Beans Binding Framework & Swing Application Framework Geertjan Wielenga http//netbeans.dzone.com.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

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.
Introduction to JFC Swing Written by Adam Carmi. Agenda About JFC and Swing Pluggable Look and Feel Swing Components Borders Layout Management Events.
Writing GUI Applications An introduction with Java.
Object-Oriented Software Engineering Java with added Swing.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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 Joon Ho Cho. What is Java Swing? Part of the Java Foundation Classes (JFC) Provides a rich set of GUI components Used to create a Java program.
Creating of Rich Client Applications using NetBeans 6 and Java Swing Miroslav Nachev.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Graphical User Interface (GUI) Design using Swing Course Lecture Slides.
Written by Liron Blecher
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
Introduction to Java GUI Creating Graphical User Interfaces © copyright Bobby Hoggard / material may not be redistributed without permission.
Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial.
Using the Netbeans GUI Builder. The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The Netbeans.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Saldin Samuel eBay India Product Center 29 th October 2010.
Java GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
עקרונות תכנות מונחה עצמים תרגול 4 - GUI. Outline  Introduction to GUI  Swing  Basic components  Event handling.
Java GUI Framework Developed for Tantivy EMS System (October 1999 to August 2000)
Java Applets. Topics What is an applet? To convert GUI applications to Applets Hello World applet example!! Applets life cycle examples Invoking applets.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
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.
CSC 205 – Java Programming II Applet. Types of Java Programs Applets Applications Console applications Graphics applications Applications are stand-alone.
FEN IntroJava2006 AAU1 GUI: Graphical User Interface AWT/SWING: Components Drag and Drop in NetBeans Events Listeners.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Synchronizing threads, thread pools, etc.
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.
Creating a GUI with JFC/Swing. What are the JFC and Swing? JFC –Java Foundation Classes –a group of features to help people build graphical user interfaces.
Creating Applets. What is an applet? What is an applet? A Java program that runs in a web browser. A Java program that runs in a web browser. An applet.
Swing part-two Eriq Muhammad Adams J
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
Basics of GUI Programming Chapter 11 and Chapter 22.
Java Swing One of the most important features of Java is its ability to draw graphics.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Creating Modular CRUD Desktop Applications Jiri Rechtacek Geertjan Wielenga.
By, [Blue Team] Bauyrzhan Aitileu Muneeb Mahmood Vinaykumar Bangera.
Event-Driven Programming F Procedural programming is executed in procedural order. F In event-driven programming, code is executed upon activation of events.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
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:
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7 ( Book Chapter 14) GUI and Event-Driven Programming.
Module 13: Swing API Object Oriented Programming(Java)
Using NetBeans IDE for Desktop Development Geertjan Wielenga
Slide 1. What's New in NetBeans IDE 7.1 Name Title.
Swing Application Framework and Beans Binding David Botterill
Porting a Swing Application to the NetBeans Platform Anton Epple
Presenter Name This presentation introduces Swing Application Framework and Beans Binding JSRs. These are two new JSRs which greatly.
A Quick Java Swing Tutorial
Lecture 15 Basic GUI programming
CSC 222: Object-Oriented Programming
Recap Modules: dependency management, revisioning, information hiding
Geertjan Wielenga
“Form Ever Follows Function” Louis Henri Sullivan
Lecture 27 Creating Custom GUIs
Geertjan Wielenga This presentation introduces Swing Application Framework and Beans Binding JSRs. These are two new JSRs.
A Quick Java Swing Tutorial
Productivity Tools Extensions to NetBeans IDE that make life easier
Technical Sessions Scripting/Groovy Simple App Framework Portlet Rest
Introduction to Graphical Interface Programming in Java
Programming in Java Text Books :
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Steps to Creating a GUI Interface
A Quick Java Swing Tutorial
Advanced Programming in Java
Constructors, GUI’s(Using Swing) and ActionListner
Java Tutorial – Application Building
Introducing Java.
Presentation transcript:

Beans Binding Framework & Swing Application Framework Geertjan Wielenga http//netbeans.dzone.com

2 Agenda ● Goals ● Beans Binding Framework ● Swing Application Framework ● Conclusion

3 ● Goals ● Beans Binding Framework ● Swing Application Framework ● Conclusion Agenda

4 Example

5

6

7

8 faceSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { face.setFaceStyle(faceSlider.getValue()); } }); face.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName() == “faceStyle”) { faceSlider.setValue(caricature.getFaceStyle()); } } });

9 bind(faceObject, eye, slider1, value); bind(faceObject, hair, slider2, value); bind(faceObject, face, slider3, value);

10

11 BindingGroup bindingGroup = new BindingGroup();

12 BindingGroup bindingGroup = new BindingGroup(); Binding binding1 = Bindings.createAutoBinding( AutoBinding.UpdateStrategy.READ_WRITE, field, ELProperty.create("${text}"), slider, BeanProperty.create("value"));

13 BindingGroup bindingGroup = new BindingGroup(); Binding binding1 = Bindings.createAutoBinding( AutoBinding.UpdateStrategy.READ_WRITE, field, ELProperty.create("${text}"), slider, BeanProperty.create("value")); bindingGroup.addBinding(binding1); bindingGroup.bind();

14 Demo JFrame in Plain Java Class

15 validators & converters

16 Sample in the IDE

17 Summary ● Different update strategies ● Read once, read only from source, keep source and target in sync ● Ability to do validation ● Ability to transform value ● String to Color, Date to String

18 Demo Beans Binding Framework with “Matisse” GUI Builder

19 Latest Developments ● Expression language is no longer mandatory ● Subclasses for complex cases ● JTable binding ● Column binding ● JComboBox binding ● JList binding

20 ● When will Beans Binding be in the JDK? ● Planned - Java Platform 7 ● I can't wait. Where can I get it? ● Version ● Released November 2, 2007 ● Available at ● Bundled in NetBeans 6.0 When and Where?

21 ● Goals ● Beans Binding Framework ● Swing Application Framework ● Conclusion Agenda

22 public static void main(String args[]) { // good luck! } Problem Statement

23 ● Goals: ● As small as possible ● Explain it all in an hour ● Work well for small/medium apps ● Nice consequence: toolable Framework Goals

24 ● Lifecycle support ● Resources ● Actions ● Tasks ● Session state Framework Features

25 ● Modular system ● Docking system ● File system ● Data model ● Help system ● Update mechanism Out of Scope

26 Framework Architecture

27 import javax.swing.JFrame; import javax.swing.JLabel; public class HelloWorldSwing { public static void main(String[] args) { JFrame frame = new JFrame("HelloWorldSwing"); final JLabel label = new JLabel("Hello World"); frame.getContentPane().add(label); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } Lifecycle Support (On your own)

28 import javax.swing.JLabel; import org.jdesktop.application.Application; import org.jdesktop.application.SingleFrameApplication; public class MyApp extends SingleFrameApplication protected void startup() { JLabel label = new JLabel("Hello World"); show(label); } public static void main(String[] args) { Application.launch(MyApp.class, args); } Lifecycle Support

29 Lifecycle Support Calls initialize(), startup(), ready() on EDT thread. Performs initializations that must happen before the GUI is created like setting look & feel. Creates the initial GUI and shows it. All applications will override this method. Any work that must wait until the GUI is visible and ready for input. Calls shutdown() if the exitListeners do not veto. Main frame's Windowlistener calls exit(). Take the GUI down and do final cleanup.

30 ● Defined with regular ResourceBundles ● ResourceManager class is used ● Three options: ● Manually load, use ResourceMap objects ● Automatically inject resources into UI components ● Automatically inject resources into object fields Resources

31 ● Instead of ActionListeners ● Asynchronous actions are easy annotation ● Possible simple = "changesPending") public void save() {... } public boolean getChangesPending() {... } Actions

32 // define sayHello Action – pops up message public void sayHello() { String s = textField.getText(); JOptionPane.showMessageDialog(s); } // use sayHello – set the action property Action sayHello = Application.getContext(). getActionMap(MyForm.class, this).get("sayHello"); textField.setAction(sayHello); button.setAction(sayHello); Actions

33 ● Inherit the SwingWorker API ● Support for monitoring ● Title, Start/Done, etc. ● return Tasks ● Easy to handle non-blocking actions Tasks

34 ● Easily save properties: ● Window size ● Application position ● Sizes of columns in jTable, etc. ● ApplicationContext.getSessionStorage() ● SessionStorage.save(RootComponent, filename) ● Default for SingleFrameApplication is windowname + “.session.xml” ● Uses XMLEncoder & XMLDecoder Session State

35 Demo Flickr Search Application

36 ● NetBeans Platform is for applications that need more: ● Window system ● File/Data systems ● Help system ● Update system ● Visual designer ● Explorer widgets ● etc.... JSR 296 vs. NB Platform

37 ● When will JSR-296 be in a JDK? ● Planned - Java Platform 7 ● I can't wait. Where can I get it? ● Version 1.0 packaged with NetBeans 6 ● Source available as a NetBeans project at When and Where?

38 Conclusion ● JSR 295 and 296 are making Swing development fun again ● Both are very well supported in NetBeans GUI builder (project Matisse) ● Desktop Java becoming interesting for “Delphi” and “VB” developers ● Desktop Java is well and alive!