home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 October A
/
Pcwk10a98.iso
/
Inprise
/
TRIAL
/
JBUILDER
/
JSAMPLES.Z
/
IntlDemo.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
7KB
|
193 lines
/*
* Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
*
* This SOURCE CODE FILE, which has been provided by Borland as part
* of a Borland product for use ONLY by licensed users of the product,
* includes CONFIDENTIAL and PROPRIETARY information of Borland.
*
* USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
* OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
* THE PRODUCT.
*
* IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
* COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
* OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
* OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
* OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
* OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
* CODE FILE.
*/
package borland.samples.intl;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
import borland.samples.intl.application.*;
import borland.samples.intl.beans.*;
import borland.samples.intl.gui.*;
import com.sun.java.swing.UIManager;
/**
* Launches the International Sample Application. Constructed using
* the Applet Wizard, IntlDemo.java works both as an applet and an
* application. When run as an application without
* command-line parameters, TextDataFiles are used as the data source.
* If JDBC connection parameters are passed as command-line
* parameters, the specified JDBC database will be used.
* Running as an applet displays a button which when pushed
* starts running the application.
*/
public class IntlDemo extends Applet {
XYLayout xYLayout1 = new XYLayout();
static boolean isStandalone = false;
ButtonControl buttonControl1 = new ButtonControl();
private boolean framesInitialized = false;
Panel panel1 = new Panel();
BorderLayout borderLayout1 = new BorderLayout();
Frame frame = null;
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public IntlDemo() {
}
//Initialize the applet
public void init() {
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
// Component initialization
public void jbInit() throws Exception{
buttonControl1.setFont(new Font("Dialog", 2, 14));
buttonControl1.setImage(createImage((java.awt.image.ImageProducer) this.getClass().getResource("beans/resources/LocaleChooserIconColor32.gif").getContent()));
buttonControl1.setLabel(getParameter("appletButtonStart"));
buttonControl1.addActionListener(new IntlDemo_buttonControl1_actionAdapter(this));
this.setLayout(borderLayout1);
this.add(panel1, BorderLayout.CENTER);
panel1.add(buttonControl1, null);
}
//Start the applet
public void start() {
if (framesInitialized) {
WelcomeFrame.getInstance().setBackgroundActivityEnabled(true);
}
}
//Stop the applet
public void stop() {
if (framesInitialized) {
WelcomeFrame.getInstance().setBackgroundActivityEnabled(false);
}
}
//Destroy the applet and dispose of frames
public void destroy() {
if (framesInitialized) {
WelcomeFrame.getInstance().dispose();
ProductFrame.getInstance().dispose();
OrderFrame.getInstance().dispose();
}
}
//Get Applet information
public String getAppletInfo() {
return "IntlDemo Applet";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
//Main method
static public void main(String[] argv) {
isStandalone = true;
try {
if ((argv.length != 0) && (argv.length != 4)) {
System.out.println("Usage: java IntlDemo");
System.out.println(" runs demo using a TextDataFile data source");
System.out.println("Usage: java IntlDemo [url user password driver]");
System.out.println(" runs demo using the specified JDBC data source");
System.exit(0);
}
if (argv.length == 4) {
System.out.println("Using JDBC data source with the following parameters:");
System.out.println("url: " + argv[0]);
System.out.println("user: " + argv[1]);
System.out.println("password: " + argv[2]);
System.out.println("driver: " + argv[3]);
// set JDBC data source
AppDataModule.setJDBCDataSource(argv[0], argv[1], argv[2], argv[3]);
} else {
System.out.println("Using TextDataFile data source");
}
UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
// show loading screen
LoadingFrame loadingFrame = new LoadingFrame();
loadingFrame.setImageName("Loading.gif");
loadingFrame.setTitle("IntlDemo");
loadingFrame.setVisible(true);
// pre-load frames used by the sample
WelcomeFrame.getInstance();
ProductFrame.getInstance();
OrderFrame.getInstance();
loadingFrame.dispose();
// display welcome frame
WelcomeFrame.getInstance().setVisible(true);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
};
}
void buttonControl1_actionPerformed(ActionEvent e) {
if (framesInitialized == false) {
framesInitialized = true;
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
// set JDBC data source
AppDataModule.setJDBCDataSource(getParameter("url"),
getParameter("user"),
getParameter("password"),
getParameter("driver"));
WelcomeFrame.setRunningAsApplet(true);
// tell WelcomeFrame to run in applet mode
// load frames used by the sample
WelcomeFrame.getInstance();
ProductFrame.getInstance();
OrderFrame.getInstance();
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
WelcomeFrame.getInstance().setVisible(true);
}
}
class IntlDemo_buttonControl1_actionAdapter implements java.awt.event.ActionListener {
IntlDemo adaptee;
IntlDemo_buttonControl1_actionAdapter(IntlDemo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.buttonControl1_actionPerformed(e);
}
}