BPanel
There is another class in BorlandBase called BPanel. This class allows for you to easily do a SplashScreen. To use it, extend BPanel. All of the methods you are used to you can use.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.image.*;
/**
* Write a description of class SamplePanel here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MySamplePanel extends BPanel
{
BTextField textField = new BTextField();
JButton closeButton= new JButton ("Close");
/**
* This method will be called one time at the beginning of your applet/program
*/
public void initialize()
{
setBackgroundColor(Color.red);
addItem(textField);
addItem(closeButton);
}
/**
* This method gets called if the button is pressed
* c is the component (button usually) that was pressed
*/
public void buttonPressed (Component c)
{
echo ("action being performed"); //this is just like system.out.println - but shorter
if (c == closeButton)
{
closePanel();
}
}
//When someone presses the mouse button
public void mousePressed(MouseEvent e)
{
}
/**
* This method if you would like to do drawing on your screen
*/
public void paintScreen (Graphics g)
{
}
}
Then in your main program, stop animation, and open your panel as below.
stop(); //stop animation, if it is going
openPanel(new MySamplePanel(),true); //the boolean is wether you want animation to go when the panel[splash screen] closes
|