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

📄 addwordsframe.java

📁 Java AWT界面例子
💻 JAVA
字号:
package end;import java.awt.*;import javax.swing.*;import java.awt.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author unascribed * @version 1.0 */class AddWordsFrame extends JFrame {  JPanel contentPane;  JTextPane Wordsin = new JTextPane();  JTextPane Transin = new JTextPane();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  Image icon;  public AddWordsFrame() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception {    this.setSize(320,240);    icon=getToolkit().getImage("ico.gif");    this.setIconImage(icon);    contentPane =(JPanel)this.getContentPane();    contentPane.setSize(320,240);    contentPane.setLayout(null);    contentPane.setBackground(new Color(226, 245, 255));    contentPane.setAlignmentX((float) 1.0);    contentPane.setAlignmentY((float) 1.0);    contentPane.setToolTipText("");    contentPane.setActionMap(null);    Wordsin.setBackground(new Color(245, 251, 255));    Wordsin.setFont(new java.awt.Font("SansSerif", 0, 12));    Wordsin.setForeground(Color.blue);    Wordsin.setBounds(new Rectangle(85, 8, 208, 22));    Transin.setBackground(new Color(245, 251, 255));    Transin.setFont(new java.awt.Font("SansSerif", 0, 12));    Transin.setForeground(Color.blue);    Transin.setBounds(new Rectangle(17, 60, 191, 150));    jButton1.setBackground(new Color(188, 244, 224));    jButton1.setBounds(new Rectangle(214, 127, 89, 28));    jButton1.setFont(new java.awt.Font("SansSerif", 0, 12));    jButton1.setText("确定");    jButton1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton1_actionPerformed(e);      }    });    jButton2.setBackground(new Color(188, 244, 224));    jButton2.setBounds(new Rectangle(213, 173, 91, 28));    jButton2.setFont(new java.awt.Font("SansSerif", 0, 12));    jButton2.setText("取消");    jButton2.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        jButton2_actionPerformed(e);      }    });    this.setFont(new java.awt.Font("SansSerif", 0, 12));    this.setResizable(false);    this.setTitle("添加单词");    jLabel1.setBackground(new Color(245, 251, 255));    jLabel1.setFont(new java.awt.Font("SansSerif", 0, 12));    jLabel1.setText("输入单词");    jLabel1.setBounds(new Rectangle(3, 6, 75, 28));    jLabel2.setBounds(new Rectangle(5, 38, 75, 24));    jLabel2.setBackground(new Color(245, 251, 255));    jLabel2.setFont(new java.awt.Font("SansSerif", 0, 12));    jLabel2.setText("输入解释");    contentPane.add(Transin, null);    contentPane.add(jButton1, null);    contentPane.add(jButton2, null);    contentPane.add(Wordsin, null);    contentPane.add(jLabel1, null);    contentPane.add(jLabel2, null);  }  void jButton1_actionPerformed(ActionEvent e) {      if(Wordsin.getText()!="")      {          frame.addwords(Wordsin.getText(),Transin.getText());      }      close();  }  void jButton2_actionPerformed(ActionEvent e) {      close();  }  void close()  {      processWindowEvent(new WindowEvent(this,WindowEvent.WINDOW_CLOSING));  }}

⌨️ 快捷键说明

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