import java.awt.*;
import javax.swing.JPanel;
import java.awt.event.*;
//import java.Color;
public class Project_notepad implements MouseListener,MouseMotionListener
{
public Frame f; //basic frame
public MenuBar mb; //menubar declaration
private Menu File, Edit, Format,View, Findit;
private MenuItem new_file,new_window,open,save,save_as, close, cut, copy, paste, case_convert, indent,font,style,size,underline,italic,bold,finds, incremental_find,replace;
private CheckboxMenuItem status_bar,word_wrap,hide_menu_bar,full_screen;
Label l1_menushow=new Label("show menu",Label.RIGHT); //create label for menu show/hide
Panel p1_menushow=new Panel(); //create panel for top part to use with label
public Project_notepad()
{
f=new Frame();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); //Dimension class object for setting max screen size
f.setBounds(0,0,screenSize.width, screenSize.height);
p1_menushow.setLayout(new BorderLayout());
l1_menushow.setSize(5,5);
p1_menushow.add(l1_menushow,BorderLayout.NORTH); //add label to top panel
//l1_menushow.setVisible(false);
f.addMouseListener(this);
f.addMouseMotionListener(this);
f.add(p1_menushow);
f.setVisible(true);
}
public void mouseEntered(MouseEvent e)
{
Object o=e.getSource();
if(o==l1_menushow)
{
create_menu();
}
}
public void mouseExited(MouseEvent e)
{
Object o=e.getSource();
if(o==l1_menushow)
{
//f.removeMenuBar();
}
}
public void mouseClicked(MouseEvent e)
{
Object o=e.getSource();
if(o==l1_menushow)
{
create_menu();
}
}
public void mousePressed(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
public void mouseMoved(MouseEvent e)
{
}
public void mouseDragged(MouseEvent e)
{
}
private void create_menu()
{ //menu bar creation
mb=new MenuBar(); //menu bar declaration
File=new Menu("File");
Edit=new Menu("Edit");
Format=new Menu("Format");
View=new Menu("View");
Findit=new Menu("Find");
new_file=new MenuItem("new file"); //menu items declaration
new_window=new MenuItem("new window");
open=new MenuItem("open");
save=new MenuItem("save");
save_as=new MenuItem("save as");
close=new MenuItem("close");
cut=new MenuItem("cut");
copy=new MenuItem("copy");
paste=new MenuItem("paste");
case_convert=new MenuItem("case convert");
indent=new MenuItem("indent");
font=new MenuItem("font");
style=new MenuItem("style");
size=new MenuItem("size");
underline=new MenuItem("underline");
italic=new MenuItem("italic");
bold=new MenuItem("bold");
incremental_find=new MenuItem("incremental_find");
replace=new MenuItem("replace");
finds = new MenuItem("finds");
status_bar=new CheckboxMenuItem("status bar"); //chechkbox items declaration
word_wrap=new CheckboxMenuItem("word wrap");
hide_menu_bar=new CheckboxMenuItem("hide menu bar");
full_screen=new CheckboxMenuItem("full screen");
File.add(new_file); //adding items to menu bar
File.add(new_window);
File.add(open);
File.add(save);
File.add(save_as);
File.add(close);
Edit.add(copy);
Edit.add(paste);
Edit.add(case_convert);
Edit.add(indent);
Format.add(font);
Format.add(style);
Format.add(size);
Format.add(underline);
Format.add(italic);
Format.add(bold);
Findit.add(finds);
Findit.add(incremental_find);
Findit.add(replace);
View.add(status_bar);
View.add(word_wrap);
View.add(hide_menu_bar);
View.add(full_screen);
mb.add(File);
mb.add(Edit);
mb.add(Format);
mb.add(View);
mb.add(Findit);
f.setMenuBar(mb);
}
public static void main(String args[])
{
Project_notepad pr=new Project_notepad();
}
}