Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.androcode.LDB;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import java.util.logging.*;
- public class Main {
- // Component prototypes:
- // Labels:
- JLabel mainMenuLabel;
- // Buttons:
- JButton addLanternButton;
- JButton findLanternButton;
- JButton viewAllButton;
- JButton exitButton;
- // Panels:
- JPanel setPanel;
- JPanel aLPanel;
- // Main Frame function:
- public Main() {
- initComponents();
- }
- // Component initiation function:
- public void initComponents() {
- // Constraint variable for the GridBag Layout:
- GridBagConstraints constraints;
- // Main JFrame:
- JFrame mainFrame = new JFrame( "Lighting DB" );
- mainFrame.setPreferredSize ( new Dimension ( 500, 400 ) );
- mainFrame.getContentPane().setLayout ( new GridBagLayout() );
- // Frame and Component information:
- // Labels:
- mainMenuLabel = new JLabel ( "Main Menu" );
- mainFrame.getContentPane().add ( mainMenuLabel, new GridBagConstraints() );
- // Buttons:
- addLanternButton = new JButton ( "Add Lantern" );
- addLanternButton.setMnemonic ( 'A' );
- addLanternButton.setPreferredSize ( new Dimension ( 120, 25 ) );
- constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 1;
- mainFrame.getContentPane().add ( addLanternButton, constraints );
- findLanternButton = new JButton ( "Find Lantern(s)" );
- findLanternButton.setMnemonic ( 'F' );
- findLanternButton.setPreferredSize ( new Dimension ( 120, 25 ) );
- constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 2;
- mainFrame.getContentPane().add ( findLanternButton, constraints );
- viewAllButton = new JButton ( "View All" );
- viewAllButton.setMnemonic ( 'V' );
- viewAllButton.setPreferredSize ( new Dimension ( 120, 25 ) );
- constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 3;
- mainFrame.getContentPane().add ( viewAllButton, constraints );
- exitButton = new JButton ( "Exit" );
- exitButton.setMnemonic ( 'E' );
- exitButton.setPreferredSize ( new Dimension ( 80, 25 ) );
- constraints = new GridBagConstraints();
- constraints.gridx = 0;
- constraints.gridy = 10;
- constraints.anchor = GridBagConstraints.NORTHWEST;
- mainFrame.getContentPane().add ( exitButton, constraints );
- // Panels:
- setPanel = new JPanel();
- setPanel.setLayout ( new GridBagLayout() );
- constraints = new GridBagConstraints();
- constraints.gridx = 2;
- constraints.gridy = 0;
- constraints.gridwidth = 11;
- constraints.gridheight = 10;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- mainFrame.getContentPane().add ( setPanel, constraints );
- aLPanel = new JPanel();
- aLPanel.setLayout ( new GridBagLayout() );
- //aLPanel.add ( new addLanternPanel() ); // TODO - When addLanternPanel() is created, remove comments
- setPanel.add ( aLPanel, new GridBagConstraints() );
- mainFrame.pack();
- // Button ActionListeners:
- addLanternButton.addActionListener ( new ActionListener() {
- public void actionPerformed ( ActionEvent e ) {
- // TODO - add an albActionPerformed() here when created
- }
- } );
- findLanternButton.addActionListener ( new ActionListener() {
- public void actionPerformed ( ActionEvent e ) {
- // TODO - add an flbActionPerformed() here when created
- }
- } );
- viewAllButton.addActionListener ( new ActionListener() {
- public void actionPerformed ( ActionEvent e ) {
- // TODO - add an vabActionPerformed() here when created
- }
- } );
- exitButton.addActionListener ( new ActionListener() {
- public void actionPerformed ( ActionEvent e ) {
- ebActionPerformed ( e );
- }
- } );
- }
- // TODO - Button ActionPerformed functions ONLY ADD WHEN NEEDED to prevent confusion:
- private void ebActionPerformed ( ActionEvent e ) {
- System.exit ( 0 );
- }
- public static void main ( String args[] ) {
- EventQueue.invokeLater ( new Runnable() {
- public void run() {
- new Main().setVisible ( true );
- }
- } );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement