📄 uidesignerdemo.java~20~
字号:
package JSwingDemo;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Font;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.GridBagLayout;
import java.awt.*;
public class UIDesignerDemo extends JFrame {
public UIDesignerDemo() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
UIDesignerDemo uidesignerdemo = new UIDesignerDemo();
}
private void jbInit() throws Exception {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocale(new java.util.Locale("zh", "CN", ""));
this.setSize(300,300);
this.setJMenuBar(jMenuBar1);
this.setTitle("UIDemo");
this.setVisible(true);
jMenu1.setText("文件");
jMenu2.setText("编辑");
jMenu3.setText("格式");
jMenuItem1.setText("打开");
jMenuItem1.addActionListener(new
UIDesignerDemo_jMenuItem1_actionAdapter(this));
jMenuItem2.setText("退出");
jMenuItem2.addActionListener(new UIDesignerDemo_jMenuItem2_actionAdapter(this));
jMenuItem4.setText("关闭");
jPanel1.setLayout(gridBagLayout1);
jButton1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 14));
jButton1.setText("打开");
jButton1.addActionListener(new UIDesignerDemo_jButton1_actionAdapter(this));
jButton2.setText("jButton2");
jButton3.setText("jButton3");
jButton4.setText("jButton4");
jButton5.setText("jButton5");
jRadioButton1.setText("jRadioButton1");
jPanel1.setToolTipText("");
jButton6.setText("jButton6");
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
jMenuBar1.add(jMenu3);
jMenu1.add(jMenuItem1);
jMenu1.add(jMenuItem4);
jMenu1.addSeparator();
jMenu1.add(jMenuItem2);
this.getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
jPanel1.add(jButton1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(5, 5, 0, 0), 0, 0));
jPanel1.add(jButton2, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(5, 0, 0, 0), 0, 0));
jPanel1.add(jButton3, new GridBagConstraints(2, 0, 2, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(5, 0, 0, 6), 0, 0));
jPanel1.add(jButton4, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(5, 0, 0, 0), 0, 0));
jPanel1.add(jRadioButton1, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(5, 0, 0, 0), 0, 0));
jPanel1.add(jButton5, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(5, 0, 0, 0), 0, 0));
jPanel1.add(jComboBox1, new GridBagConstraints(1, 2, 1, 2, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(27, 24, 137, 31), 0, 0));
jPanel1.add(jList1,
new GridBagConstraints(3, 3, GridBagConstraints.REMAINDER,
GridBagConstraints.REMAINDER, 1.0,
1.0
, GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jList2,
new GridBagConstraints(3, 3, GridBagConstraints.REMAINDER,
GridBagConstraints.REMAINDER, 1.0,
1.0
, GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
jPanel1.add(jButton6, new GridBagConstraints(2, 1, 2, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(58, 11, 0, 0), 0, 0));
//
}
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JMenu jMenu2 = new JMenu();
JMenu jMenu3 = new JMenu();
JMenuItem jMenuItem1 = new JMenuItem();
JMenuItem jMenuItem2 = new JMenuItem();
JMenuItem jMenuItem3 = new JMenuItem();
JMenuItem jMenuItem4 = new JMenuItem();
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JRadioButton jRadioButton1 = new JRadioButton();
JComboBox jComboBox1 = new JComboBox();
JList jList1 = new JList();
JList jList2 = new JList();
JButton jButton6 = new JButton();
GridBagLayout gridBagLayout1 = new GridBagLayout();
public void jMenuItem2_actionPerformed(ActionEvent e) {
System.exit(0);
}
public void jMenuItem1_actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,"您选择了:"+e.getActionCommand()+"菜单");
}
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null,"您选择了:"+e.getActionCommand()+"按钮");
}
}
class UIDesignerDemo_jButton1_actionAdapter implements ActionListener {
private UIDesignerDemo adaptee;
UIDesignerDemo_jButton1_actionAdapter(UIDesignerDemo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.actionPerformed(e);
}
}
class UIDesignerDemo_jMenuItem1_actionAdapter implements ActionListener {
private UIDesignerDemo adaptee;
UIDesignerDemo_jMenuItem1_actionAdapter(UIDesignerDemo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuItem1_actionPerformed(e);
}
}
class UIDesignerDemo_jMenuItem2_actionAdapter implements ActionListener {
private UIDesignerDemo adaptee;
UIDesignerDemo_jMenuItem2_actionAdapter(UIDesignerDemo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuItem2_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -