תוכנית בדיקה - פירוט התוכנית
להלן פירוט מלא של תוכנית הבדיקה.
/*File Swing04 Copyright 1998, R.G.Baldwin The primary purpose of this program is to demonstrate pluggable look and feel (PL&F) and the ability to change the L&F at runtime. It also illustrates a couple of requirements of using Swing components that differ from using AWT components. The program creates a GUI in a JFrame containing a PlafPanel. The PlafPanel01 is instantiated from a custom class named PlafPanel01 and contains one JButton for each L&F implementation in the currently installed JDK. The name of the L&F is displayed on each JButton on the PlafPanel01. The PlafPanel01 is added to the content pane of the JFrame. Clicking each JButton on the PlafPanel01 will cause the L&F of the GUI to change to the L&F represented by that JButton. The program also creates another GUI in a JFrame which is intended to simulate a GUI under test. This GUI contains an inactive JButton and an inactive JTextField. These components are provided so that you can see how then behave when the L&F is changed. It is instructive to see how shapes and colors for these inactive components change as each different L&F is implemented. Tested using JDK 1.1.3 and Swing 1.0.1 under Windows 95 *********************************************************/ import java.awt.*; import java.awt.event.*; import com.sun.java.swing.*; import java.util.*; // Subclass JFrame to display a window public class Swing04 extends JFrame {//controlling class Swing04(String title) {//constructor // Set the title of the JFrame super(title); //Now create the test GUI for this application. getContentPane().setLayout(new FlowLayout()); //Add some components to be viewed with the new L&F getContentPane().add(new JButton("Dummy JButton")); getContentPane().add(new JTextField("Dummy JTextField")); }//end constructor //-----------------------------------------------------// // Create main method to execute the application public static void main(String args[]) { JFrame jFrame = new Swing04( "Pluggable L&F, Copyright 1998, RG Baldwin"); // Set the size of the JFrame and show it jFrame.setSize(400,100); jFrame.setVisible(true); // Create a WindowAdapter to terminate the program // when the window is closed. jFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }//end windowClosing() });//end WindowListener //Create a PlafPanel in a floating JFrame that can be // used to test this GUI. JFrame myPlafPanel = new JFrame( "PL&F Panel,Copyright 1998,RG Baldwin"); myPlafPanel.getContentPane().add( new PlafPanel01(jFrame)); myPlafPanel.setBounds(0,400,400,150); myPlafPanel.setVisible(true); }//end main() }//end class Swing04 //=======================================================// |
.