Reviews : Java Books :
Learning Java : Chapter 14: Using Swing Components

Title: Learning Java
ISBN: 1565927184
Order No 7184
US Price: $ 34.95
Publication Date: May 2000
Pages: 722
© O'Reilly & Associates, Inc.
Author's Top Ten Tips and Tricks

Learning Java
Chapter 14: Using Swing Components

The following application includes all the examples we've covered:

import javax.swing.*;

public class ExerciseOptions {
  public static void main(String[] args) {
    JFrame f = new JFrame("ExerciseOptions v1.0");
    f.setSize(200, 200);
    f.setLocation(200, 200);
    f.setVisible(true);
    JOptionPane.showMessageDialog(f, "You have mail.");
    JOptionPane.showMessageDialog(f,
	 "You are low on memory.",
        "Apocalyptic message",
		JOptionPane.WARNING_MESSAGE);
    int result = JOptionPane.showConfirmDialog(null,
        "Do you want to remove Windows now?");
    switch (result) {
      case JOptionPane.YES_OPTION:
        System.out.println("Yes"); break;
      case JOptionPane.NO_OPTION:
        System.out.println("No"); break;
      case JOptionPane.CANCEL_OPTION:
        System.out.println("Cancel"); break;
      case JOptionPane.CLOSED_OPTION:
        System.out.println("Closed"); break;
    }
    String name = JOptionPane.showInputDialog(null,
        "Please enter your name.");
    System.out.println(name);
    JTextField userField = new JTextField(  );
    JPasswordField passField = new JPasswordField(  );
    String message = "Please enter your user name and password.";
    result = JOptionPane.showOptionDialog(f,
        new Object[] { message, userField, passField },
        "Login", JOptionPane.OK_CANCEL_OPTION,
        JOptionPane.QUESTION_MESSAGE,
        null, null, null);
    if (result == JOptionPane.OK_OPTION)
      System.out.println(userField.getText(  ) +
          " " +  new String(passField.getPassword(  )));
    System.exit(0);
  }
}

[Lines 10 and 11 above are one line as are lines 12 and 13. They have been split for formatting purposes.]

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.