⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strseldia.java

📁 JTREE的例子
💻 JAVA
字号:
package util4;import javax.swing.*;import java.awt.*;import java.awt.event.*;import util2.*;import util3.*;public class StrSelDia extends JDialog{  JPanel jPanel1 = new JPanel();  GridBagLayout gridBagLayout1 = new GridBagLayout();  JLabel lab1 = new JLabel();  JTextField tf = new JTextField();  JLabel nulLab1 = new JLabel();  JButton finishBut = new JButton();  JButton continueBut = new JButton();  JRadioButton bacRadi = new JRadioButton();  JRadioButton forRadi = new JRadioButton();  JLabel jLabel1 = new JLabel();  FindStrListener fsl;  String strToFind="";  public StrSelDia(Frame frame,String title)  {    super(frame,title,false);    try{jbInit();}    catch(Exception e){e.printStackTrace();}  }  private void jbInit() throws Exception  {    jPanel1.setLayout(gridBagLayout1);    lab1.setFont(new java.awt.Font("Dialog", 1, 14));    lab1.setText("String to find : ");    tf.setFont(new java.awt.Font("Dialog", 0, 14));    tf.setCaretPosition(0);    tf.setText(" ");    tf.addActionListener(new ActionListener(){      public void actionPerformed(ActionEvent e){        continueBut.doClick();      }    });    nulLab1.setFont(new java.awt.Font("Dialog", 1, 18));    nulLab1.setText(" ");    finishBut.setActionCommand("cancelBut");    finishBut.setText("Finish");    continueBut.setActionCommand("okBut");    continueBut.setText("Continue");    bacRadi.setText("Backward");    bacRadi.setForeground(SystemColor.textHighlight);    bacRadi.setFont(new java.awt.Font("Dialog", 1, 13));    forRadi.setText("Forward");    forRadi.setForeground(SystemColor.textHighlight);    forRadi.setFont(new java.awt.Font("Dialog", 1, 13));    jLabel1.setFont(new java.awt.Font("Dialog", 1, 13));    jLabel1.setText(" ");    this.getContentPane().add(jPanel1, BorderLayout.CENTER);    jPanel1.add(lab1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel1.add(tf, new GridBagConstraints(1, 0, 3, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel1.add(jLabel1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel1.add(nulLab1, new GridBagConstraints(1, 1, 3, 1, 0.0, 0.0            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel1.add(finishBut, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0            ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 15), 0, 0));    jPanel1.add(continueBut,        new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0            ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel1.add(forRadi, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0            ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    jPanel1.add(bacRadi, new GridBagConstraints(2, 2, 2, 1, 0.0, 0.0            ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));    tf.setColumns(20);    forRadi.setSelected(true);    setBounds(200,190,340,160);    forRadi.addActionListener(new ActionListener(){      public void actionPerformed(ActionEvent e){        bacRadi.setSelected(false);      }    });    bacRadi.addActionListener(new ActionListener(){      public void actionPerformed(ActionEvent e){        forRadi.setSelected(false);      }    });    finishBut.addActionListener(new ActionListener(){      public void actionPerformed(ActionEvent e){        StrSelDia.this.setVisible(false);      }    });    continueBut.addActionListener(new ActionListener(){      public void actionPerformed(ActionEvent e){        if((strToFind=tf.getText()).length()==0) return;        if(!forRadi.isSelected()){          fsl.backward(strToFind);        }        else fsl.forward(strToFind);      }    });    this.addWindowListener(new WindowAdapter(){      public void windowClosing(WindowEvent e){        StrSelDia.this.setVisible(false);      }    });  }  public void addFindStrListener(FindStrListener li){    this.fsl=li;  }  public void showIt(){    this.tf.setText(this.strToFind);    this.setVisible(true);    //tf.selectAll();  }  public static void main(String[] arg){/*    JFrame jf=new JFrame("try");    jf.setBounds(200,200,200,200);    StrSelDia ssp=new StrSelDia("Find string");    ssp.setBounds(250,250,400,150);    jf.show();    ssp.show();*/  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -