Geniuses/src/project3/Project3.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package project3;
import java.awt.BorderLayout;
import java.awt.*;
import java.awt.event.*;
import java.awt.GridLayout;
import javax.swing.*;
import java.net.URL;
import javax.swing.ImageIcon;
/**
*
* @author Lucielsa
*/
public class Project3 extends JFrame {
private JButton btSearch = new JButton ("Search");
private JButton btAddFile = new JButton ("Add File");
private JButton btClear = new JButton ("Clear");
private JButton btAboutUs = new JButton ("About Us");
private JButton btRemoveFile = new JButton ("Remove File");
private JRadioButton all = new JRadioButton ("All of the Search Tems");
private JRadioButton any = new JRadioButton ("Any of the Search Tems");
private JRadioButton exact = new JRadioButton ("Exact Phrase");
private JMenuBar menuBar;
private JMenu menuMaintenance;
private JMenu menuAboutUs;
private JMenu menuHelp;
private JMenuItem addRemove;
public Project3 (){
menuBar = new JMenuBar();
setJMenuBar( menuBar );
menuMaintenance = new JMenu( "Maintenance" );
menuMaintenance.setMnemonic( 'M' );
menuMaintenance.setBackground(Color.BLACK);
menuMaintenance.setForeground(Color.BLUE);
menuBar.add( menuMaintenance );
menuAboutUs = new JMenu( "About Us" );
menuAboutUs.setMnemonic( 'A' );
menuAboutUs.setBackground(Color.BLACK);
menuAboutUs.setForeground(Color.BLUE);
menuBar.add( menuAboutUs );
menuHelp = new JMenu( "Help" );
menuHelp.setMnemonic( 'H' );
menuHelp.setBackground(Color.BLACK);
menuHelp.setForeground(Color.BLUE);
menuBar.add( menuHelp );
addRemove = new JMenuItem("Add/Remove File");
addRemove.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.ALT_MASK) );
addRemove.setMnemonic('F');
menuMaintenance.add(addRemove);
JLabel title1 = new JLabel ();
title1.setIcon(new javax.swing.ImageIcon(getClass().getResource("Geniuses.jpg")));
Toolkit tk = Toolkit.getDefaultToolkit();
Image icon = tk.getImage( "Search.jpg" );
setIconImage( icon );
JTextField textSearch = new JTextField
(" ");
textSearch.setHorizontalAlignment(JTextField.RIGHT);
all.setForeground(Color.BLUE);
all.setMnemonic('A');
any.setForeground(Color.BLUE);
any.setMnemonic('y');
exact.setForeground(Color.BLUE);
exact.setMnemonic('E');
ButtonGroup group = new ButtonGroup();
group.add (all);
group.add (any);
group.add (exact);
JPanel p1 = new JPanel(); p1.setBackground(Color.WHITE);
JPanel p2 = new JPanel(); p2.setBackground(Color.WHITE);
JPanel p3 = new JPanel(); p3.setBackground(Color.WHITE);
//setLayout(new GridLayout(2,1, 5, 5));
p1.add(title1);
p2.add(new JLabel (" "));
p2.add(textSearch);
p2.add(btSearch);
p2.add(btClear);
p2.add(new JLabel (" "));
p2.add(all);
p2.add(any);
p2.add(exact);
p3.add(new JLabel ("Copyright © 2013, Geniuses and/or its affiliates. All rights reserved."));
add(p1, BorderLayout.NORTH);
add(p2, BorderLayout.CENTER);
add(p3, BorderLayout.SOUTH);
addRemove.addActionListener(new MenuListeneraddRemove());
}
private class MenuListeneraddRemove implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JFrame addRemoveFrame = new Maintenance();
addRemoveFrame.setTitle("Maintenance");
addRemoveFrame.setSize(500, 500);
addRemoveFrame.setLocationRelativeTo (getRootPane());
addRemoveFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
addRemoveFrame.setVisible(true);
}
}
public static void main (String[] args){
JFrame frame = new Project3 ();
frame.getContentPane().setBackground(Color.WHITE);
frame.setTitle("Geniuses Search");
frame.setSize(600, 600);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}