Frame1.java~1~
资源名称:Java.rar [点击查看]
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:2k
源码类别:
Java编程
开发平台:
Java
- package gao;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- public class Frame1 extends JFrame {
- private JPanel contentPane;
- private JToolBar jToolBar = new JToolBar();
- private JButton jButton1 = new JButton();
- private JButton jButton2 = new JButton();
- private JButton jButton3 = new JButton();
- private ImageIcon image1;
- private ImageIcon image2;
- private ImageIcon image3;
- private JLabel statusBar = new JLabel();
- private BorderLayout borderLayout1 = new BorderLayout();
- //Construct the frame
- public Frame1() {
- enableEvents(AWTEvent.WINDOW_EVENT_MASK);
- try {
- jbInit();
- }
- catch(Exception e) {
- e.printStackTrace();
- }
- }
- //Component initialization
- private void jbInit() throws Exception {
- image1 = new ImageIcon(gao.Frame1.class.getResource("openFile.gif"));
- image2 = new ImageIcon(gao.Frame1.class.getResource("closeFile.gif"));
- image3 = new ImageIcon(gao.Frame1.class.getResource("help.gif"));
- //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
- contentPane = (JPanel) this.getContentPane();
- contentPane.setLayout(borderLayout1);
- this.setSize(new Dimension(400, 300));
- this.setTitle("Frame Title");
- statusBar.setText(" ");
- jButton1.setIcon(image1);
- jButton1.setToolTipText("Open File");
- jButton2.setIcon(image2);
- jButton2.setToolTipText("Close File");
- jButton3.setIcon(image3);
- jButton3.setToolTipText("Help");
- jToolBar.add(jButton1);
- jToolBar.add(jButton2);
- jToolBar.add(jButton3);
- contentPane.add(jToolBar, BorderLayout.NORTH);
- contentPane.add(statusBar, BorderLayout.SOUTH);
- }
- //File | Exit action performed
- public void jMenuFileExit_actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- //Help | About action performed
- public void jMenuHelpAbout_actionPerformed(ActionEvent e) {
- }
- //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);
- }
- }
- }