0% found this document useful (0 votes)
10 views1 page

Java Swing GUI with JMenu Example

This document describes creating a GUI application window in Java using Swing and AWT packages. It creates a JFrame containing a JMenuBar with menu options, a JPanel at the bottom with a label, text field, and buttons, and a JTextArea in the center. The frame is configured to close on exit and has its size set before making it visible.

Uploaded by

Ilirian Rexho
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Java Swing GUI with JMenu Example

This document describes creating a GUI application window in Java using Swing and AWT packages. It creates a JFrame containing a JMenuBar with menu options, a JPanel at the bottom with a label, text field, and buttons, and a JTextArea in the center. The frame is configured to close on exit and has its size set before making it visible.

Uploaded by

Ilirian Rexho
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

// Dritarja e nje aplikacioni me JOption

// duke perdorur paketat swing dhe awt


import [Link].*;
import [Link].*;
public class gui {
public static void main(String args[]) {

// Krijimi i Frame-s
JFrame frame = new JFrame("Aplikacioni 01");
[Link](JFrame.EXIT_ON_CLOSE);
[Link](500, 400);

// Krijimi i shiritit me menute e ndryshme


JMenuBar mb = new JMenuBar();
JMenu m1 = new JMenu("File");
JMenu m2 = new JMenu("Edit");
JMenu m3 = new JMenu("Format");
JMenu m4 = new JMenu("Help");
[Link](m1);
[Link](m2);
[Link](m3);
[Link](m4);
JMenuItem m111 = new JMenuItem("Krijo");
JMenuItem m222 = new JMenuItem("Hap");
JMenuItem m333 = new JMenuItem("Ruaj");
JMenuItem m444 = new JMenuItem("Printo");
JMenuItem m555 = new JMenuItem("Mbyll");
[Link](m111);
[Link](m222);
[Link](m333);
[Link](m444);
[Link](m555);

// Krijimi i panelit ne fund te dritares me komponentet e saj


JPanel panel = new JPanel(); // the panel is not visible in output
JLabel label = new JLabel("Futni tekst");
JTextField tf = new JTextField(15); // accepts upto 10 characters
JButton send = new JButton("Dergo");
JButton reset = new JButton("Zero");
[Link](label); // Components Added using Flow Layout
[Link](label); // Components Added using Flow Layout
[Link](tf);
[Link](send);
[Link](reset);

// Text Area at the Center


JTextArea ta = new JTextArea();

//Adding Components to the frame.


[Link]().add([Link], panel);
[Link]().add([Link], mb);
[Link]().add([Link], ta);
[Link](true);
}
}

You might also like