SwingAppKit
1.0

http://www.swingappkit.com


SwingAppKit is a complete swing framework for building desktop applications. It includes dialog management, preferences, XML application descriptor for menus, popups, toolbars..., various prefedefined dialogs (about, help, tip of the day...), some swing utilities.

The following applications are based on this framework : EditiX (an XML Editor and XSLT Debugger), XFlows (an XML workflow), UniMailer (a mail client)

1. Dialog Management
2. Preferences
3. Wizard
4. Application Descriptor
5. Application Model
6. Tools

1. Dialog management

The main part is the DialogManager class. With the DialogManager you can show easily your dialog in a modern style

The main method is the showDialog, with this method, it will display your content pane inside a modal dialog. As any dialogs, various actions like Ok, Cancel are available, you can know the last pressed action with the returned value of the showDialog method. For sample for detecting the Ok action, the value is equals to DialogManager.OK_ID.

In the following sample, we display a button in a dialog content for a size of 500 x 500, we force the screen center location using the setAutoCenter method.

package dialogs;

import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JOptionPane;

import com.japisoft.framework.dialog.DialogManager;

/**
 * Here a simple case for displaying an OK/Cancel dialog
 @author JAPISoft / http://www.japisoft.com */
public class Simple {

  public static void mainString[] args ) {
    JButton btn = new JButton"Test" );
    // Force the center location
    DialogManager.setAutoCentertrue );

    // Show our dialog box    
    if DialogManager.showDialog(
        null,
        "My dialog title",
        "My first title",
        "One comment\nOther comment",
        null,
        btn,
        new Dimension500500 ) ) ==
          DialogManager.OK_ID ) {
      JOptionPane.showMessageDialognull, "OK Pressed " );
    else
      JOptionPane.showMessageDialognull, "Cancel Pressed " );
  }

}

Automatically the user interface content takes all the space in dialog, this is due to an hidden usage of a BorderLayout. Note that most of the time, you will not put directly your component (like a button) but rather you will put a complete panel.

A dialog box is divided in three parts :

- The header (Main title in bold, comment and one icon)

- The UI part (this is your interface)

- A footer (with the action part : Ok, Cancel...)

You can manage (add,remove...) the dialog actions (ok, cancel...) using a DialogActionModel. When it is not specified, the DialogManager includes a default model with the Ok and Cancel actions. An action is a standard class implementing the swing javax.swing.Action interface.

In the following sample, we add a custom action with the class CustomDialogAction :

package dialogs;

import java.awt.Dimension;

import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JOptionPane;

import com.japisoft.framework.dialog.DialogManager;
import com.japisoft.framework.dialog.actions.AbstractDialogAction;
import com.japisoft.framework.dialog.actions.ClosingAction;

/**
 * Here we add another action inside the dialog bottom part
 @author JAPISoft / http://www.japisoft.com */
public class CustomAction {

  /** Here a sample of custom dialog action
   *  We implement the ClosingAction interface for
   *  closing the dialog automatically when this action is
   *  activated
   *  */
  static class CustomDialogAction extends AbstractDialogAction 
      implements ClosingAction {
    CustomDialogAction() {
      // Here our action ID
      // Each action ID must be unique !
      super10 );
      putValue( Action.NAME, "My Action);
    }
  }

  public static void mainString[] args ) {
    JButton btn = new JButton"Test" );
    // Force the center location
    DialogManager.setAutoCentertrue );

    CustomDialogAction myAction = new CustomDialogAction();
    
    // We add another action for the dialog */
    DialogManager.getDefaultDialogActionModel().addDialogAction(
      myAction
    );

    DialogManager.setDefaultAction10 );
    int ret = 0;

    // Show our dialog box
    if ( ( ret = DialogManager.showDialog(
        null,
        "My dialog title",
        "My first title",
        "One comment\nOther comment",
        null,
        btn,
        new Dimension500500 ) ) ) ==
          DialogManager.OK_ID ) {
      JOptionPane.showMessageDialog
          null, 
          "OK Pressed " );
    else
      if ret == DialogManager.CANCEL_ID ) {
        JOptionPane.showMessageDialog
            null, 
            "Cancel Pressed " );
      else
        JOptionPane.showMessageDialog
            null, 
            "Another Pressed " );

    // We remove the action, otherwise it will be present for the next dialogs
    DialogManager.getDefaultDialogActionModel().removeDialogAction(
        myAction );
  }

}

Our action is stored inside the default action model. Note that putting it inside the default model will make it visible for all the next dialogs, that's why we remove it at the end. The interface ClosingAction is for helping the dialog manager to know if the dialog must be closed or not with this action, if you don't implement this empty interface, the dialog will not be closed.

We can also build our own action model, but we must add too the Ok or Cancel actions if required. Here a sample :

package dialogs;

import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JOptionPane;

import com.japisoft.framework.dialog.DialogManager;
import com.japisoft.framework.dialog.actions.CancelAction;
import com.japisoft.framework.dialog.actions.DialogActionModel;
import com.japisoft.framework.dialog.actions.OKAction;

/**
 * Here we add another action inside the dialog bottom part
 @author JAPISoft / http://www.japisoft.com */
public class CustomModel {

  public static void mainString[] args ) {
    JButton btn = new JButton"Test" );
    // Force the center location
    DialogManager.setAutoCentertrue );

    // We create a model for storing all our actions
    DialogActionModel
      model = new DialogActionModel();
    model.addDialogAction(
        new CancelAction() );    
    model.addDialogAction(
        new OKAction() );

    int ret = 0;

    // Show our dialog box with our action model
    if ( ( ret = DialogManager.showDialog(
        null,
        "My dialog title",
        "My first title",
        "One comment\nOther comment",
        null,
        btn,
        model,
        new Dimension500500 ) ) ) ==
          DialogManager.OK_ID ) {
      JOptionPane.showMessageDialog
          null, 
          "OK Pressed" );
    else
      if ret == DialogManager.CANCEL_ID ) {
        JOptionPane.showMessageDialog
            null, 
            "Cancel Pressed" );
      else
        JOptionPane.showMessageDialog
            null, 
            "Another Pressed..." );
  }

}

We build an action model using the DialogActionModel class and we report it to the DialogManager inside the showDialog method.

Using the DialogManager you can replace :

- The default dialog header, you must in this case implement the DialogHeader interface and call the setDefaultDialogHeader(java.lang.Class) method

- The default dialog footer, you must in this case implement the DialogFooter interface and call the setDefaultDialogFooter(java.lang.Class) method.

- The default action model, you must in this case called the setDefaultDialogActionModel(com.japisoft.framework.dialog.actions.DialogActionModel) method.

- The default icon, you must in this case call the setDefaultDialogIcon(javax.swing.Icon) method.

You can work without the DialogManager creating another dialog class. Here a sample, this dialog has one Ok button.

package dialogs;

import java.awt.Frame;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import com.japisoft.framework.dialog.BasicOKDialogComponent;

/**
 * Here a simple dialog with a default OK button
 @author JAPISoft / http://www.japisoft.com */
public class SimpleOKDialog extends BasicOKDialogComponent {
  public SimpleOKDialogFrame parent ) {
    superparent, 
        "A custom title",
        "My title",
        "My comment",
        null );
    setInitialSize400300 );

    // My interface content
    
    // You must not use the getContentPane/add methods but the
    // setUI method

    setUI(
        new JScrollPane(
            new JTextArea() ) );
    
  }

  public static void mainString[] args ) {
    SimpleOKDialog cd = new SimpleOKDialognull );
    cd.setVisibletrue );
  }
}

In this sample, we inherit from the BasicOkDialogComponent class. This class is a complete dialog box with an Ok dialog action. We use the setUI method for setting the user interface. Note that you musn't use the getContentPane() or the add method as for a traditional JDialog usage.

When making visible such dialog, the method getLastAction give the last dialog action called (like Ok, Cancel...)

If you wish to have both the Ok and Cancel dialog actions, you must inherit from the BasicOkCancelDialogComponent.

If you wish to use other actions, you can also modify the actions model by overriding the method prepareActionModel (from the BasicOkDialogComponent...) or by using the DialogManager and its default action models.

/** Defining the dialog actions */
  protected DialogActionModel prepareActionModel() {
    DialogActionModel actionModel = DialogManager.getDefaultDialogActionModel();
    return actionModel;
  }
 

2. Preferences

A preference is a way to let the user changing a part of the configuration. When building your code, you need to know the user choice, for colors, font, int... values, all is available from the Preferences class. This class contains a lot of static methods for getting a value that the user may have changed.

A preference is divided in two parts :

- The group : this is a collection of preferences

- A preference name

All the preferences are stored inside the home directory/.The application config name. The application name is defined by the ApplicationModel.SHORT_APPNAME value. For instance if the name is "simple" the user choices will be stored in his personal account home/.Simple.

Here a sample

package preferences;

import com.japisoft.framework.ApplicationModel;
import com.japisoft.framework.preferences.Preferences;

/** Here a simple preference usage. We read two preferences and
 * we save the last values 
 */
public class Simple {

  /**
   @param args
   */
  public static void main(String[] args) {
    ApplicationModel.SHORT_APPNAME = "simple";

    // Read or create a new preference
    // it will return 10 the first time
    int val1 = Preferences.getPreference(
        "test1""pref1"10 );
    
    // Read or create a new preference
    // it will return 10 the first time    
    String val2 = 
      Preferences.getPreference(
          "test1""pref2""Val2" );
    
    System.out.println"Val1 = " + val1 );
    System.out.println"Val2 = " + val2 );
    
    // The preferences values are stored inside the
    // YOUR HOME/.Simple/pref.prop file
    Preferences.savePreferences();
  }

}

In this sample there're two preferences : pref1 and pref2 from the test1 group, so each value can be changed by the user with the preferences dialog box.

The preferences are loaded automatically for the first usage, if you change a value, you need to save it at the end of your application by calling the savePreferences method because all is managed in memory.

For displaying the preferences dialog box, you can use such code sample :

package preferences;

import com.japisoft.framework.ApplicationModel;
import com.japisoft.framework.dialog.actions.OKAction;
import com.japisoft.framework.preferences.Preferences;
import com.japisoft.framework.preferences.PreferencesDialog;

/** Display the preferences interface dialog */
public class Interface {

  public static void main(String[] args) {
    ApplicationModel.SHORT_APPNAME = "simple";

    // Read or create a new preference
    // it will return 10 the first time
    int val1 = Preferences.getPreference(
        "test1""pref1"10 );
    
    // Read or create a new preference
    // it will return 10 the first time    
    String val2 = 
      Preferences.getPreference(
          "test1""pref2""Val2" );

    System.out.println"Val1 = " + val1 );
    System.out.println"Val2 = " + val2 );
    
    // Display the preferences interface

    PreferencesDialog 
      dialog = new PreferencesDialognull );
    
    dialog.setVisibletrue );
    if dialog.getLastAction() == OKAction.ID ) {
      
      // Save the user changes
      
      dialog.storePreferences();
    }
  }
}
 

The preference dialog box is available and the user can update it. Note that you must test the last activated action once visible for storing definitly the preferences changes. Most of the time, the change will require to restart the application.

3. Wizard

The wizard is a way to propose to the user several steps for building an application element.

All is managed from the JWizard class. This class contains a set of wizard step. A step is the interface part that will evolve during the wizard usage. All the steps are stored inside a WizardStepModel. In a step you must specify a title, a short title, a long title and comment and the user interface component like a JPanel instance. You can use a basic step with the BasicWizardStep class.

Here a sample of usage :

package wizard;

import java.awt.Dimension;

import javax.swing.JOptionPane;
import javax.swing.JTextField;

import com.japisoft.framework.dialog.DialogManager;
import com.japisoft.framework.dialog.actions.DialogActionModel;
import com.japisoft.framework.dialog.actions.OKAction;
import com.japisoft.framework.wizard.BasicStepView;
import com.japisoft.framework.wizard.BasicWizardStep;
import com.japisoft.framework.wizard.JWizard;

/** Here a simple demo for using the wizard */
public class Simple {

  public static void main(String[] args) {
    JWizard wizard = new JWizard();

    // We initialize some simple step cases
    for int i = 1; i < 5; i++ )
      wizard.getWizardStepModel().addWizardStep(
        new BasicWizardStep(
            "step" + i,
            "short title",
            "Long title about step " + i,
            new BasicStepView(
                new JTextField"Content " + i ) ) ) );

    int returnCode = 0;

    // We display the wizard
    
    returnCode = DialogManager.showDialog(
        null,
        "Wizard test",
        "Wizard sample",
        "Test our wizard",
        null,
        wizard.getView().getView()
        // We create an empty dialog action because this is already in the wizard
        new DialogActionModel(),  
        new Dimension400300 ) );

    // We check if the Ok action has been choosen

    if returnCode == OKAction.ID )
      JOptionPane.showMessageDialog(
          null,
          "Wizard completed" );
  }

}

 

4. Application descriptor

The application descriptor is an XML document for building menus, popups, toolbars and set of actions. All is managed by the InterfaceBuilder class. This class builds all the required elements from an XML descriptor.

The XML descriptor has the following elements :

- a <root element> (can be any names) :
Attributes :
icon : application icon path from the classpath

- <menuBar> : set of menus

- <menu> : part of the <menuBar>
Attributes :
id : required, the menu identification

- <item> : part of the <menu>, <toolBar>, <model> or <popup> elements.
Attributes :
id : required, a unique id
group : a group name

- <itemRef> : can replace the <item> element
Attributes :
ref : A reference to an existing id.

- <ui> : part of the <menu> or <item> element
Attributes :
label : label of the item
mnemonic : character mnemonic for underline the good label part
help : A tooltip
icon : An icon path from the classpath
shortcut : An item shortcut, note you needn't to include a control key, it is added automatically
enabeld : true or false

- <action> : Part of the <item> element
Attributes :
class : Required, a java action class (compatible with the javax.swing.Action interface)

- <toolBar>
Attributes :
id : Required, a toolBar id.
floatable : false or true

- <separator/> : Part of a <menu> or <toolBar> or a <popup>

- <popup>
Attributes :
id : Required, a popup id

- <model>
Attributes :
id : Required, a model id

Here a sample of descriptor :

<!-- Here a simple application descriptor with one menubar, one toolbar and one popup -->

<test icon="descriptor/images/app.png">

<!-- Test of simple menu bar -->

<menuBar>

<!-- Simple menu content -->

<menu id="file">
<ui label="File" mnemonic="F"/>
<item id="openFile">
<ui help="Open a file" label="Open..." icon="descriptor/images/open.png"/>
<action class="descriptor.actions.OpenAction"/>
</item>

<separator/>

<item id="quit">
<ui help="Quit all" label="Quit" shortcut="Q" icon="descriptor/images/quit.png"/>
<action class="descriptor.actions.QuitAction"/>
</item>
</menu>

<!-- Simple menu content -->

<menu id="other">
<ui label="Other" mnemonic="O"/>
<item id="openFile2">
<ui help="Open a file" label="Open..." icon="descriptor/images/open.png" enabled="false"/>
<action class="descriptor.actions.OpenAction" enabled="false"/>
</item>

<!-- sub menu -->

<menu id="other2">
<ui label="Other2"/>
<item id="quit2">
<ui help="Quit all" label="Quit" shortcut="Q" icon="descriptor/images/quit.png"/>
<action class="descriptor.actions.QuitAction"/>
</item>
</menu>

</menu>

</menuBar>

<!-- Test of a simple toolBar -->

<toolBar id="mainToolBar">
<itemRef ref="openFile"/>
<separator/>
<itemRef ref="quit"/>
</toolBar>

<!-- Test of a simple popup -->

<popup id="mainPopup">
<itemRef ref="openFile"/>
<separator/>
<itemRef ref="quit"/>
</popup>

<!-- Test of a simple action model -->

<model id="mainModel">
<itemRef ref="openFile"/>
</model>

</test>



Here a code sample for using this descriptor :

package descriptor;

import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import com.japisoft.framework.ApplicationModel;
import com.japisoft.framework.application.descriptor.InterfaceBuilder;
import com.japisoft.framework.application.descriptor.InterfaceBuilderException;

/** Simple interface descriptor 
 *   usage for building menus, toolbars and popups */
public class Simple {

  /**
   @param args */
  public static void main(String[] args) {
    try {
      // Required application name
      ApplicationModel.SHORT_APPNAME = "Simple";
      
      // Here the class creating the menu,toolbar,popup... from the
      // application descriptor simple.xml
      final InterfaceBuilder
        ib = new InterfaceBuilder(
            Simple.class.getResource"simple.xml" ) );

      // Bound to the application ui content to the following frame
      JFrame f = new JFrame();
      f.setJMenuBarib.getMenuBar() );
      f.getContentPane().add(
          ib.getToolBarById"mainToolBar" ), BorderLayout.NORTH );
      final JTextArea ta = new JTextArea();
      f.getContentPane().add(
              new JScrollPaneta ) );
      
      // Show a popup
      ta.addMouseListener(
          new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              if e.getButton() == e.BUTTON3 )
                ib.getPopup"mainPopup" ).show(
                    ta,
                    e.getX(), e.getY() );
            }            
          } );
      f.setSize400400 );
      f.setVisibletrue );
    catch (InterfaceBuilderException e) {
      e.printStackTrace();
    }
  }
}

Note that your application must have a short name with the ApplicationModel.SHORT_APPNAME value.

For finding the application descriptor we use the application classpath, here the URL of the application descriptor is accessed relativly to our application location using the getResource method. Once the descriptor is read, we can access to the menu bar by calling the getMenuBar method, this is similar for the toolbar with the getToolBarById method and for the popup and the bound getPopup method.

As the application descriptor works with standard swing actions, you may also create your own code for creating action, supposing your actions are stored in a database etc.. You must in this case implement the ActionBuilder interface. Your class will be a kind of delegate for building each action instance and must be provided inside the constructor of the InterfaceBuilder class.

Here a code sample :

package descriptor;

import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;

import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import com.japisoft.fastparser.node.SimpleNode;
import com.japisoft.framework.ApplicationModel;
import com.japisoft.framework.application.descriptor.InterfaceBuilder;
import com.japisoft.framework.application.descriptor.InterfaceBuilderException;
import com.japisoft.framework.application.descriptor.helpers.ActionBuilder;

/** Here a more complex case. We use a delegate for  */
public class Complex {

  /** Here we create a delegate for building each application actions
   * It could be loaded anywhere
   */ 
  static class CustomActionBuilder implements ActionBuilder {
    HashMap map = new HashMap();

    /** It will return the action instance. 
     * The actionName is equals to the action class */
    public Action buildAction
        SimpleNode source, 
        String actionName 
          throws InterfaceBuilderException {

      try {
        // We avoid to create duplicate action instance
        Action a = Action )map.getactionName );
        if a == null ) {
          System.out.println"Build the action " + actionName );
          a = Action )Class.forNameactionName ).newInstance();
          map.putactionName, a );
        }
        return a;
      catch Exception e ) {
        throw new InterfaceBuilderExceptione.getLocalizedMessage() );
      }
    }
  }

  /**
   @param args */
  public static void main(String[] args) {
    try {
      // Required application name
      ApplicationModel.SHORT_APPNAME = "Simple";
      
      // Here the class creating the menu,toolbar,popup... from the
      // application descriptor simple.xml
      final InterfaceBuilder
        ib = new InterfaceBuilder(
            Complex.class.getResource"complex.xml" )
            new CustomActionBuilder() );

      // Bound to the application ui content to the following frame
      JFrame f = new JFrame();
      f.setJMenuBarib.getMenuBar() );
      f.getContentPane().add(
          ib.getToolBarById"mainToolBar" ), BorderLayout.NORTH );
      final JTextArea ta = new JTextArea();
      f.getContentPane().add(
              new JScrollPaneta ) );

      // Show a popup
      ta.addMouseListener(
          new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              if e.getButton() == e.BUTTON3 )
                ib.getPopup"mainPopup" ).show(
                    ta,
                    e.getX(), e.getY() );
            }            
          } );
      f.setSize400400 );
      f.setVisibletrue );
    catch (InterfaceBuilderException e) {
      e.printStackTrace();
    }
  }
}

 All the action instances are available inside the ActionModel class. You can for instance retrieve an action, activate it and disable/enable. You have also various methos for popup, toolbar and model access from the InterfaceBuilder.

 

5. Application model

The SwingAppKit includes too an application framework that can be use outside the scope of a swing application. This is a mecanism for building in a clean way your application. For the concept, your application starting is divided in a set of steps. Each step is managed by the ApplicationMain class. A step is stored inside the ApplicationModel. A step is a task that must be runned when starting the application, it can be anything, like showing a splashscreen, setting the current lookAndFeel, defining the application interface content... Once the model is full of steps, you only have to call the start method of the ApplicationMain, when terminating your application, you must call the stop method from the ApplicationMain class, then each step that needs it, will dispose its resource.

Here a sample of code working work various steps

  // Add a splashscreen
    ApplicationModel.addApplicationStep(
        new SplashScreenApplicationStep1000 ) );

    // Install the default lookAndFeel
    ApplicationModel.addApplicationStep(
        new LookAndFeelStep() );
    
    // Add the application descriptor analysis
    ApplicationModel.addApplicationStep(
        new InterfaceBuilderStep(
            "app/notepad.xml" ) );

    // Add the final user interface step
    ApplicationModel.addApplicationStep(
        new UIStep() );

    // Start the main application
    ApplicationMain.startargs );
 

The following steps are predefined :

com.japisoft.framework.step.InterfaceBuilderStep : Use an XML descriptor for building the menubar, toolbar...
com.japisoft.framework.step.LookAndFeelStep : Set the application lookAndFeel. By default use the system one.
com.japisoft.framework.step.SplashScreenApplicationStep : Add a splash screen, if the application logo is not specified it is loaded from the ApplicationModel.APP_IMG_PATH property.
com.japisoft.framework.step.ClassInstanceStep : Create an instance for a particular class.

There're also some properties inside the ApplicationModel class you should defined for your application, some properties are used by some predefined dialog box.

/** The application full name */
LONG_APPNAME = null;
/** A short application name. This is used for the user home directory name */
SHORT_APPNAME = null;
/** A build version */
BUILD = "010105";
/** A major version number */
MAJOR_VERSION = 1;
/** A Minor version number */
MINOR_VERSION = 0;
/** A Sub minor version number */
SUBMINOR_VERSION = 0;
/** A Beta version number */
BETA_VERSION = 0;
/** Main contact for email support */
MAIN_SUPPORT_EMAIL = null;
/** Registered file name */
REGISTERED_FILE = null;
/** URL for reporting a problem */
REPORTING_URL = null;
/** Main application descriptor */
USERINTERFACE_FILE = null;
/** File for generating a documentation */
AUTODOC_FILE = "autodoc.xsl";
/** Path (classpath) for an application logo image */
APP_IMG_PATH = null;

Here a code sample :

    // Short name, required for saving preferences
    ApplicationModel.SHORT_APPNAME = "notepad";
    // Long application name
    ApplicationModel.LONG_APPNAME = "Notepad";
    // Application major version
    ApplicationModel.MAJOR_VERSION = 1;
    // Last application build
    ApplicationModel.BUILD = "010506";
    // Company URL
    ApplicationModel.REPORTING_URL = "http://www.japisoft.com";
    // Path for the application logo
    ApplicationModel.APP_IMG_PATH = "app/notepad.png";
    

 Note that most path are working from the classpath, thus you can deploy your application with one jar very easily.

6. Tools

There's some predefined dialogs :

The about dialog : You can invoke it with the AboutAction class (this is a swing action, you can put it in an XML descriptor) or using the AboutDialog.

The tip of the day dialog : You can invoke it with the TipOfTheDayAction class (this is a standard swing action) or using the dialog TipOfTheDayDialog. All the tips must be stored in a tips path available from your classpath. Each tip is available in an HTML file call tip1.html, tip2.html ... The first line of each tip file is the tip name.

The manual is available with the ManualAction class or using the ManualDialog dialog box. The manual is an HTML document located with an URL inside the ApplicationModel.DEF_MANUAL_PATH property.

You have also accessed to various components like a Gradient panel or a TextField for choosing a file :

Here a code sample for usage :

package tools;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.japisoft.framework.ui.GradientPanel;
import com.japisoft.framework.ui.text.FileTextField;

/** Here a sample of custom swing components */ 
public class Simple {

  public static void mainString[] args ) {
    JFrame f = new JFrame();
    
    JPanel p = new JPanelnew BorderLayout() );
    p.addnew FileTextFieldnull, "xml" ), BorderLayout.NORTH );
    
    f.getContentPane().addnew GradientPanel(
        "My Title",
        ) );
    f.setSize400400 );
    f.setVisibletrue );
  }
  
}


© 2006 JAPISoft - http://www.japisoft.com 17/05/06