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

📄 zuoye1.java

📁 主要完成一些窗口的建立
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author Administrator *///import com.sun.org.apache.regexp.internal.REDebugCompiler;import java.awt.*;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import javax.swing.*;import java.awt.event.*;public class ZuoYe1 extends JFrame implements ActionListener{    JCheckBox checkbox1,checkbox2;    JRadioButton blue, red;    JButton OK;    private JTextArea text ;   private ButtonGroup bgt=new ButtonGroup ();    public ZuoYe1(){      Container container= getContentPane();        container.setLayout(new BorderLayout());    JPanel p1=new JPanel();    p1.setLayout(new BorderLayout());    JPanel p2=new JPanel();    p2.setLayout(new GridLayout(2,1));    p2.add(checkbox1=new JCheckBox("checkbox1"));    p2.add(checkbox2=new JCheckBox("checkbox2"));    JPanel p3=new JPanel();    p3.setLayout(new GridLayout(2,1));    p3.add (blue=new JRadioButton("blue"));    p3.add (red=new JRadioButton("red"));    bgt.add(blue);    bgt.add(red);    p1.add(p2,BorderLayout.WEST);    p1.add(p3,BorderLayout.CENTER);    container.add(p1,BorderLayout.NORTH);    container.add(text=new JTextArea(""),BorderLayout.CENTER);    container.add(OK=new JButton("OK"),BorderLayout.SOUTH);    checkbox1.addActionListener(this);    checkbox2.addActionListener(this);    red.addActionListener(this);    blue.addActionListener(this);    OK.addActionListener(this);    }    public void actionPerformed(ActionEvent e){    if(e.getSource() == checkbox1){     text.append("check1 is select"+"\n");    }        if(e.getSource() == checkbox2){     text.append("checkbox2 is select"+ "\n");        }      if(e.getSource() == red){     text.setBackground(Color.red);            }       if(e.getSource() == blue){        text.setBackground(Color.blue);    }     if(e.getSource() == OK){        text.append("Butten is beaten"+ "\n");      }    }        public static void main(String[] args){        ZuoYe1 frame=new  ZuoYe1();        frame.setTitle("example");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.setSize(400,250);        frame.setVisible(true);        }}

⌨️ 快捷键说明

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