• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Notepad in Java with various Menus and Submenus (AWT or Swings).

July 1, 2012 by ProjectsGeek Leave a Comment

Assignment No 06

AIM:


Design Notepad in Java with various Menus and Submenus.  (AWT or Swings)

 THEORY:

Java’s Abstract Windowing Toolkit generates events when user performs actions like mouse click, key press etc. When an event is fired, it is received by one or more listeners that act on that event. Components can handle events by themselves or can delegate it to the objects called listeners. An EventListener interface has a separate method for each distinct event type that event class represents.

Low-level Events:

·         ComponentListener

·         ContainerListener

·         FocusListener

·         KeyListener

·         MouseListener

·         MouseMotionListener

·         WindowListener

Semantic Events:

·         ActionListener

·         AdjustmentListener

·         ItemListener

·         TextListener

A place in which the various drawing needs to be done must be provided and this is called the container. The container is derived from java.awt.Container class. The elements of the user interface are called components. The components are derived from java.awt.Component class.

1) Button

The Button is similar to a push Button in any other GUIs.

Button b1= new Button (String label)

b1.addActionListener (this)

2) CheckBox

Checkboxes are user interface components that have dual state: checked and unchecked. Clicking on it can change the state of the checkbox.

Java supports two types of checkboxes: exclusive and non-exclusive.

Non-exclusive:      

Checkbox c = new Checkbox (String name, Boolean state)

Exclusive: 

Only one among the group of items can be selected at a time. These are called radio Buttons.

CheckboxGroup cg = new CheckboxGroup ();

Checkbox c= new Checkbox(“name”, Boolean state, cg);

c.addMoustListener (this);

3) Choice

The Choice class implements a pop-up menu that allows the user to select an item from that menu.

Choice abc=new Choice( );

abc.add( String name );

abc.addItemListener(this);

4) Label

This component can be used for displaying a single line of text in a container. The text can be changed by an application but the user cannot edit the text. Labels do not generates events.

Label l= new Label (String text);

5) List

The list component presents the user with a scrolling list of text items. Unlike Choice, which displays only the single-selected item, the list can be made to show any number of choices in the visible window. The list can be constructed to allow multiple selections.

List acts = new List( );

acts.add( String  item);

acts.setMultipleMode(boolean b);  // allows multiple  selection in list.

6) Scrollbar

Scrollbars are used to select a value between a specified minimum and maximum.

Scrollbar s= new Scrollbar( int orientation );

7) TextField

TextFields are UI components that accept text input from the user.

TextField tx = new TextField(int columns);

8) TextArea

Text areas behave like TextFields Except that they have more functionality to handle large amount of text.

TextArea ta= new TextArea(int rows, int columns );

The layout manager classes are a set of classes that implements the java.awt. LayoutManager interface and help to position the components in a container.

The Basic layout managers are:

1) FlowLayout:

The FlowLayout lays out components line wise from left to right. When the line of components is filled, Flow layout creates new line and continues laying out components on the next line.

setLayout (new FlowLayout (int align))

setLayout (new FlowLayout (int align, int vgap, int hgap))

2) GridLayout:

This class lays out components in away very similar to spreadsheet= in rows and in columns. The components in a grid are resized to fit their cells.

setLayout (new GridLayout (int rows, int col))

setLayout (new GridLayout (int rows, int col, int vgap, int hgap))

3) BorderLayout:

The placement of the components is specified as being, North, South, East and West. The border layout resizes the center component to fill the remaining space.

setLayout (new BorderLayout (int vgap, int hgap))

4) CardLayout:

The CardLayout allows only one of its components to be visible at a time. The CardLayout considers each of its components as a card. A CardLayout is controlled by a combo box.

setLayout (new CardLayout (int vgap, int hgap))

Insets are used to provide spacing around the container.

public Insets getInsets( )

{

return new Insets (10,05,15,25)

}

The Panel class is a non-abstract container. The panel can contain UI components and other containers. The default layout of the Panel is FlowLayout.

Panel p1= new Panel( )

p1.add( b1)

The frame window is a full-fledged window that can contains user interface components like Title bar, Menu bar, and Control elements. The default layout of the frame s border Layout.

Frame f= new frame (String title);

          setVisible(boolean)

setSize(int width, int height)

setLocation( int x, int y)

setTitle(String title)

When the user tries to close the frame window, a window Closing event is generated that should be handled for the following to be done:

The resources related to the frame should be disposed using dispose( );

Since the frame window is the main window of the application, when the user closes the frame, the application itself should be closed using exit method in the System class. The error value 0 indicates normal exit i.e. System.exit(0);

Menus:

Menubar mb =new Menubar( );

Menu m =new Menu (“File”);

MenuItem m1 = new MenuItem(“Open”);

MenuItem m2 = new MenuItem(“Close”);

CheckBoxMenuItem mc =new CheckBoxMenuItem(  )

m.add(m1);

m.addSeparator( );

m.add(mc);

m.add(m2);

mb.add(m);

myframe.setMenubar(mb);

Dialog is a pop-up window on which UI components can be laid out. Usually they are used to display messages and get specific information from the user. Unlike frames, a dialog has a parent window. The dialog is automatically closed when the parent window is closed. A dialog box can be modal. A modal dialog prevents user input to other windows in the application until the dialog is closed.

CONCLUSION

Java Editor is successfully implemented.

Other Projects to Try:

  1. Write an Applet that crease a Working Version of Fifteen Puzzle in Java
  2. Text Editor in Java Project
  3. Socket programming in Java
  4. To create a window application (WinDIR app/ Drive Tree app.) using different GUI components and Direct view architecture.
  5. Notepad Application in Java Project with Source Code

Filed Under: Software Development Tools Lab

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy