Assuming MyFrame is your main class extending JFrame,
you can write the main function like this call JSplashScreen.
public static void main(String[] args) {
MyFrame f = new MyFrame();
JSplashScreen splash = new JSplashScreen(f ,
MyFrame.class.getResource("images/splash.png"),
10 );
f.show();
splash.requestFocus();
}
In this example, the image use in the splash is under same package as the MyFrame class (under images sub-directory).
|
Assuming aFrame is a JFrame with a BorderLayout, you add a StatusBar to that frame
using code below. This example comes with an additional text label (JStatusLabel a JLabel with lowered border) and an icon in the status bar.
JStatusBar statusBar = new JStatusBar();
JStatusLabel st = new JStatusLabel("Status");
statusBar.add(st);
statusBar.add(new JStatusLabel(new ImageIcon("images/default_co.gif")));
statusBar.addTimeLabel();
aFrame.getContentPane().add(statusBar, BorderLayout.SOUTH);
statusBar.setStatusText("Modified Status text");
You can set or get the status text with StatusBar::setStatusText and StatusBar::getStatusText.
|
Here is a sample code to construct a JCoolTabbedPanel:
The main panel of the example is manage by a BorderLayout. The JCoolTabbedPanel
is added to the center of the main panel (it can be added where you want,
in main cases to the west in a real application, but it can be added to a splitpane too).
The main work is to add a panel to a JCoolTabbedPanel (JCoolTabbedPanel::addTab).
You can use ony panel you want, I made a special panel (JCoolTabInnerPanel)
which behave like in a standard Outlook Bar.
Once this is done, your work is to associated ActionListener to buttons in the panel
(for example, switch visible component of a panel manager by java.awt.CardLayout layout,
which is added at the center of the main panel).
public void initUI() {
setTitle((String) getClass().getName());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = (JPanel)getContentPane();
panel.setLayout(new BorderLayout());
//
// *** Constructs the sub-panels for the Outlook like panel
//
// *** first Panel ***
// this panel is especially developped for JCoolTabbedPanel
pan1 = new JCoolTabInnerPanel();
// add a background image : default alignment is bottom-left (more to come)
// see pan2 for tiled background
pan1.setBackgroundImage("images/dino.png");
// add components to the sub-panel :
// JCoolButton behaves something like a standard Outlook button
//with rollover behaviour
pan1.add(new JCoolButton("New", new ImageIcon("images/view.gif")));
pan1.add(new JCoolButton("Edit", new ImageIcon("images/view.gif")));
pan1.add(new JCoolButton("Delete", new ImageIcon("images/view.gif")));
pan1.add(new JCoolButton("Childs", new ImageIcon("images/view.gif")));
// *** repeat for others sub-panels ***
pan2 = new JCoolTabInnerPanel();
// add a tiled background image
pan2.setBackgroundImage("images/dark-marble.gif", true);
pan2.add(new JCoolButton("Users", new ImageIcon("images/view.gif")));
pan2.add(new JCoolButton("Roles", new ImageIcon("images/view.gif")));
pan3 = new JCoolTabInnerPanel();
pan3.add(new JCoolButton("Preferences", new ImageIcon("images/view.gif")));
//
// *** JCoolTabbedPanel
//
// Here is the core function of the JCoolTabbedPanel:
// it adds the constructed panels to a JCoolTabbedPanel
// You can experience your own sub-panels to test other behaviours
JCoolTabbedPanel tab = new JCoolTabbedPanel();
tab.addTab(pan1,"Main"); // params are : the panel to add, the title of the tab
tab.addTab(pan2, "Admin");
tab.addTab(pan3,"Options");
// add it to the west as standard Outlook Bar
panel.add(tab, BorderLayout.CENTER);
pack();
setVisible(true);
show();
}
|
|