posts - 38,  comments - 22,  trackbacks - 0
          公告

          兼職寫Java應(yīng)用程序 保證質(zhì)量 需要的和我聯(lián)系 大家多交流 msn:zht_dream@hotmail.com QLSC@SDU

          <2006年5月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          常用鏈接

          留言簿(3)

          隨筆分類(31)

          隨筆檔案(38)

          文章檔案(1)

          相冊

          搜索

          •  

          積分與排名

          • 積分 - 30161
          • 排名 - 1384

          最新評論

          閱讀排行榜

          評論排行榜

          sum


          1 flaot 取小數(shù)點(diǎn)

          ?/**
          ?? * 把傳入的雙精度變量或單精度變量轉(zhuǎn)化為兩位小數(shù)的形式輸出
          ?? * */
          ?? public float getInvertDataDouble(float para)
          ?? {
          ???? DecimalFormat decimalFormat=new DecimalFormat("0.00");
          ???? String s=decimalFormat.format(para);
          ???? float a=Float.parseFloat(s);
          ???? return a;
          ?? }
          ??
          2對話框顯示
          SwingUtilities.getAncestorOfClass(Frame.class,this)
          處理網(wǎng)頁對話框顯示在網(wǎng)頁底下

          3字符處理

          ???? StringTokenizer st = new StringTokenizer(CurveLabel, "%");
          ???? String[] value = new String[4];
          ???? int l = 0;
          ???? while (st.hasMoreElements()) {
          ??????? value[l] = (String) st.nextElement();
          ??????? l = l + 1;
          ???? }
          ???? String shujuleixing = value[0];
          ???? String ycxm = value[1];
          ???? String riqi = value[2];??

          4對話框

          ???????? String message = "已有DSM修正預(yù)測數(shù)據(jù)!";
          ???????? int result = JOptionPane.showOptionDialog(SwingUtilities.getAncestorOfClass(Frame.class,this), message, title,
          ???????????? optionType, messageType, null, options, options[1]);
          ????????????
          ???????????? dialog
          ????????????
          ????????????
          ????????????
          ????????????
          5布局
          ?setbounds 只有在布局為null的時(shí)候有用
          ?setPreferredSize在布局的時(shí)候有用 但是布局器可能自動設(shè)置其大小
          ?可以設(shè)置 setMaximumSize 最大大小

          ?

          6servlet和程序用的不是一個(gè)classes12包
          ?(1)servlet調(diào)用的class12和程序調(diào)用的class12不一樣 在dafaultroot里
          ?(2)ldfserver問題主要是 oracle8i 與oracle9i客戶端不兼容 將9i的dll拷到bin目錄下即可


          7
          ?????? if (e.getValueIsAdjusting()) { //list不處理
          ????????? return;
          ?????? }

          8 setVisible(true/false) 使組件是否可見
          ?加完以后要重新布一下局.revalidate();

          9JCheckBox 可以用addActionListener() 然后在actionperformed里 查看是否isSelected

          10 JTable 必須加滾動才出列名

          11對話框
          ?? ?? String title="Message Dialog";
          ?? ?? String message="";
          ?? ?? int type=JOptionPane.PLAIN_MESSAGE;
          ?? ?? if (cmd.equals("Show Error Icon")){
          ?? ?? ?? type=JOptionPane.ERROR_MESSAGE;
          ?? ?? ?? message="Error Message";
          ?? ?? }else if (cmd.equals("Show Information Icon")){
          ?? ?? ?? type=JOptionPane.INFORMATION_MESSAGE;
          ?? ?? ?? message="information Message";
          ?? ?? }else if (cmd.equals("Show Waring Icon")){
          ?? ?? ?? type=JOptionPane.WARNING_MESSAGE;
          ?? ?? ?? message="Waring Message";
          ?? ?? }else if (cmd.equals("Show Question Icon")){
          ?? ?? ?? type=JOptionPane.QUESTION_MESSAGE;
          ?? ?? ?? message="Question Message";
          ?? ?? }else if (cmd.equals("Show Plain Icon")){
          ?? ?? ?? type=JOptionPane.PLAIN_MESSAGE;
          ?? ?? ?? message="Plain Message";
          ?? ?? }else if (cmd.equals("Show User Define Icon")){
          ?? ?? ?? type=JOptionPane.PLAIN_MESSAGE;
          ?? ?? ?? JOptionPane.showMessageDialog(f,message,title,type,new ImageIcon("..\\icons\\glass.jpg"));
          ?? ?? ?? return ;
          ?? ?? }
          ?? ?? JOptionPane.showMessageDialog(f,message,title,type);

          12
          ??? table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//自動設(shè)置大小 在用滾動條的時(shí)候管用
          ??? table.setColumnSelectionAllowed(true);//設(shè)置選擇模式 行或列


          13 list觸發(fā)兩次事件處理
          ??????? if (e.getValueIsAdjusting()) { //list不處理
          ????????? return;
          ?????? }

          14 和list里的內(nèi)容進(jìn)行比較
          ?DefaultListModel getdm=(DefaultListModel) sflist.getModel();
          ???if(getdm.contains(name))
          ???{
          ????type = JOptionPane.ERROR_MESSAGE;
          ????message = "組合算法名稱已經(jīng)存在!";
          ????JOptionPane.showMessageDialog(f, message, title, type);
          ????return;
          ???}


          15進(jìn)度條
          ?import java.awt.Container;
          import java.awt.Dimension;
          import java.awt.FlowLayout;
          import java.awt.Rectangle;
          import java.awt.event.ActionEvent;
          import java.awt.event.ActionListener;

          import javax.swing.*;

          public class ProgressBartr implements ActionListener {

          ?/**
          ? * @param args
          ? */
          ?JProgressBar pb = new JProgressBar();

          ?public static void main(String[] args) {
          ??// TODO 自動生成方法存根
          ??new ProgressBartr();
          ?}
          ?public ProgressBartr() {
          ??JFrame f = new JFrame();
          ??Container con=f.getContentPane();
          ??con.setLayout(new FlowLayout());
          ??JButton jb=new JButton("button");
          ??jb.addActionListener(this);
          ??//pb.setIndeterminate(true);
          ??pb.setValue(0);
          ??pb.setMaximum(100);
          ??pb.setStringPainted(true);
          ??pb.setPreferredSize(new Dimension(250,25));
          ??pb.setMaximumSize(new Dimension(250,250));
          ??con.add(jb);
          ??con.add(pb);
          ??f.setBounds(new Rectangle(300, 300, 300, 300));
          ??f.show();
          ?}
          ?public void actionPerformed(ActionEvent arg0) {
          ??// TODO 自動生成方法存根
          ??Thread runner = new Thread() {
          ???public void run() {
          ????pb.setStringPainted(true);
          ????for (int i = 0; i < 100; i++) {
          ?????pb.setValue(i);
          ?????try {
          ??????sleep(100);
          ?????} catch (InterruptedException e) {
          ??????// TODO 自動生成 catch 塊
          ??????e.printStackTrace();
          ?????}
          ????}
          ????pb.setValue(0);
          ????pb.setStringPainted(false);
          ???}
          ??};
          ??runner.start();
          ?}

          }
          16 數(shù)據(jù)庫操作 日期轉(zhuǎn)換????????
          ?select * from table where MARKETDATE(date)=to_date('2006/03/19','yyyy/mm/dd')
          ?告訴 日期格式 自動轉(zhuǎn)換

          17 applet ---->jsp
          ? public void toNext() {
          ??? try{
          ????? this.getAppletContext().showDocument(new URL(this.getCodeBase()+"pmCtrDecFiv_up.jsp?year="+year+"&unit_id="+unit_id),"_blank");
          ???? }catch(Exception ex){}
          ? }

          18?tree 線顯示為紅色
          ? UIManager.put( "Tree.hash", new ColorUIResource(Color.red) );


          19 JButton顏色切換
          ????if(obj==jb)
          ???{
          ????jb.setBackground(Color.ORANGE);
          ????jb1.setBackground(null);
          ???}
          ???if(obj==jb1)
          ???{
          ????jb1.setBackground(Color.ORANGE);
          ????jb.setBackground(null);
          ???}


          20 ftp處理
          ???try {
          ???FTPClient fc = new FTPClient("10.34.20.78");
          ???fc.login("ftp", "ftp");
          ???fc.setType(FTPTransferType.ASCII);
          ???fc.put("e:/java/ftp/ftp.TXT", "/abc/b.txt");//第一個(gè)參數(shù)為源 第二個(gè)為目的
          ???fc.quit();
          ??} catch (Exception e) {}

          21StringTokenizer
          ?????????????????? StringTokenizer st = new StringTokenizer("sss%ddd%eee%ttt%", "%");
          ????????????????? Vector val = new Vector();
          ????????????????? int l = 0;
          ????????????????? System.out.print(st.countTokens() );
          ????????????????? int num=st.countTokens() ;
          ????????????????? while (st.hasMoreElements()) {
          ??????????????????????? val.addElement(st.nextElement());
          ??????????????????????? l = l + 1;
          ????????????????? }

          22得到服務(wù)器IP

          ?this.getCodeBase().toString()

          23? Runtime.getRuntime().exec("ping 172.20.42.71");
          ?執(zhí)行命令
          ?String URL="\"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE\"
          http://www.china.com ";
          ??Process pp=Runtime.getRuntime().exec(URL);

          24??? 將字符串轉(zhuǎn)換為Date
          ?import java.text.SimpleDateFormat;
          ?String t="2006-05-09";
          ?SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
          ?Date d=sdf1.parase(t);

          25 setOpaque(false)設(shè)置透明

          26 OptionPane設(shè)置背景顏色
          Color oldColor1=UIManager.getColor("OptionPane.background");??????? Color oldColor2=UIManager.getColor("Panel.background");??????? String okButtonText=UIManager.getString("OptionPane.okButtonText");??????? String okButtonMnemonic=UIManager.getString("OptionPane.okButtonMnemonic");

          ?????? UIManager.put("OptionPane.background",Color.cyan);??????? UIManager.put("Panel.background",Color.yellow);??????? UIManager.put("OptionPane.okButtonText","HaHaHa!!!");??????? UIManager.put("OptionPane.okButtonMnemonic",""+((int)'H'));??????? JOptionPane.showMessageDialog(this,"<HTML><B>SUNKING</B><BR><Font Color=green>"????????????????????????????????????? +"SUNKING? </font><BR><I>SUNKING</I></html>");

          ?????? UIManager.put("OptionPane.background",oldColor1);??????? UIManager.put("Panel.background",oldColor2);??????? UIManager.put("OptionPane.okButtonText",okButtonText);??????? UIManager.put("OptionPane.okButtonMnemonic",okButtonMnemonic);

          27使用圖片 ../指上一層
          URL url=chat.MainFrame.class.getResource("../images/mm.jpg") ;

          posted on 2006-05-22 11:56 aaabbb 閱讀(376) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 孟连| 雅江县| 洛南县| 东莞市| 大姚县| 广丰县| 新龙县| 寿阳县| 长沙县| 海晏县| 松溪县| 安丘市| 金堂县| 罗城| 将乐县| 南昌县| 古交市| 榆社县| 河曲县| 定兴县| 泽州县| 元朗区| 天气| 开江县| 镇平县| 洮南市| 家居| 湄潭县| 龙井市| 喀什市| 黄石市| 阿坝| 垦利县| 石河子市| 凯里市| 泾阳县| 临猗县| 沁水县| 同江市| 霞浦县| 济阳县|