Similar documents
Agenda. 1. Abstract Windowing Toolkit (AWT) 2. Event Handling 3. Swing 4. Layout Manager 5. Applet

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

Graphical User Interface (GUI) components in Java Applets. With Abstract Window Toolkit (AWT) we can build an applet that has the basic GUI

Top-Level Containers

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

The most striking feature of Java is Platform neutralness. Java is the first language that is not tied to any particular hardware or O.S.

/* Write a Program implementing GUI based Calculator using Swing */

Laborator 2 Aplicatii Java

INTRODUCTION TO (GUIS)

Using Several Components

Datenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1

H212 Introduction to Software Systems Honors

Attempt FOUR questions Marking Scheme Time: 120 mins

Graphic User Interfaces. - GUI concepts - Swing - AWT

Building Java Programs Bonus Slides

DM503 Programming B. Peter Schneider-Kamp.

SAZ4A/SAE4A/BPC41 PROGRAMMING IN JAVA Unit : I - V

Java Project P6 Event Handling

Packages: Putting Classes Together

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

JComponent. JPanel. JFrame. JFrame JDialog, JOptionPane. JPanel. JPanel

Swing Programming Example Number 2

) / Java ( )

Java Swing. Lists Trees Tables Styled Text Components Progress Indicators Component Organizers

CS211 GUI Dynamics. Announcements. Motivation/Overview. Example Revisted

Graphical User Interfaces

MODEL UPDATES MANIPULATES USER

Java Graphical User Interfaces

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

FirstSwingFrame.java Page 1 of 1

navlakhi.com / navlakhi.education / navlakhi.mobi / navlakhi.org 1

The Java Programming Language Basics. Identifiers, Keywords, and Types. Expressions and Flow Control. Object-Oriented Programming. Objects and Classes

Swing UI. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

Chapter 13 Lab Advanced GUI Applications

Graphical User Interface

MIT AITI Swing Event Model Lecture 17

11/6/15. Objec&ves. RouleQe. Assign 8: Understanding Code. Assign 8: Bug. Assignment 8 Ques&ons? PROGRAMMING PARADIGMS

2110: GUIS: Graphical User Interfaces

Points Missed on Page page 1 of 8

CSIS 10A Assignment 7 SOLUTIONS

China Jiliang University Java. Programming in Java. Java Swing Programming. Java Web Applications, Helmut Dispert

Laborator 3 Aplicatii Java

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

Introduction to the JAVA UI classes Advanced HCI IAT351

Graphical User Interface (GUI)

Swing from A to Z Some Simple Components. Preface

Dr. Hikmat A. M. AbdelJaber

Chapter #1. Program to demonstrate applet life cycle

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall (total 7 pages)

Graphical Interfaces

An array is a type of variable that is able to hold more than one piece of information under a single variable name.

CSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

III/IV B.Tech (Regular/Supplementary) DEGREE EXAMINATION. Electronics & Instrumentation Engineering Object Oriented Programming with JAVA

JAVA PROGRAM EXAMPLE WITH OUTPUT PDF

University of Cape Town ~ Department of Computer Science. Computer Science 1016S / 1011H ~ November Exam

1.1 GUI. JFrame. import java.awt.*; import javax.swing.*; public class XXX extends JFrame { public XXX() { // XXX. init() main() public static

AP CS Unit 11: Graphics and Events

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

RAIK 183H Examination 2 Solution. November 11, 2013

JAVA NOTES GRAPHICAL USER INTERFACES

CSCI 201L Midterm Written Fall % of course grade

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

Swing - JButton. Adding buttons to the main window

UTM CSC207: Midterm Examination October 28, 2011

1005ICT Object Oriented Programming Lecture Notes

CSCI 201L Midterm Written SOLUTION Fall % of course grade

Chapter 9 Designing Graphical User Interfaces (GUIs)

Swing from A to Z Using Focus in Swing, Part 2. Preface

DM503 Programming B. Peter Schneider-Kamp.

Graphical interfaces & event-driven programming

Chapter 4. Swing 18 marks

We are on the GUI fast track path

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

Part 3: Graphical User Interface (GUI) & Java Applets

RAIK 183H Examination 2 Solution. November 10, 2014

Gracefulness of TP-Tree with Five Levels Obtained by Java Programming

Graphical Interfaces

Window Interfaces Using Swing Objects

Graphical User Interfaces 2

COMP Assignment #10 (Due: Monday, March 11:30pm)

core 2 Basic Swing GUI Controls in Java 2

core programming Basic Swing GUI Controls in Java Marty Hall, Larry Brown

BM214E Object Oriented Programming Lecture 12

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

Išdėstymai. Lekt. dr. Pijus Kasparaitis m. m. pavasario semestras.

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

JLayeredPane. Depth Constants in JLayeredPane

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1.

// Class fully inheritance and Person immutable GUI nun and Gridbag Layout import java.awt.*; import java.awt.event.*; import javax.swing.

Basicsof. JavaGUI and SWING

1 GUI GUI GUI GUI GUI. GUI(Graphical User Interface) JDK java.awt. ? Component

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University

CS108, Stanford Handout #22. Thread 3 GUI

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

CSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT

Lab Assignment 13 (week 13)

RobotPlanning.java Page 1

Containers and Components

Graphical User Interfaces. Swing. Jose Jesus García Rueda

Transcription:

import javax.swing.*; public class Sample { JFrame f; Sample(){ f=new JFrame(); JButton b=new JButton("click"); b.setbounds(130,100,100, 40); f.add(b); f.setsize(400,500); f.setlayout(null); f.setvisible(true); public static void main(string[] args) { new Sample();

import javax.swing.*; public class Sample2 extends JFrame{ JFrame f; Sample2(){ JButton b=new JButton("click"); b.setbounds(130,100,100, 40); add(b); setsize(400,500); setlayout(null); setvisible(true); public static void main(string[] args) { new Sample2();

import javax.swing.*; public class RadioButton { JFrame f; RadioButton() { f=new JFrame(); JRadioButton r1=new JRadioButton("A) Male"); JRadioButton r2=new JRadioButton("B) FeMale"); r1.setbounds(50,100,70,30); r2.setbounds(50,150,70,30); ButtonGroup bg=new ButtonGroup(); bg.add(r1);bg.add(r2); f.add(r1);f.add(r2); f.setsize(300,300); f.setlayout(null); f.setvisible(true); public static void main(string[] args) { new RadioButton();

import java.awt.color; import javax.swing.*; public class TArea1 { JTextArea area; JFrame f; TArea1(){ f=new JFrame(); area=new JTextArea(300,300); area.setbounds(10,30,300,300); area.setbackground(color.black); area.setforeground(color.white); f.add(area); f.setsize(400,400); f.setlayout(null); f.setvisible(true); public static void main(string[] args) { new TArea1();

import javax.swing.*; public class MyTable { JFrame f; MyTable(){ f=new JFrame(); String data[][]={ {"101","Amit","670000", {"102","Jai","780000", {"101","Sachin","700000"; String column[]={"id","name","salary"; JTable jt=new JTable(data,column); jt.setbounds(30,40,200,300); JScrollPane sp=new JScrollPane(jt); f.add(sp); f.setsize(300,400); // f.setlayout(null); f.setvisible(true); public static void main(string[] args) { new MyTable();

JButton b1=new JButton("NORTH");; JButton b2=new JButton("SOUTH");; JButton b3=new JButton("EAST");; JButton b4=new JButton("WEST");; JButton b5=new JButton("CENTER");; f.add(b1,borderlayout.north); f.add(b2,borderlayout.south); f.add(b3,borderlayout.east); f.add(b4,borderlayout.west); f.add(b5,borderlayout.center); f.setsize(300,300); f.setvisible(true); //f.setdefaultcloseoperation(jframe.exit_on_close); public static void main(string[] args) { new Border(); import java.awt.*; import javax.swing.*; public class Border { JFrame f; Border(){ f=new JFrame();

import java.awt.*; import javax.swing.*; public class MyGridLayout{ JFrame f; MyGridLayout(){ f=new JFrame(); JButton b1=new JButton("1"); JButton b2=new JButton("2"); JButton b3=new JButton("3"); JButton b4=new JButton("4"); JButton b5=new JButton("5"); JButton b6=new JButton("6"); JButton b7=new JButton("7"); JButton b8=new JButton("8"); JButton b9=new JButton("9"); f.add(b1);f.add(b2);f.add(b3);f.add(b4);f.add(b5); f.add(b6);f.add(b7);f.add(b8);f.add(b9); f.setlayout(new GridLayout(3,3));//creating grid layout of 3 row and 3 columns f.setsize(300,300); f.setvisible(true); public static void main(string[] args) { new MyGridLayout();

import java.awt.*; import javax.swing.*; public class MyFlowLayout{ JFrame f; MyFlowLayout(){ f=new JFrame(); JButton b1=new JButton("1"); JButton b2=new JButton("2"); JButton b3=new JButton("3"); JButton b4=new JButton("4"); JButton b5=new JButton("5"); f.add(b1);f.add(b2);f.add(b3);f.add(b4);f.add(b5); f.setlayout(new FlowLayout(FlowLayout.LEFT)); //setting flow layout of right alignment f.setsize(300,300); f.setvisible(true); f.setdefaultcloseoperation(jframe.exit_on_close); public static void main(string[] args) { new MyFlowLayout();

import java.awt.*; import javax.swing.*; public class BoxLayoutExample1 extends Frame { Button buttons[]; public BoxLayoutExample1 () { buttons = new Button [5]; for (int i = 0;i<5;i++) { buttons[i] = new Button ("Button " + (i + 1)); add (buttons[i]); setlayout (new BoxLayout (this, BoxLayout.Y_AXIS)); setsize(400,400); setvisible(true); public static void main(string args[]){ BoxLayoutExample1 b=new BoxLayoutExample1();

import java.awt.*; import javax.swing.*; public class BoxLayoutExample2 extends Frame { Button buttons[]; public BoxLayoutExample2() { buttons = new Button [5]; for (int i = 0;i<5;i++) { buttons[i] = new Button ("Button " + (i + 1)); add (buttons[i]); setlayout (new BoxLayout(this, BoxLayout.X_AXIS)); setsize(400,400); setvisible(true); b.setdefaultcloseoperation(button.exit_on_close); public static void main(string args[]){ BoxLayoutExample2 b=new BoxLayoutExample2();

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CardLayoutExample extends JFrame implements ActionListener{ CardLayout card; JButton b1,b2,b3; Container c; CardLayoutExample(){ c=getcontentpane(); card=new CardLayout(40,30); //create CardLayout object with 40 hor space and 30 ver space c.setlayout(card); b1=new JButton("Apple"); b2=new JButton("Boy"); b3=new JButton("Cat"); b1.addactionlistener(this); b2.addactionlistener(this); b3.addactionlistener(this); c.add("a",b1);c.add("b",b2);c.add("c",b3);

public void actionperformed(actionevent e) { card.next(c); public static void main(string[] args) { CardLayoutExample cl=new CardLayoutExample(); cl.setsize(400,400); cl.setvisible(true); cl.setdefaultcloseoperation(exit_on_close);