import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class SplashScreen extends JFrame
{
JLabel bgImage;
//public void run()
SplashScreen()
{
Container c = getContentPane();
c.setLayout(new BorderLayout());
bgImage = new JLabel(new ImageIcon("Sunset.jpg"));
c.add(bgImage);
}
}
class ClusterUI extends JFrame
{
JLabel clusterLabel;
JButton configureButton, migrateButton, viewprocButton, aboutButton;
JTable displayTable;
String columnNames[] = {"Machine Id","IP Address"};
Object[][] data = {
{new Integer(1), "192.168.10.1"},
{new Integer(2), "192.168.22.15"},
{new Integer(3), "192.168.2.5"},
};
ClusterUI()
{
super("Cluster computing - Software");
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(Color.BLACK);
clusterLabel = new JLabel("Cluster PCs Monitoring");
clusterLabel.setForeground(Color.BLUE);
clusterLabel.setFont(new Font("Monospaced", Font.BOLD,25));
configureButton = new JButton("Configure");
migrateButton = new JButton("Migrate ");
viewprocButton = new JButton("View the process");
aboutButton = new JButton("About");
aboutButton.addActionListener(new abtButtonListener());
displayTable = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(displayTable);
displayTable.setPreferredScrollableViewportSize(new Dimension(200,
60));
c.add(clusterLabel);
c.add(configureButton);
c.add(migrateButton);
c.add(viewprocButton);
c.add(aboutButton);
c.add(scrollPane);
} //end of constructor
private class abtButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Clustering program"+
"\n*********************" +
"\n\nThis program is developed using open source technologies.\n\n
Program was "+
"developed by Justin, Nandu and Gopu. \n\n\nFor product support
contact clust...@logic.com\n\n\n\n\n\n");
}
}
}
public class ClusterTest
{
public static void main(String args[])
{
SplashScreen s1 = new SplashScreen();
s1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
s1.setSize(448,336);
s1.setUndecorated(true);
s1.setVisible(true);
ClusterUI c1 = new ClusterUI();
c1.setSize(400,275);
c1.setVisible(true);
c1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
//USe the new ClusterTest.java as well as the SplashScreen,java
//ClsuterTest.java
//ClusterTest.java
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class ClusterUI extends JFrame
{
JLabel clusterLabel;
JButton configureButton, migrateButton, viewprocButton,
aboutButton;
JTable displayTable;
String columnNames[] = {"Machine Id","IP Address"};
Object[][] data = {
{new Integer(1), "192.168.10.1"},
{new Integer(2), "192.168.22.15"},
{new Integer(3), "192.168.2.5"},
{new Integer(4), "192.168.2.121"},
{new Integer(5), "192.168.2.21"}
};
ClusterUI()
{
super("Cluster computing - Software");
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(Color.BLACK);
clusterLabel = new JLabel("Cluster PCs Monitoring");
clusterLabel.setForeground(Color.BLUE);
clusterLabel.setFont(new Font("Monospaced",
Font.BOLD,25));
configureButton = new JButton("Configure");
migrateButton = new JButton("Migrate ");
viewprocButton = new JButton("View the process");
aboutButton = new JButton("About");
aboutButton.addActionListener(new abtButtonListener());
displayTable = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(displayTable);
displayTable.setPreferredScrollableViewportSize(new
Dimension(200,80));
c.add(clusterLabel);
c.add(configureButton);
c.add(migrateButton);
c.add(viewprocButton);
c.add(aboutButton);
c.add(scrollPane);
} //end of constructor
private class abtButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, "Clustering
program"+
"\n*********************" +
"\n\nThis program is developed using open source
technologies.\n\n "+
"Program was developed by Justin, Nandu and Gopu. \n\n\nFor product
support "+
"contact cluster...@logic.com\n\n\n\n\n\n");
}
}
}
public class ClusterTest extends Thread
{
public static void main(String args[])
{
SplashScreen sp=new SplashScreen();//Public class
Defined outside..
ClusterUI c1 = new ClusterUI();
c1.setSize(400,275);
c1.setVisible(true);
c1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
//SplashScreen.java
import java.awt.*;
import javax.swing.*;
import java.applet.*;
public class SplashScreen extends JWindow
{
public SplashScreen()
{
JPanel con=(JPanel)getContentPane();
con.setBackground(new Color(200,205,249));
int width=500;
int height=300;
Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
int x=(screen.width-width)/2;
int y=(screen.height-height)/2;
setBounds(x,y,width,height);
JLabel l1=new JLabel(new ImageIcon("Bliss.jpg"));
con.setLayout(null);
con.add(l1);
l1.setBounds(0,0,500,300);
Color c=new Color(70,70,70);
con.setBorder(BorderFactory.createLineBorder(c,5));
setVisible(true);
try
{
Thread.sleep(4000);
}
catch(Exception e)
{
System.out.println(e);
}
setVisible(false);
}
}
//Then the code is mentioned below
import javax.swing.UIManager;
import javax.swing.ImageIcon;
public class SplashScreenMain {
SplashScreen screen;
public SplashScreenMain() {
// initialize the splash screen
splashScreenInit();
// do something here to simulate the program doing something that
// is time consuming
for (int i = 0; i <= 100; i++)
{
for (long j=0; j<50000; ++j)
{
String poop = " " + (j + i);
}
// run either of these two -- not both
screen.setProgress("Yo " + i, i); // progress bar with a message
//screen.setProgress(i); // progress bar with no
message
}
splashScreenDestruct();
System.exit(0);
}
private void splashScreenDestruct() {
screen.setScreenVisible(false);
}
private void splashScreenInit() {
ImageIcon myImage = new ImageIcon("cluster.jpg");
screen = new SplashScreen(myImage);
screen.setLocationRelativeTo(null);
screen.setProgressMax(100);
screen.setScreenVisible(true);
}
public static void main(String[] args)
{
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
new SplashScreenMain();
}
}