001package bradleyross.library.tools; 002 003// import javax.swing.JApplet; 004// import javax.swing.event.*; 005// import javax.swing.border.*; 006// import java.awt.event.*; 007// import java.awt.*; 008// import javax.swing.event.MenuListener; 009// import javax.swing.event.MenuEvent; 010import java.awt.event.ActionEvent; 011import java.awt.event.ActionListener; 012import java.awt.GridBagLayout; 013import java.awt.GridBagConstraints; 014import javax.swing.JFrame; 015import javax.swing.JPanel; 016import javax.swing.JMenu; 017import javax.swing.JMenuItem; 018import javax.swing.JMenuBar; 019import javax.swing.SwingUtilities; 020import bradleyross.library.helpers.ExceptionHelper; 021// import org.apache.logging.log4j.Logger; 022import org.apache.logging.log4j.LogManager; 023/** 024 * This will be the main class for the jar file. 025 * 026 * It will open a Java Swing demostration that will 027 * drive the other classes. 028 * @author Bradley Ross 029 * 030 */ 031public class MasterIndex { 032 protected ExceptionHelper logger = new ExceptionHelper(LogManager.getLogger()); 033 protected JFrame frame = null; 034 protected JMenuBar menuBar = null; 035 protected ActionListener menuListener = null; 036 public void buildMenuBar(JMenuBar menuBar) { 037 menuListener = new MenuActions(); 038 JMenu file = new JMenu("File"); 039 menuBar.add(file); 040 JMenuItem open = new JMenuItem("Open"); 041 open.setActionCommand("OPEN"); 042 file.add(open); 043 open.addActionListener(menuListener); 044 JMenuItem save = new JMenuItem("Save"); 045 save.setActionCommand("SAVE"); 046 save.addActionListener(menuListener); 047 file.add(save); 048 JMenuItem exit = new JMenuItem("Exit"); 049 exit.setActionCommand("EXIT"); 050 exit.addActionListener(menuListener); 051 file.add(exit); 052 } 053 protected class MenuActions implements ActionListener { 054 055 public void actionPerformed(ActionEvent e) { 056 System.out.println(e.getActionCommand()); 057 } 058 } 059 public class MainPage implements Runnable { 060 public void run() { 061 frame = new JFrame(); 062 frame.setSize(300, 200); 063 menuBar = new JMenuBar(); 064 frame.setJMenuBar(menuBar); 065 buildMenuBar(menuBar); 066 frame.setVisible(true); 067 } 068 } 069 @SuppressWarnings("serial") 070 public class Body extends JPanel { 071 GridBagConstraints c = new GridBagConstraints(); 072 GridBagConstraints cEnd = new GridBagConstraints(); 073 GridBagLayout layout = new GridBagLayout(); 074 } 075 public void launch() { 076 System.out.println("Starting launch"); 077 try { 078 SwingUtilities.invokeLater(new MainPage()); 079 } catch (Exception e) { 080 e.printStackTrace(); 081 } 082 } 083 public static void main(String[] args) { 084 System.out.println("Starting program"); 085 MasterIndex instance = new MasterIndex(); 086 instance.launch(); 087 } 088}