📄 frame1.java~10~
字号:
package example9;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) 2005</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame1 extends JFrame { JPanel contentPane; JMenuBar jMenuBar1 = new JMenuBar(); JMenu jMenuFile = new JMenu(); JMenuItem jMenuFileExit = new JMenuItem(); JMenu jMenuHelp = new JMenu(); JMenuItem jMenuHelpAbout = new JMenuItem(); ImageIcon image1; ImageIcon image2; ImageIcon image3; XYLayout xYLayout1 = new XYLayout(); String[] patternExamples={ "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ' 'yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy,MMMMM,dd GGG hh:mm aaa" }; JComboBox jComboBox1 = new JComboBox(patternExamples); JLabel jLabel1 = new JLabel(); //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLoodAndFeel"); jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { image1 = new ImageIcon(example9.Frame1.class.getResource("openFile.png")); image2 = new ImageIcon(example9.Frame1.class.getResource("closeFile.png")); image3 = new ImageIcon(example9.Frame1.class.getResource("help.png")); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(xYLayout1); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setEnabled(true); this.setLocale(java.util.Locale.getDefault()); this.setResizable(true); this.setSize(new Dimension(400, 300)); this.setState(Frame.NORMAL); this.setTitle("Yeah"); jMenuFile.setText("File"); jMenuFileExit.setText("Exit"); jMenuFileExit.addActionListener(new Frame1_jMenuFileExit_ActionAdapter(this)); jMenuHelp.setText("Help"); jMenuHelpAbout.setText("About"); jMenuHelpAbout.addActionListener(new Frame1_jMenuHelpAbout_ActionAdapter(this)); jLabel1.setText("jLabel1"); jComboBox1.addActionListener(new Frame1_jComboBox1_actionAdapter(this)); jMenuFile.add(jMenuFileExit); jMenuHelp.add(jMenuHelpAbout); jMenuBar1.add(jMenuFile); jMenuBar1.add(jMenuHelp); contentPane.add(jComboBox1, new XYConstraints(107, 44, 165, 35)); contentPane.add(jLabel1, new XYConstraints(87, 171, 232, 34)); this.setJMenuBar(jMenuBar1); } //File | Exit action performed public void jMenuFileExit_actionPerformed(ActionEvent e) { System.exit(0); } //Help | About action performed public void jMenuHelpAbout_actionPerformed(ActionEvent e) { Frame1_AboutBox dlg = new Frame1_AboutBox(this); Dimension dlgSize = dlg.getPreferredSize(); Dimension frmSize = getSize(); Point loc = getLocation(); dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); dlg.setModal(true); dlg.pack(); dlg.show(); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { jMenuFileExit_actionPerformed(null); } } void jComboBox1_actionPerformed(ActionEvent e) { }}class Frame1_jMenuFileExit_ActionAdapter implements ActionListener { Frame1 adaptee; Frame1_jMenuFileExit_ActionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuFileExit_actionPerformed(e); }}class Frame1_jMenuHelpAbout_ActionAdapter implements ActionListener { Frame1 adaptee; Frame1_jMenuHelpAbout_ActionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jMenuHelpAbout_actionPerformed(e); }}class Frame1_jComboBox1_actionAdapter implements java.awt.event.ActionListener { Frame1 adaptee; Frame1_jComboBox1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jComboBox1_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -