Advertisement
0xff42

KWBAGUI

Aug 5th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.12 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2.  
  3. public class KWBAGUI extends JFrame {
  4.  
  5.     /**
  6.      *
  7.      */
  8.     private static final long serialVersionUID = 1L;
  9.     private JPanel contentPane;
  10.     private JMenuItem mntmRefresh;
  11.     private JMenuItem mntmExit;
  12.     private JMenu mnHelp;
  13.     private JMenuItem mntmAbout;
  14.     private JLabel label;
  15.  
  16.     /**
  17.      * Launch the application.
  18.      */
  19.     public static void main(String[] args) {
  20.     EventQueue.invokeLater(new Runnable() {
  21.         public void run() {
  22.         try {
  23.             KWBAGUI frame = new KWBAGUI();
  24.             frame.setVisible(true);
  25.         } catch (Exception e) {
  26.             e.printStackTrace();
  27.         }
  28.         }
  29.     });
  30.     }
  31.  
  32.     /**
  33.      * init stuff
  34.      */
  35.     public KWBAGUI() {
  36.     initGUI();
  37.     this.setVisible(true);
  38.     }
  39.  
  40.     private void initGUI() {
  41.     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  42.     setBounds(100, 100, 900, 600);
  43.     this.setTitle("");
  44.     this.setResizable(false);
  45.     JMenuBar menuBar = new JMenuBar();
  46.     setJMenuBar(menuBar);
  47.    
  48.     JMenu mnFile = new JMenu("File");
  49.     menuBar.add(mnFile);
  50.    
  51.     mntmRefresh = new JMenuItem("Refresh");
  52.     mnFile.add(mntmRefresh);
  53.    
  54.     mntmExit = new JMenuItem("Exit");
  55.     mnFile.add(mntmExit);
  56.    
  57.     mnHelp = new JMenu("Help");
  58.     menuBar.add(mnHelp);
  59.    
  60.     mntmAbout = new JMenuItem("About");
  61.     mnHelp.add(mntmAbout);
  62.     contentPane = new JPanel();
  63.     contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  64.     setContentPane(contentPane);
  65.     contentPane.setLayout(new BorderLayout(0, 0));
  66.    
  67.     label = new JLabel("");
  68.     label.setHorizontalAlignment(SwingConstants.CENTER);
  69.     label.setIcon(new ImageIcon("res/weather.png"));
  70.     contentPane.add(label);
  71.     }
  72.  
  73.     public JMenuItem getMntmRefresh() {
  74.         return mntmRefresh;
  75.     }
  76.  
  77.     public JMenuItem getMntmExit() {
  78.         return mntmExit;
  79.     }
  80.  
  81.     public JMenu getMnHelp() {
  82.         return mnHelp;
  83.     }
  84.  
  85.     public JMenuItem getMntmAbout() {
  86.         return mntmAbout;
  87.     }
  88.  
  89.     public void refreshPicture() {
  90.     this.label.setIcon(new ImageIcon("res/weather.png"));
  91.     this.label.updateUI();
  92.     }
  93.  
  94.     public void showHelp() {
  95.     JOptionPane.showMessageDialog(this,"Some information.");
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement