14-Advanced-Swing

14-Advanced-Swing - 2006 Marty Hall Advanced Swing Custom...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
2 JSP, Servlet, Struts, JSF, Ajax, & Java 5 Training: http://courses.coreservlets.com J2EE Books from Sun Press: http://www.coreservlets.com © 2006 Marty Hall Advanced Swing Custom Data Models and Cell Renderers 3 J2EE Books from Sun Press: http://www.coreservlets.com © 2006 Marty Hall For live Java training, please see training courses at http://courses.coreservlets.com/. Servlets, JSP, Struts, JSF, AJAX, Java 5, etc. Taught by the author of Core Servlets and JSP , More Servlets and JSP , and this tutorial. Available at public venues, or customized versions can be held on-site at your organization.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 J2EE training: http://courses.coreservlets.com Agenda Building a simple static JList Adding and removing entries from a JList at runtime Making a custom data model Telling JList how to extract data from existing objects Making a custom cell renderer Telling JList what GUI component to use for each of the data cells 5 J2EE training: http://courses.coreservlets.com MVC Architecture Custom data models Changing the way the GUI control obtains the data. Instead of copying data from an existing object into a GUI control, simply tell the GUI control how to get at the existing data. Custom cell renderers Changing the way the GUI control displays data values. Instead of changing the data values, simply tell the GUI control how to build a Swing component that represents each data value. Main applicable components JList JTable JTree
Background image of page 2
6 J2EE training: http://courses.coreservlets.com JList with Fixed Set of Choices Build JList: pass strings to constructor The simplest way to use a JList is to supply an array of strings to the JList constructor. Cannot add or remove elements once the JList is created. String options = { "Option 1", . .. , "Option N"}; JList optionList = new JList(options); Set visible rows Call setVisibleRowCount and drop JList into JScrollPane optionList.setVisibleRowCount(4); JScrollPane optionPane = new JScrollPane(optionList); someContainer.add(optionPane); Handle events Attach ListSelectionListener and use valueChanged 7 J2EE training: http://courses.coreservlets.com Simple JList: Example Code public class JListSimpleExample extends JFrame { ...
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/16/2009 for the course CSCI 571 taught by Professor Papa during the Summer '07 term at USC.

Page1 / 11

14-Advanced-Swing - 2006 Marty Hall Advanced Swing Custom...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online