“Look and Feel” and Layouts Feb 11, 2000. Pluggable Look and Feel zYou can change the looking or “look and feel” of your Swing application easily into:

Slides:



Advertisements
Similar presentations
Event Handling Feb 14, Event Model Revisited zRecall that a component can fire an event. zEach type of event is defined as a distinct class. zAn.
Advertisements

Java GUI Libraries Swing Programming. Swing Components Swing is a collection of libraries that contains primitive widgets or controls used for designing.
© L.Lúcio, An example GUI in Java n Two graphic libraries in Java u AWT u Swing n Swing is more recent than AWT: u Built on top of AWT classes;
1 GUI Programming (Part III). Graphical User Interfaces (Part III) Overview  GUI Programming Issues.  GUI Programming in Java: Then and Now.  Overview.
1 Lecture 11Lecture 14 Graphical User Interfaces (GUI) with AWT and Swing Overview  GUI Programming Issues.  GUI Programming in Java: Then and Now. 
JFC and the Swing Package Feb 10, Java Foundation Class (JFC) zAWT (Abstract Window Toolkit) has been used since jdk1.0 Archaic and very poorly.
Creating a GUI with Swing. Introduction Very useful link: Swing – is a part of JFC (Java Foundation.
Feb 18, 2000 Intermediate Containers. Global, Local and Static zGlobal/local are terms for variables in a program written in procedural-based language.
Graphical User Interfaces
Contructing GUI’s in Java Implemented in the Swing API Imported into your programs by: import javax.swing.*; Most Swing programs also need the AWT packages.
Java Swing Chris North cs3724: HCI. AWT to Swing AWT: Abstract Windowing Toolkit import java.awt.* Swing: new with Java2 import javax.swing.* Extends.
Lesson 35: Review of the Java GUI. The JFrame, Container and JButton.
1 A Quick Java Swing Tutorial. 2 Introduction Swing – A set of GUI classes –Part of the Java's standard library –Much better than the previous library:
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Graphical User Interface (GUI) Design using Swing Course Lecture Slides.
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
Java Swing © Walter Milner 2005: Slide 1 Java Swing Walter Milner.
Introduction to GUI Java offers a great number of pre-defined classes to support the development of graphical user interfaces –These are broken down into.
OOP (Java): Layout/ OOP Objectives – –describe the basic layout managers for GUIs Semester 2, GUI Layout.
Graphical User Interfaces Java’s AWT and Swing APIs.
Lesson 27: Introduction to the Java GUI. // helloworldbutton.java import java.awt.*; import javax.swing.*; class HelloButton{ public static void main.
Layout Management Containers can arrange their components. Our container is a JPanel, and it can set the way it’s components will be laid out : mypanel.setLayout.
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
Lesson 36: The calculator – Java Applets. 1. Creating Your First Applet HelloWorldApp is an example of a Java application, a standalone program. Now you.
1 Java Swing - Components and Containment. 2 Components and Containers Components and Containers Components Components The building blocksThe building.
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
GUI Components and Design Here we add one more component to our programs, JButtons –JButtons can only be inserted into JPanels (or JApplets) –Clicking.
CS Lecture 01 Frames and Components and events Lynda Thomas
GUI Chapter 10 Graphics context and objects Creating a window based application JFrame, JTextField, JButton Containers and Controls Graphics commands Layout.
Lesson 34: Layering Images with Java GUI. The FlowLayout RECAP.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
GUIs for Video Games. The Plan ● Layout suggestions ● Observer/Observable ● Steps to writing Observer/Observables ● Sample Code ● Practice.
CompSci 100E 35.1 Graphical User Interfaces: GUIs  Components  Flat Layouts  Hierarchical Layouts  Designing a GUI  Coding a GUI.
CSCI Swing1 The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness –The Abstract.
Java Swing Reference: 1.Swing: A Beginner’s Guide by Herbt Schildt, TMH Edition.
Lesson 39: More wrapup on GUIs. 1.This presentation will focus on the decisions around software architecture and the decisions that will drive the code.
GUI Basics. What is GUI? A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs in more ways than.
Programming with Java’s Swing API February 4, 2003 CMPS Advanced Programming Graphical User Interfaces.
Java Applet. Introductions Applet is java program that can be embedded into HTML pages Java applets runs on the java enables web browsers such as mozila.
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
Object-Oriented Software Engineering
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
CS 4244: Internet Programming User Interface Programming in Java 1.0.
Ch13 Creating windows and applets. Short overview AWT (Abstract Windowing Toolkit) Early Java development used graphic classesEarly Java development used.
1 cs205: engineering software university of virginia fall 2006 GUI Design and Implementation Schedule design meetings this week.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Review_6 AWT, Swing, ActionListener, and Graphics.
1 Chapter 16: Creating Windows. 2 Basics of GUI Programming How to create a Window. TryWindow.java You always need a JFrame component before creating.
Ch15 簡單計算機 物件導向系統實務. Ch22_Main.java import javax.swing.*; import java.awt.*; import java.awt.event.*; class Ch22_Main { public static void main(String.
Java Swing One of the most important features of Java is its ability to draw graphics.
1CS480: Graphical User Interfaces. Dario Salvucci, Drexel University. Lecture 3: Layout Basics.
Graphical User Interface (GUI)
Lesson 33: Layout management and drawing – Java GUI.
1 A Quick Java Swing Tutorial. 2 Introduction Swing – A set of GUI classes –Part of the Java's standard library –Much better than the previous library:
Import javax.swing.*; class Check { public static void main(String[] args) { JFrame frame = new JFrame("Check"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//DO_NOTHING_ON_CLOSE.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7 ( Book Chapter 14) GUI and Event-Driven Programming.
Java Swing. Note - this presentation.. often needs to refer to source code which is too big to put on a slide So the source code is in a separate Word.
A Quick Java Swing Tutorial
Graphical User Interfaces
Abstract Window Toolkit (AWT): native GUI components
Graphical User Interfaces
Swing JComponents.
Graphical user interface with Swing by jose maria gonzalez pinto
A Quick Java Swing Tutorial
Introduction to Graphical Interface Programming in Java
class PrintOnetoTen { public static void main(String args[]) {
Steps to Creating a GUI Interface
The calculator – Java GUI
A Quick Java Swing Tutorial
CiS 260: App Dev I Chapter 6: GUI and OOD.
Presentation transcript:

“Look and Feel” and Layouts Feb 11, 2000

Pluggable Look and Feel zYou can change the looking or “look and feel” of your Swing application easily into: yWindows yMacintosh yMotif (X-windows) yJava look zBig win for software portability in a sense that we can have a program which looks the same across platforms. zIf you don’t care about how your program looks, Don’t bother!!!

public static void main(String[] args) { try { UIManager.setLookAndFeel( // Put your favorite Look and Feel here!!! ); } catch (Exception e) { } new SwingApplication(); } "javax.swing.plaf.metal.MetalLookAndFeel" "com.sun.java.swing.plaf.windows.WindowsLookAndFeel” "com.sun.java.swing.plaf.motif.MotifLookAndFeel" "javax.swing.plaf.mac.MacLookAndFeel" Setting Look and Feel

Layouts

import java.awt.*; import java.awt.event.*; import javax.swing.*; class LayoutDemo { JFrame frame; Container pane; LayoutDemo(){ frame = new JFrame("LayoutDemo"); pane = frame.getContentPane(); } private void setupGUI(int w,int l) { addComponent(); frame.setSize(w,l); frame.setVisible(true); frame.pack(); } private void addComponent() { // next page } public static void main(String args[]) { int w = Integer.parseInt(args[0]); int l = Integer.parseInt(args[1]); LayoutDemo demo = new LayoutDemo(); demo.setupGUI(w,l); }

private void addComponent(){ pane.setLayout(new BorderLayout()); JCheckBox jck1 = new JCheckBox("this class is easy"); JCheckBox jck2 = new JCheckBox("this class is hard"); pane.add(jck1,"East"); pane.add(jck2,"South"); JButton b1 = new JButton("no touch"); JButton b2 = new JButton("please touch"); pane.add(b1,"North"); pane.add(b2,"West"); JLabel label = new JLabel(new ImageIcon("cab.gif")); pane.add(label,"Center"); }

private void addComponent(){ pane.setLayout(new GridLayout(2,3)); JCheckBox jck1 = new JCheckBox("this class is easy"); JCheckBox jck2 = new JCheckBox("this class is hard"); pane.add(jck1); pane.add(jck2); JButton b1 = new JButton("no touch"); JButton b2 = new JButton("please touch"); pane.add(b1); pane.add(b2); JLabel label = new JLabel(new ImageIcon("cab.gif")); pane.add(label); }

private void addComponent(){ pane.setLayout(new FlowLayout()); JCheckBox jck1 = new JCheckBox("this class is easy"); JCheckBox jck2 = new JCheckBox("this class is hard"); pane.add(jck1); pane.add(jck2); JButton b1 = new JButton("no touch"); JButton b2 = new JButton("please touch"); pane.add(b1); pane.add(b2); JLabel label = new JLabel(new ImageIcon("cab.gif")); pane.add(label); }

private void addComponent(){ pane.setLayout(new BoxLayout(pane,BoxLayout.Y_AXIS));... } private void addComponent(){ pane.setLayout(new BoxLayout(pane,BoxLayout.X_AXIS));... }

private void addComponent() { JPanel p1 = new JPanel(); p1.setLayout( new BoxLayout(p1,BoxLayout.Y_AXIS)); JCheckBox jck1 = new JCheckBox("this class is easy"); JCheckBox jck2 = new JCheckBox("this class is hard"); p1.add(jck1); p1.add(jck2); JPanel p2 = new JPanel(); p2.setLayout( new BoxLayout(p2,BoxLayout.Y_AXIS)); JButton b1 = new JButton("no touch"); JButton b2 = new JButton("please touch"); p2.add(b1); p2.add(b2); JLabel label = new JLabel( new ImageIcon("cab.gif")); pane.add(label,"Center"); pane.add(p1,"West"); pane.add(p2,"East"); }