import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class ProductDatabase extends JFrame implements ActionListener
{
private JPanel textPanel;
private JPanel buttonPanel;
private JPanel aboutTextPanel;
private JButton searchButton;
private JButton editButton;
private JTextArea textArea;
private JTextArea aboutTextArea;
private JInternalFrame aboutFrame;
private JMenuBar menuBar;
private JMenu file;
private JMenu help;
private JMenuItem quit;
private JMenuItem about;
private JMenuItem helpMI;
private JDesktopPane desktop;
private Container c;
private static final int WIDTH = 400;
private static final int HEIGHT = 300;
private EditGUI editGUI;
private SearchGUI searchGUI;
/*
* Sets up the main screen GUI
*/
public ProductDatabase()
{
super("Product Database");
desktop = new JDesktopPane();
setTitle("Product Database");
setSize(WIDTH, HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
c = getContentPane();
c.setLayout(new FlowLayout());
c.add(textPanel);
c.add(buttonPanel);
c.add(aboutTextPanel);
editGUI = new EditGUI();
searchGUI = new SearchGUI();
textPanel = new JPanel();
textArea = new JTextArea("Floor Coverings International \n Virginia Beach");
textArea.setFont(new Font("serif", Font.BOLD, 12));
textPanel.add(textArea);
buttonPanel = new JPanel();
searchButton = new JButton("Search");
searchButton.setVerticalTextPosition(AbstractButton.SOUTH);
searchButton.setHorizontalTextPosition(AbstractButton.LEADING);
searchButton.setFont(new Font("serif", Font.PLAIN, 12));
searchButton.addActionListener(this);
buttonPanel.add(searchButton);
editButton = new JButton("Edit");
editButton.setVerticalTextPosition(AbstractButton.SOUTH);
editButton.setHorizontalTextPosition(AbstractButton.TRAILING);
editButton.setFont(new Font("serif", Font.PLAIN, 12));
editButton.addActionListener(this);
buttonPanel.add(editButton);
aboutTextPanel = new JPanel();
aboutTextArea = new JTextArea("Floor Coverings International \n Virginia Beach \n Created by: Ali Jacob");
aboutTextArea.setFont(new Font("serif",Font.PLAIN, 12));
aboutTextPanel.add(aboutTextArea);
file = new JMenu("File");
help = new JMenu("Help");
quit = new JMenuItem("Quit");
about = new JMenuItem("About");
helpMI = new JMenuItem("Help");
file.add(quit);
help.add(about);
help.addSeparator();
help.add(helpMI);
menuBar = new JMenuBar();
menuBar.add(file);
menuBar.add(help);
setJMenuBar(menuBar);
createJInternalFrames();
}
/*
* Creates the JInternalFrame for the GUI
*/
private void createJInternalFrames()
{
aboutFrame = new JInternalFrame();
aboutFrame = new JInternalFrame("About");
aboutFrame.setVisible(false);
aboutFrame.setResizable(true);
aboutFrame.setClosable(true);
aboutFrame.setMaximizable(true);
aboutFrame.setIconifiable(true);
aboutFrame.add(aboutTextPanel);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == searchButton)
{
searchGUI = new SearchGUI();
searchGUI.setVisible(true);
}
else if(e.getSource() == editButton)
{
editGUI = new EditGUI();
editGUI.setVisible(true);
}
else if(e.getSource() == quit)
{
System.exit(0);
}
else if(e.getSource() == about)
{
aboutFrame.setVisible(true);
}
}
/*
* Runs the GUI
*/
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
ProductDatabase pd = new ProductDatabase();
}
});
}
} |