Download our latest
Android and iPhone apps ...
At a glance ...
Pages
809
Exercises
21
Sections
37
Public
On-Site
Level
2
Days
5

Course Name: Java 1.7 Swing

Duration:
Minimum skill level required:
On-Site course:
Public course:
Sections:
No of exercises:
No of pages in the manual:
Pre-Requisite course(s):
Suggested further course(s):
Price guide:
5 days
2 (1 - Beginner, 2 - Experienced 3 - Advanced)
Yes
No
37
21
809
Java 1.7 Programming
None
Contact us for the latest pricing

Synopsis for course

The follow on course from our Java 1.7 Programming course, this course dives straight in to creating GUI modules in Java

This course is designed for delegates wishing to use Java AWT and Swing classes in a commercial setting, it builds up the knowledge of the delegate to the point where they are creating functionally rich input screens with complicated data integrity checks, pop up menus and Java toolbars.

All Swing classes are covered from the basic JFrames through to JTables and JApplets and everything in between.

Note: A good working knowledge of Java programming is a must for this course, so therefore delegates should have attended our Java 1.7 Programming training course or have had comprehensive period of time working with Java.

The course comes with a comprehensive manual, and over 80 working modules in addition to the solutions for every exercise.

This is a practical course based on commercial requirements.

Exercise highlights

Creating a JTaskBar
Using JTrees and JTables
Using GroupLayout, BorderLayout and GridLayout
Web enabling Applications
Error checking with JSwing

Course Contents

Section
Section Name
Page


One
Introduction to Java
2

 
- Usage of Java
3

 
- Structure of Java
4

 
- Flexibility of Java Programming
5

 
- Swing and AWT in Java
6

Two
Using Java in DOS
9

 
- Using the DOS window
10

 
- DOS Operating System Commands
11

 
- Compiling and Executing Java Programs in DOS
13

 
- Using JAVAC to Compile Java Programs
14

Three
Dialog Boxes
20

 
- Using Dialog Boxes
21

 
- Using Message Dialogs
23

 
- Using ImageIcons with Message Dialogs
28

 
- Using Confirm Dialogs
31

 
- Using Input Dialogs
36

 
- Using Input Dialogs with Icons and Lists
38

 
- Using Option Dialogs
40

 
- Making a Beep in Java
46

 
- Exercise One
47

Four
Dimensions
52

 
- The Dimension Datatype
53

 
- Examples of Using Dimensions
54

 
- Methods for Dimensions
55

 
- getScreenSize()
57

Five
JFrame
58

 
- Using JFrame
59

 
- setDefaultCloseOperation()
60

 
- setVisible()
61

 
- Exiting JFrames
62

 
- setResizable()
63

 
- setLocation()
64

 
- setBounds()
66

 
- Centering JFrames
67

 
- JFrame Example
68

 
- setLocationRelativeTo() for Centreing
69

 
- dispose()
70

 
- Using setIconImage()
71

 
- Using Constructors in Java Swing
72

 
- serialVersionUID
73

 
- Creating a Constructor Method
74

 
- JFrame Constructor
76

 
- @SuppressWarnings
77

 
- Exercise Two
81

Six
JComponent
83

 
- Introduction
84

 
- Methods to Change Appearance
85

 
- Methods to Process Components
89

Seven
Colour and Fonts
93

 
- Using Color
94

 
- Using Color with JFrame
96

 
- Using Font
97

Eight
JLabel
103

 
- Using JLabel
104

 
- getContentPane().add()
105

 
- Creating a message in JLabel
107

 
- Using HTML with JLabel
108

 
- Changing the position in a JLabel
111

 
- Adding an Icon to a JLabel
113

 
- Changing a JLabel's Colour and Font
115

 
- Icon only JLabel
117

 
- setVerticalAlignment()
118

 
- pack()
120

 
- Exercise Three
121

Nine
Borders
124

 
- BorderFactory
125

 
- createEmptyBorder()
128

 
- createLineBorder()
129

 
- createRaisedBevelBorder()
131

 
- createRaisedSoftBevelBorder()
132

 
- createBevelBorder()
133

 
- createDashedBorder()
135

 
- createStrokeBorder()
138

 
- createEtchedBorder()
142

 
- createMatteBorder()
144

 
- createTitledBorder()
146

 
- Nested createTitledBorder()
156

 
- Fonts with createTitledBorder()
157

 
- createCompoundBorder()
158

 
- Exercise Four
161

Ten
Mid-Level Containers
165

 
- Containers
166

 
- JPanels
168

 
- JScrollPanes
170

 
- Scroll Bar policy
173

 
- Exercise Five
175

Eleven
Absolute Layouts
177

 
- Introduction
178

 
- setBounds()
179

 
- Exercise Six
183

Twelve
Layouts
184

 
- JPanel and Layouts
185

 
- FlowLayout
187

 
- Some FlowLayout Methods
191

 
- GridLayout
193

 
- Some GridLayout Methods
198

 
- BorderLayout
199

 
- Defining BorderLayouts since Java 1.4
204

 
- Some BorderLayout Methods
206

 
- Exercise Seven
207

 
- BoxLayout
210

 
- SpringLayout
213

 
- putConstraint()
217

Thirteen
Box
221

 
- Introduction
222

 
- createRigidArea()
224

 
- createVerticalStrut()
225

 
- createHorizontalStrut()
226

 
- createGlue()
227

 
- createHorizontalGlue() / createVerticalGlue()
229

 
- Using Box.Filler
230

 
- Using Box as a Container
233

 
- Exercise Eight
235

Fourteen
JButton
237

 
- Introduction
238

 
- Example
239

 
- Using Insets to re-size JButtons
241

 
- Using Icons with JButtons
243

 
- Using AbstractButton with JButtons
244

 
- Using SwingConstants with JButtons
248

 
- Some Methods for JButtons
249

 
- Using HTML with JButton
252

 
- Advanced Icons with JButtons
253

 
- Using Rollover with JButtons
255

 
- JButtons and ToolTips
256

 
- BasicArrowButton
257

Fifteen
Event Handling with Listeners
259

 
- Listening for Events
260

Sixteen
Private Event Listeners for JButtons
265

 
- Introduction
266

 
- java.awt.event.*
267

 
- Example of Private Listener
268

 
- ActionEvent
270

 
- Recording the Event
271

 
- Which Component fired the Listener
272

 
- Using getActionCommand()
273

 
- getValueIsAdjusting()
274

 
- getWhen()
275

 
- Exercise Nine
276

Seventeen
Public Event Listeners
278

 
- Introduction
279

 
- Example of Public Listener
280

Eighteen
Implemented Event Listeners
282

 
- Introduction
283

 
- Example of Implemented Listener
284

Nineteen
Listener Events
286

 
- Introduction
287

 
- Multiple Events with Listeners
288

 
- Exercise Ten
289

Twenty
JTextComponent
291

 
- Methods in JTextComponent
292

Twenty One
Input Components
293

 
- Introduction
294

 
- JTextField
295

 
- JTextField Example
296

 
- JTextField Initialisation
298

 
- Other Methods for JTextField
299

 
- Processing JTextField using getText()
301

 
- Listeners for JTextField
302

 
- FocusListener with JTextField
303

 
- ActionListener with JTextField
305

 
- JPasswordField
308

 
- JPasswordField Example
309

 
- setEchoChar()
311

 
- JTextArea
312

 
- JTextArea Example
313

 
- JTextArea and setFocusable()
315

 
- Wrapping text in JTextArea
317

 
- Listeners with JTextArea
320

 
- Some methods for JTextArea
321

 
- JFormattedTextField
324

 
- Initialising JFormattedTextField
325

 
- Populating JFormattedTextField
328

 
- Using setValue()
330

 
- Listeners with JFormattedTextField
331

 
- Using MaskFormatter
332

 
- Using setFocusLostBehavior
334

 
- requestFocusInWindow()
336

 
- Exercise Eleven
337

Twenty Two
GroupLayout
339

 
- Introduction
340

 
- Sequential and Parallel Groups
341

 
- addGap()
344

 
- setAutoCreateGaps()
345

 
- Changing Direction of Components
346

 
- Chained Invocation or Method Chaining
347

 
- Adding further Groups with addGroup()
348

 
- Controlling Resizing with addComponent()
353

 
- Using LinkSize to standardise sizing
356

 
- Alignment
357

Twenty Three
Selection Components
358

 
- JComboBox
359

 
- Using addItem() with JComboBox
362

 
- getSelectedItem() with JComboBox
363

 
- ComboBoxModel with JComboBox
364

 
- Some methods for JComboBox
365

 
- ItemListener with JComboBox
367

 
- JCheckBox
368

 
- JCheckBox Example
369

 
- Initialising JCheckBox
370

 
- Using HTML with JCheckBox
371

 
- Images with JCheckBox
372

 
- ItemListener with JCheckBox
373

 
- JToggleButton
375

 
- Initialising JToggleButton
376

 
- Listeners with JToggleButtons
377

 
- JRadioButton
378

 
- JRadioButton Example
380

 
- Initialising JRadionButtons
382

 
- Icons with JRadioButtons
383

 
- ActionListener with JRadioButton
385

 
- Using setActionCommand()
386

 
- setActionCommand() Example
387

 
- Using Enumeration
389

 
- Using AbstractButton
392

 
- Exercise Twelve
393

 
- JList
398

 
- JList Example
399

 
- setLayoutOrientation() with JList
401

 
- setSelectionMode() with JList
403

 
- setPrototypeCellValue() with JList
405

 
- setFixedCellWidth with JList
406

 
- DefaultListModel with JList
407

 
- DefaultListModel Example
408

 
- Icons with DefaultListModels
410

 
- Using Vectors
412

 
- Methods for Vectors
413

 
- getSelectedIndices() in JList
418

 
- JList Listeners
419

 
- ListSelectionListener
420

 
- Using getSelectedValuesList()
421

 
- ListDataListener
422

 
- ListDataListener Example
423

 
- Exercise Thirteen
425

 
- JSpinner
428

 
- SpinnerNumberModel
429

 
- SpinnerNumberModel Example
430

 
- Methods for SpinnerNumberModel
431

 
- Change Orientation of JSpinner
432

 
- ChangeListener with JSpinner
433

 
- SpinnerListModel
434

 
- SpinnerListModel Example
435

 
- setPreferredSize()
436

 
- ArrayLists with SpinnerListModel
438

 
- SpinnerDateModel
439

 
- SpinnerDateModel Example
441

 
- DateEditor with SpinnerDateModel
443

 
- JSlider
448

 
- Initialising JSlider
449

 
- ChangeListener with JSlider
451

 
- Placing Numbers on the JSlider
452

 
- Placing ticking on the JSlider
453

 
- setMinorTickSpacing() with JSlider
454

 
- Customising the JSlider ticks
455

 
- Some more JSlider methods
456

 
- JSeparator
458

 
- JSeparator Example
459

 
- Using Box with JSeparator Example
461

 
- Exercise Fourteen
463

Twenty Four
JMenus and JPopupMenus
466

 
- Introduction
467

 
- JMenuBar
468

 
- JMenuBar Example
470

 
- JMenu
471

 
- JMenu Example
472

 
- JMenuBar and JTextField
473

 
- Mnemonic with JMenus
474

 
- MenuListener
475

 
- MenuListener Example
476

 
- JMenuItem
478

 
- JMenuItem Example
479

 
- JMenuItems with Images
480

 
- Mnemonic with JMenuItems
481

 
- Accelerator with JMenuItems
482

 
- Listeners with JMenuItems
484

 
- JMenuItem and MenuKeyListener
485

 
- Sub-Menus in JMenus
486

 
- JCheckBoxMenuItems in JMenus
487

 
- JCheckBoxMenuItems with Images
489

 
- JCheckBoxMenuItems with ItemListener
490

 
- JRadioButtonMenuItem in JMenus
491

 
- JRadioButtonMenuItem Example
492

 
- JRadioButtonMenuItem with JMenu Example
493

 
- JRadioButtonMenuItem with Images
494

 
- JRadioButtonMenuItem and Listeners
495

 
- Using getActionCommand() with JRadioButton
496

 
- Using Enumeration
497

 
- JPopupMenu
498

 
- JPopupMenu with MouseListener
499

 
- MouseListener Examples
500

 
- Event.isPopupTrigger()
502

 
- PopupMenuListener
503

 
- JToolBar
504

 
- JToolBar Example
506

 
- JToolBar and setFloatable()
508

 
- JToolBar and Listeners
509

 
- JToolBar and Icons
510

 
- JToolBar Orientation
511

 
- JToolBar with JTextFields
512

 
- addSeparator() with JToolBar
514

 
- Exercise Fifteen
515

Twenty Five
Applets
518

 
- Introduction to using Applets
519

 
- Embedding Java in HTML
520

 
- Using Appletviewer in DOS
521

 
- Using the applet tag in HTML
523

 
- Using showStatus() (Short status strings)
525

 
- Passing Parameters to the Applet
526

 
- Using getParameter() with JApplet
527

 
- Reading Parameters in the Applet
529

 
- Using the object tag in HTML
530

 
- Appletviewer Options
531

 
- Converting a basic Application to an Applet
532

 
- InvocationTargetException and Images
538

 
- Using URL with Images
539

 
- Dialog Boxes converted to JApplet
540

 
- JInternalFrames (with LAF) converted to JApplet
541

 
- JMenus converted to JApplet
542

 
- JTrees converted to JApplet
543

 
- JColorChooser converted to JApplet
544

 
- Choosing Applet or Application in Eclipse
545

 
- Using start(), stop(), paint(), init() and destroy()
549

 
- Accessing System Properties in Applets
552

 
- Exercise Sixteen
554

Twenty Six
Look and Feel (LAF)
557

 
- Using setLookandFeel()
558

 
- Standard LAF Styles
560

 
- javax.swing.plaf.metal.MetalLookAndFeel
562

 
- javax.swing.plaf.nimbus.NimbusLookAndFeel
563

 
- com.sun.java.swing.plaf.motif.MotifLookAndFeel
564

 
- com.sun.java.swing.plaf.windows.WindowsLookAndFeel
565

 
- com.sun.java.swing.plaf.windows.WindowsClassicLookandFeel
566

 
- Defaulting the LAF permanently in Java
567

 
- Using Third Party LAFs
568

 
- Installing the LAF in the Operating System
569

 
- Identifying the Look and Feel Class in the Jar file
570

 
- Using the third party LAF in Java
571

 
- Exercise Seventeen
572

Twenty Seven
GridBagLayouts
573

 
- Introduction
574

 
- GridBagConstraints
575

 
- GridBagConstraints Example
578

 
- gridx and gridy
583

 
- gridx and gridy example
584

 
- gridwidth and gridheight
587

 
- gridwidth and gridheight example
588

 
- GridBagConstraints.REMAINDER
591

 
- fill
592

 
- fill example
593

 
- anchor
594

 
- anchor examples
595

 
- insets
597

 
- insets example
598

 
- ipadx and ipady
599

 
- ipadx and ipady example
600

 
- weightx and weighty
601

 
- Final example
605

Twenty Eight
JTable
611

 
- Introduction
612

 
- JTable Example
613

 
- Default Settings
616

 
- setPreferredScrollableViewportSize()
617

 
- java.lang.ArrayIndexOutOfBoundsException
618

 
- Problems with the TableColumnModel
619

 
- Adding to a JPanel
620

 
- Using DefaultTableModel()
621

 
- Using addColumn()
622

 
- setAutoCreateColumnsFromModel()
624

 
- Changing the Width of Columns
625

 
- setResizable()
627

 
- Some Methods for JTable
628

 
- Moving Columns Programmatically
629

 
- Moving Rows Programmatically
630

 
- Setting the Selection Mode
631

 
- isCellEditable()
634

 
- Accessing Cells
636

 
- Determining the Current Cell
637

 
- ListSelectionListener
638

 
- ListSelectionListener Example
639

 
- TableModelListener
643

 
- TableModelListener Example
645

 
- Exercise Eighteen
648

Twenty Nine
Mouse Double Click
651

 
- Introduction
652

 
- Double Click Example
653

Thirty
JTree
655

 
- Introduction
656

 
- JTree Example
657

 
- Populating a JTree (Top to Bottom)
659

 
- Expand()
662

 
- Populating a JTree (Bottom to Top)
663

 
- Populating a JTree with more levels
664

 
- TreeExpansionListener
666

 
- getLastSelectedPathComponent()
667

 
- TreeSelectionListener
668

 
- Customising the JTree
669

Thirty One
CardLayouts
671

 
- Introduction
672

 
- CardLayout Example
673

 
- Exercise Nineteen
677

Thirty Two
More Containers
682

 
- Introduction
683

 
- JSplitPane
684

 
- setDividerLocation() with JSplitPane
688

 
- Using setResizeWeight with JSplitPane
689

 
- JSplitPanes within JSplitPanes
690

 
- JTabbedPane
692

 
- JTabbedPane Example
694

 
- Using addTab() with JTabbedPane
696

 
- Inserting Tabs into a JTabbedPane
699

 
- Removing Tabs in JTabbedPane
700

 
- Positioning the Tabs
701

 
- setTabLayoutPolicy for JTabbedPane
704

 
- setMnemonic() with Tabs
706

 
- Some Methods for JTabbedPane
707

 
- ChangeListener with JTabbedPane
711

Thirty Three
More Frames
713

 
- JInternalFrame
714

 
- Using LAF with JInternalFrame
716

 
- JInternalFrame Behaviour
717

 
- Some JInternalFrame Methods
720

 
- Adding Compnents to JInternalFrame
721

 
- setJMenuBar() for JInternalFrame
722

 
- InternalFrameListener
723

 
- isVisible() with JInternalFrame
725

 
- JLayeredPane
726

 
- JLayeredPane Example
730

 
- Layouts in JLayeredPane
732

 
- More methods for JLayeredPane
733

 
- JDesktopPane
736

 
- showInternalMessageDialog
737

 
- showInternalConfirmDialog
740

 
- Exercise Twenty
745

Thirty Four
JWindow
747

 
- Using JWindow
748

Thirty Five
Swing Timers and Progress Bars
750

 
- Introduction
751

 
- Methods for Swing Timers
754

 
- Timers and Coaleace
756

 
- JProgressBar
757

 
- JProgressBar Example
758

 
- JProgressBar Methods
760

 
- Displaying text in the JProgressBar
761

 
- JProgressBar Orientation
763

 
- JProgressBar and ChangeListener
764

 
- Using Threads to create a Splash screen
765

 
- Cursors
767

 
- Scope of Cursors
770

 
- Creating a Custom Cursor
771

Thirty Six
System Tray
772

 
- Introduction
773

 
- System Tray Example
775

Thirty Seven
Java Built-in Choosers
778

 
- JColorChooser
779

 
- ChangeListener
785

 
- setPreviewPanel()
788

 
- Using setColor()
789

 
- Using AbstractColorChooserPanel
790

 
- JFileChooser
792

 
- setFileSelectionMode()
797

 
- setControlButtonsAreShown()
799

 
- FileFilter
800

 
- setAcceptAllFileFilterUsed()
802

 
- addChoosableFileFilter
803

 
- Some Methods for JFileChooser
804

 
- ActionListener with JFileChooser
805

 
- Exercise Twenty One
808