📄 usingswingframe.java~6~
字号:
package usingswing;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import javax.swing.border.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class usingSwingFrame extends JFrame { JPanel contentPane; BorderLayout borderLayout1 = new BorderLayout(); JTabbedPane jTabbedPane1 = new JTabbedPane(); JPanel jPanel1 = new JPanel(); JPanel jPanel2 = new JPanel(); JPanel jPanel3 = new JPanel(); JPanel jPanel4 = new JPanel(); XYLayout xYLayout1 = new XYLayout(); BorderLayout borderLayout2 = new BorderLayout(); BorderLayout borderLayout3 = new BorderLayout(); XYLayout xYLayout2 = new XYLayout(); JLabel jLabel1 = new JLabel(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JToggleButton jToggleButton1 = new JToggleButton(); JToggleButton jToggleButton2 = new JToggleButton(); JPanel jPanel5 = new JPanel(); JPanel jPanel6 = new JPanel(); BorderLayout borderLayout4 = new BorderLayout(); BorderLayout borderLayout5 = new BorderLayout(); JLabel jLabel2 = new JLabel(); JPanel jPanel7 = new JPanel(); JPanel jPanel8 = new JPanel(); VerticalFlowLayout verticalFlowLayout1 = new VerticalFlowLayout(); VerticalFlowLayout verticalFlowLayout2 = new VerticalFlowLayout(); JRadioButton jRadioButton1 = new JRadioButton(); JRadioButton jRadioButton2 = new JRadioButton(); JRadioButton jRadioButton3 = new JRadioButton(); JRadioButton jRadioButton4 = new JRadioButton(); JRadioButton jRadioButton5 = new JRadioButton(); ButtonGroup buttonGroup1 = new ButtonGroup(); JCheckBox jCheckBox1 = new JCheckBox(); JCheckBox jCheckBox2 = new JCheckBox(); JCheckBox jCheckBox3 = new JCheckBox(); JCheckBox jCheckBox4 = new JCheckBox(); JTextField jTextField1 = new JTextField(); JTextArea jTextArea1 = new JTextArea(); JLabel jLabel3 = new JLabel(); private String[] data={“白菜”,“黄瓜”,“茄子”,“冬瓜”,“豆腐”}; JList jList1 = new JList(data); TitledBorder titledBorder1; Border border1; TitledBorder titledBorder2; //Construct the frame public usingSwingFrame() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); titledBorder1 = new TitledBorder(""); border1 = BorderFactory.createEmptyBorder(); titledBorder2 = new TitledBorder(BorderFactory.createEmptyBorder(),"列表框"); contentPane.setLayout(borderLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("使用sWing组建Java的应用系统"); jPanel1.setLayout(xYLayout1); jPanel2.setLayout(borderLayout2); jPanel3.setLayout(borderLayout3); jPanel4.setLayout(xYLayout2); jLabel1.setForeground(Color.black); jLabel1.setText(""); jButton1.setPreferredSize(new Dimension(99, 25)); jButton1.setText("显示文字"); jButton2.setPreferredSize(new Dimension(99, 25)); jButton2.setText("隐藏文字"); jToggleButton1.setText("文字颜色设置"); jToggleButton2.setText("文字大小开关"); jPanel5.setLayout(borderLayout4); jPanel6.setLayout(borderLayout5); jLabel2.setText(""); jPanel7.setLayout(verticalFlowLayout1); jPanel8.setLayout(verticalFlowLayout2); jRadioButton1.setActionCommand("jRadioButton1"); jRadioButton1.setText("Hao are you ,friends!"); jRadioButton2.setText("Good Eveny,friends!"); jRadioButton2.addActionListener(new usingSwingFrame_jRadioButton2_actionAdapter(this)); jRadioButton3.setText("Good MIdnoon,friends!"); jRadioButton4.setText("Goodbye,friends!"); jRadioButton5.setText("Good Morning,friends!"); jCheckBox1.setText("设置背景颜色"); jCheckBox2.setText("设置前景颜色"); jCheckBox3.setText("设置字体为斜体"); jCheckBox4.setPreferredSize(new Dimension(103, 25)); jCheckBox4.setText("设计字体为大写"); jTextField1.setText("Please input words here:"); jTextArea1.setEnabled(false); jTextArea1.setEditable(false); jTextArea1.setText(""); jLabel3.setText(""); jList1.setBackground(Color.lightGray); jList1.setBorder(titledBorder2); jList1.setDebugGraphicsOptions(0); jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jPanel7.add(jRadioButton5, null); jPanel7.add(jRadioButton4, null); jPanel7.add(jRadioButton3, null); contentPane.add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.add(jPanel1, "按钮和开关演示"); jPanel1.add(jLabel1, new XYConstraints(0, 0, -1, -1)); jPanel1.add(jButton1, new XYConstraints(67, 46, -1, -1)); jPanel1.add(jButton2, new XYConstraints(192, 46, -1, -1)); jPanel1.add(jToggleButton1, new XYConstraints(67, 100, -1, -1)); jPanel1.add(jToggleButton2, new XYConstraints(192, 99, -1, -1)); jTabbedPane1.add(jPanel2, "单选和多选按钮演示"); jPanel2.add(jPanel5, BorderLayout.CENTER); jPanel5.add(jPanel7, BorderLayout.CENTER); jPanel7.add(jRadioButton2, null); jPanel7.add(jRadioButton1, null); jPanel5.add(jPanel8, BorderLayout.EAST); jPanel8.add(jCheckBox4, null); jPanel8.add(jCheckBox3, null); jPanel8.add(jCheckBox2, null); jPanel8.add(jCheckBox1, null); jPanel2.add(jPanel6, BorderLayout.SOUTH); jPanel6.add(jLabel2, BorderLayout.WEST); jTabbedPane1.add(jPanel3, "开关演示"); jPanel3.add(jTextField1, BorderLayout.NORTH); jPanel3.add(jTextArea1, BorderLayout.CENTER); jTabbedPane1.add(jPanel4, "列表框演示"); jPanel4.add(jLabel3, new XYConstraints(102, 90, -1, -1)); jPanel4.add(jList1, new XYConstraints(259, 106, -1, -1)); buttonGroup1.add(jRadioButton5); buttonGroup1.add(jRadioButton4); buttonGroup1.add(jRadioButton3); buttonGroup1.add(jRadioButton2); buttonGroup1.add(jRadioButton1); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jRadioButton2_actionPerformed(ActionEvent e) { }}class usingSwingFrame_jRadioButton2_actionAdapter implements java.awt.event.ActionListener { usingSwingFrame adaptee; usingSwingFrame_jRadioButton2_actionAdapter(usingSwingFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jRadioButton2_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -