Import javax.swing.*; public class FrameTest { public static void main(String args[]) { JFrame f = new JFrame("Frame Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLO.

Slides:



Advertisements
Similar presentations
Chapter 14 Advanced GUI ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display.
Advertisements

Components and Containers
Layouts and Graphics. component - container - layout Un Container contiene [0 o +] Components Il Layout specifica come i Components sono disposti nel.
1 Event Listeners Some Events and Their Associated Event Listeners Act that Results in the EventListener Type User clicks a button, presses Enter while.
Chapter 16 GUI Programming Basics GUI Overview Event-Driven Programming Basics GUI Classes and Packages A Simple Window Program JFrame Class Java Components.
User Interfaces II GUI – Awt, Swing, Web
1 G54PRG Programming Lecture 1 Amadeo Ascó Adam Moore 22 GUI Programming I.
Introduction to Swing Components Chapter 14. Part of the Java Foundation Classes (JFC) Provides a rich set of GUI components Used to create a Java program.
Chapter 15 Graphics. To paint, you need to specify where to paint. Each component has its own coordinate system with the origin (0, 0) at the upper-left.
1 Graphical User Interfaces AWT and Swing packages Frames and Panels Components Nested Panels Images Reading for this Lecture: L&L, 3.9 – 3.11.
GridLayout, n*m grid. Column width/row height adjusted to fith the widest/highest Component.
2I1073 Lektion 2 KTH-MI Peter Mozelius Servlets, säkerhet, och filhantering.
ITK:P1 Lektion 6 Den abstrakta datatypen kö DSV Peter Mozelius.
Graphical User Interfaces
ตัวอย่างการพัฒนา ระบบงาน. 2 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SignInWindow extends JFrame { JPanel panel;
ตัวอย่างแอพพลิเคชัน ประยุกต์ใช้งาน GUI. import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class CarToonRental.
Computer Science 209 Images and GUIs. Working with Java Colors The class java.awt.Color includes constants, such as Color.red, for some commonly used.
Web Design & Development Lecture 19. Java Graphics 2.
Frame Windows A frame object is used to create a graphical frame window. This frame is used to show information in a graphical application. The JFrame.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 21.
Advance Java Technology Java’s Role::MVC Architecture :: Swing Prof.Chintan Dave.
Graphics and event-driven programs Learning objectives By the end of this lecture you should be able to: identify and use some of the common components.
Page w16.1 – Spring 2010Steffen Vissing Andersen SDJ I1 subjects, Spring 2010 Agenda – Week 16, 2010 GUI.
1 MSPEL Lektion 3 DSV Peter Mozelius Grafik och spel i Java applets.
Chapter 11 Creating User Interfaces F What is JavaBean? F JComponent F JButton  ImageIcon  JLabel  JTextField  JTextArea  JComboBox  JList  JCheckBox.
Basic Java – Interface design. Understand: How to use TextPad for Java How to define classes and objects How to create a GUI interface How event-driven.
Graphical User Interfaces (Part IV)
Java Software Development Paradigm Lecture # 12. Basics of GUI.
Examples. // A simple Frame with Rectangle Inside import java.awt.*; import javax.swing.*; import java.awt.geom.*; // For Shapes class rectComponent extends.
More on GUI We wrap up our examination of Java GUI programming by looking at several other components and their listeners – The components all come from.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Graphics Chapter 16.  If you want to draw shapes such as a bar chart, a clock, or a stop sign, how do you do it?
CS18000: Problem Solving and Object-Oriented Programming.
Graphics CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
F27SB2 Programming Languages
Problem Solving 6 GUIs and Event Handling ICS-201 Introduction to Computing II Semester 071.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Multithreading : animation. slide 5.2 Animation Animation shows different objects moving or changing as time progresses. Thread programming is useful.
Chapter 5 Programming Graphics. Chapter Goals To be able to write applications with simple graphical user interfaces To display graphical shapes such.
Graphical User Interface Bonus slides Interaction Between Components & Drawing.
Swing: the art of the GUI COMP204, Bernhard Pfahringer.
JAVA 程式語言入門 (II).  版面配置  事件驅動  Ch14_01.java 1. import javax.swing.*; 2. import java.awt.*; 3. class Ch14_01 4. { 5. public static void main(String.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
Things to mention public static void main(String [] args) –The starting point for a free-standing Java application (i.e. one not run from the DrJava interactions.
Introduction to Java Classes, events, GUI’s. Understand: How to use TextPad How to define a class or object How to create a GUI interface How event-driven.
 What are the basic GUI components we’ve learned so far? › JFrame › JPanel › JButton › JLabel › JTextArea › JTextField › JCheckBox › JRadioButton › Paint.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
Lecture 16: GUI programming JFrame windows (p.247) Containers and layout managers (p.290) Inheriting GUI components (p.330) Chapter 12: GUI programming.
Swing Components III Chapter 12 - Student JFrame, Component Methods.
Graphic User Interfaces Part 1. Typical GUI Screen from Microsoft Word What GUI “components” can you see? –Menus? Buttons? Labels? What else? –Anything.
OOP (Java): GUI I/ OOP Objectives – –describe some of the GUI controls and their listeners; more appear in part 13 Semester 2,
GUI in Java. Graphical User Interface Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides users with basic level of.
SWING. AbstractButton Swing Buttons are subclasses of the AbstractButton class, which extends JComponent. Abstract class javax.swing.AbstractButton AbstractButton.
Chapter 12Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Announcements/Reminders l Next week: »No Lectures »No Labs »Recitation.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Swing Components. Introduction Swing – A set of GUI classes – Part of the Java's standard library –Much better than the previous library: AWT Abstract.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
The Swing GUI Components Chapter 29 An enhanced alternative to AWT The PC does not need an appletviewer or browser Swing overcomes some AWT drawbacks.
Visual Index of Swing GUI Components
Basics of GUI Programming Chapter 11 and Chapter 22.
Software Construction LAB 08 Java Programming with SWING GUI Builder.
GUI Components CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 15 : Swing III King Fahd University of Petroleum & Minerals College of Computer.
Java Swing. Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: – Events:
Chapter 6 Building Java GUIs. MVC Model View Controller The model passes its data to the view for rendering The view determines which events are passed.
Advanced User Interfaces
Java Swing.
Introduction to Graphical Interface Programming in Java
Presentation transcript:

import javax.swing.*; public class FrameTest { public static void main(String args[]) { JFrame f = new JFrame("Frame Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE); f.setSize(200, 150); f.setVisible(true); } FrameTest

import javax.swing.*; public class ButtonTest { public static void main(String args[]) { JFrame f = new JFrame("*** Button Test***"); JPanel p = new JPanel(); Icon ani = new ImageIcon("Course.gif"); JButton a = new JButton("printf ",ani); JButton b = new JButton("Close ",ani); p.add(a); p.add(b); f.add(p); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(500, 150); f.setVisible(true); } ButtonTest

import java.awt.*; import javax.swing.*; public class MenuTest { public static void main(String args[]) { Font fn = new Font("Courier New",Font.BOLD,16); JFrame f; JMenuBar menubar; JMenu menuFile, menuNew, menuAbout; JMenuItem menuN1, menuN2,menuOpen, menuExit; f = new JFrame("Menu Test"); menubar = new JMenuBar(); menuFile = new JMenu("File"); menuAbout = new JMenu("About"); menuNew = new JMenu("New"); menuN1 = new JMenuItem("Java"); menuN2 = new JMenuItem("C/C++"); menuNew.add(menuN1); menuNew.addSeparator(); menuNew.add(menuN2); menuOpen = new JMenuItem("Open"); menuExit = new JMenuItem("Exit"); MenuTest

menuFile.setFont(fn); menuNew.setFont(fn); menuN1.setFont(fn); menuN2.setFont(fn); menuOpen.setFont(fn); menuExit.setFont(fn); menuAbout.setFont(fn); menuFile.add(menuNew); menuFile.addSeparator(); menuFile.add(menuOpen); menuFile.add(menuExit); menubar.add(menuFile); menubar.add(menuAbout); f.setJMenuBar(menubar); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(250, 200); f.setVisible(true); }

import java.awt.*; import javax.swing.*; public class Radio_List_Test { public static void main(String args[]) { JFrame f; JPanel p; ButtonGroup bg; JRadioButton n1,n2; JList AList; String AniList[] = {"CAT", "RAT", "DOG", "PIG", "DUCK", "EGG", "MILK"}; Font fn = new Font("Courier New",Font.BOLD,16); f = new JFrame("Select Component Test"); p = new JPanel(); n1 = new JRadioButton("MALE",true); n2 = new JRadioButton("FEMALE"); n1.setFont(fn); n2.setFont(fn); bg = new ButtonGroup(); AList = new JList(AniList); AList.setFont(fn); AList.setPreferredSize(new Dimension(135,140)); AList.setVisibleRowCount(5); Radio_List_Test

AList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); JScrollPane x = new JScrollPane(AList); bg.add(n1); bg.add(n2); p.add(n1); p.add(n2); p.add(x); f.add(p); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(230, 200); f.setVisible(true); }

import java.awt.*; import javax.swing.*; public class PanelTest { public static void main(String args[]) { JFrame f = new JFrame("Panel Test"); JPanel p = new JPanel(); p.setBackground(Color.CYAN); f.add(p); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(200, 150); f.setVisible(true); } PanelTest