Basic Swing Details

  • WindowUtilities.java Utility class that simplifies creating a window and setting the look and feel.
  • ExitListener.java A WindowListener with support to close the window.
  • JAppletExample.java A simple applet (JApplet) created in Swing. Illustrates setting the look and feel, adding components to the content pane, and changing the layout to FlowLayout (default is BorderLayout). See JAppletExample.html (requires the Java Plug-In or a Java 2 compliant browser, for example, Netscape 6.x).
  • JFrameExample.java Demonstrates creating a simple Swing application using a JFrame. As with a JApplet, components must be added to the content pane, instead of the window directly.
  • JLabels.java Illustrates creating labels in Swing. A nice feature of JLabels is that the label text can contain HTML markup. Uses image JHUAPL.gif
  • JButtons.java Creates various buttons. In Swing, buttons can contain text only, an image only, or a combination of both an image and a label. Uses image cup.gif.
  • JPanels.java A simple example that illustrates creating panels. In Swing, a JPanel can contain custom borders. Typically, utility methods in the BorderFactory class are used to create a border for the panel. Uses the following class:
    o SixChoicePanel.java A JPanel that displays six radio buttons with labels.
  • JSliders.java Creates three common types of sliders: one without tick marks, one with tick marks, and one with both tick marks and labels.
  • JColorChooserTest.java Demonstrates the use of a JColorChooser which presents a dialog with three different tabbed panes to allow the user to select a color preference. The dialog returns a Color object based on the user's selection or null if the user entered Cancel.
  • JInternalFrames.java Illustrates the ability to create a Multiple Document Interface (MDI) application by placing internal frames (JInternalFrame) in a desktop pane (JDesktopPane).
  • JToolBarExample.java Small example showing the basic use of a JToolBar. Uses the following classes and images:
    o ToolBarButton.java A simple button that contains an image and a label for use in a toolbar.
    o BrowserToolBar.java A basic tool bar for holding multiple buttons.
    o Images used in the toolbar buttons: Help.gif, Home.gif, Left.gif, Print.gif, Right.gif, RotCCUp.gif, TrafficRed.gif.
  • Browser.java Implementation of a simple browser in Swing. The user can specify a URL to load into the browser (JEditorPane). By attaching an HyperlinkListener, the editor pane is responsive to hyperlinks selected by the user. Uses the following class and image:
    o JIconButton.java A simple button that the user can select to load the entered URL.
    o home.gif Image used in the button.
  • JCheckBoxTest.java Simple example illustrating the use of check boxes.
  • JRadioButtonTest.java Creates three radio buttons and illustrates handling ItemEvents in response to selecting a radio button.
  • JOptionPaneExamples.java Creates various modal dialogs to show messages. Uses the follwoing classes:
    o JLabeledTextField.java A simple JPanel that combines a JLabel and a JTextField.
    o RadioButtonPanel.java Groups several radio buttons in a single row, with a label on the left.
    o DisableListener.java A listener that toggles the enabled status of some other component.

Permanent link to this article: http://bangla.sitestree.com/basic-swing-details/

Leave a Reply