📄 usingswingframe.java~5~
字号:
package usingswing;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <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(); //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(); 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!"); 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.NORTH); jPanel2.add(jPanel6, BorderLayout.SOUTH); jPanel6.add(jLabel2, BorderLayout.WEST); jTabbedPane1.add(jPanel3, "开关演示"); jTabbedPane1.add(jPanel4, "列表框演示"); } //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 + -