Best Projects

Bug Trackingsystem,Books online shopping,college management system,HR management system,Internet banking,Online chat room ,Online exam,Telephone billing system,Banking application,ATM database,airways reservation system,virtual network computing ,calculator,SMTP(simple mail transfer protocol)

Logo using Runnable Interface




//applet
/**
*@author Jeremy O'Donohue
*
*AppletDemo.java
*This applet gives a good demonstration of how swing componants can be easily yet effectively
*used to create an applet with a very usable gui.
*
**/
import javax.swing.*;
import java.util.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;

public class AppletDemo extends JApplet implements ActionListener, Runnable
{
JPanel pane;
JPanel StartMenu;
JButton startButton;
JPanel startMenuPanel;
JPanel buttonPane;
JLabel lblDisplay;
JButton b1;
JButton b2;
JButton b3;
JButton b4;
JButton b5;
ImageIcon startIcon;
ImageIcon homeIcon;
ImageIcon logoIcon;
ImageIcon goalsIcon;
ImageIcon contactIcon;
ImageIcon projectsIcon;
Color c1;
ImageIcon bigLogo;
Border compound,raisedbevel,blackline;
JButton dateText;
String DATE_TIME;
Thread th;

public void init()
{
setContentPane(makeContentPane());
}
/**
*Creates and initializes gui componants
**/
public Container makeContentPane()
{
c1 = new Color(110,113,250);
compound = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
raisedbevel = BorderFactory.createRaisedBevelBorder();
blackline = BorderFactory.createLineBorder(Color.black);
StartMenu = new JPanel();
startMenuPanel = new JPanel();
buttonPane = new JPanel();
b1 = new JButton("Home");
b2 = new JButton("ODON Solutions");
b3 = new JButton("Company Goals");
b4 = new JButton("Past Projects");
b5 = new JButton("Contact");
pane = new JPanel();
/**icons and images used in an applet have to be initialized differently
*to a regular java applet.
*An Url must be used. See below
***/
goalsIcon= new ImageIcon(AppletDemo.class.getResource("/pics/goals.gif"));;
contactIcon= new ImageIcon(AppletDemo.class.getResource("/pics/contact.gif"));;
projectsIcon= new ImageIcon(AppletDemo.class.getResource("/pics/projects.gif"));;
startIcon = new ImageIcon(AppletDemo.class.getResource("/pics/startIcon.gif"));
homeIcon = new ImageIcon(AppletDemo.class.getResource("/pics/home.gif"));
logoIcon = new ImageIcon(AppletDemo.class.getResource("/pics/logo.gif"));
bigLogo = new ImageIcon(AppletDemo.class.getResource("/pics/NewLogo.gif"));
/**buttons
**/
b1 = new JButton("Home",homeIcon);
b2 = new JButton("ODON Solutions",logoIcon);
b3 = new JButton("Company Goals",goalsIcon);
b4 = new JButton("Past Projects",projectsIcon);
b5 = new JButton("Contact",contactIcon);
lblDisplay = new JLabel(" ");
lblDisplay.setIcon(bigLogo);
startButton = new JButton("start",startIcon);
startButton.addActionListener(this);
buttonPane.setLayout(new GridLayout(5,1));
pane.setLayout(new BorderLayout());
String time = "";

DATE_TIME = (getTimeNow(time));
dateText = new JButton(DATE_TIME);
dateText.setEnabled(false);
startMenuPanel.setLayout(new BorderLayout());
StartMenu.setLayout(new BorderLayout());
StartMenu.add(startButton,BorderLayout.WEST);
StartMenu.add(dateText,BorderLayout.EAST);
pane.add(StartMenu, BorderLayout.SOUTH);
buttonPane.add(b1);
buttonPane.add(b2);
buttonPane.add(b3);
buttonPane.add(b4);
buttonPane.add(b5);
StartMenu.setBackground(Color.blue);
startButton.setBackground(Color.white);
b1.setBackground(Color.white);
b2.setBackground(Color.white);
b3.setBackground(Color.white);
b4.setBackground(Color.white);
b5.setBackground(Color.white);
b1.setForeground(Color.black);
b2.setForeground(Color.black);
b3.setForeground(Color.black);
b4.setForeground(Color.black);
b5.setForeground(Color.black);
dateText.setBackground(Color.white);
dateText.setForeground(Color.black);

StartMenu.setBackground(Color.white);
pane.setBackground(c1);
startMenuPanel.setBackground(c1);
b1.setBorder(raisedbevel);
b2.setBorder(raisedbevel);
b3.setBorder(raisedbevel);
b4.setBorder(raisedbevel);
b5.setBorder(raisedbevel);
dateText.setBorder(blackline);
StartMenu.setBorder(blackline);
buttonPane.setBorder(raisedbevel);
b1.setHorizontalAlignment(SwingConstants.LEFT);
b2.setHorizontalAlignment(SwingConstants.LEFT);
b3.setHorizontalAlignment(SwingConstants.LEFT);
b4.setHorizontalAlignment(SwingConstants.LEFT);
b5.setHorizontalAlignment(SwingConstants.LEFT);
lblDisplay.setHorizontalAlignment(SwingConstants.RIGHT);

buttonPane.setBackground(Color.white);
startMenuPanel.add(buttonPane, BorderLayout.SOUTH);
pane.add(startMenuPanel, BorderLayout.WEST);
pane.add(lblDisplay,BorderLayout.CENTER);
startMenuPanel.setVisible(false);
startButton.addActionListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
th = new Thread(this);
th.start();
return pane;
}
/**
*This is the thread that runs when th.start() is called.
*The thread waites for 1 min or 60000 milliseconds and then updates the clock
*with the current hour and minute
**/
public void run()
{
while(true)
{
try{
th.sleep(60000);
String time = "";
DATE_TIME = (getTimeNow(time));
dateText.setText(DATE_TIME);
repaint();
}catch(Exception er){}
}

}
/**
*This method creates a date and then extracts theinformation that we need out of it
*and puts it into a string to create our clock.
*!note getHours() and getMinutes are now deprecated.... may be removed from the
*api at some stage in the future
**/
public String getTimeNow(String time)
{
Date now = new Date();
String pmam ="";
int hour = now.getHours();
int minutes = now.getMinutes();
if(hour > 12)
{
hour = hour -12;
pmam = "pm";
}
else
pmam = "am";
time = " " + hour+":"+minutes+" "+ pmam +" ";
return time;
}
/**
*Action listener for all the buttons on the gui
**/
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(startButton))
{


startMenuPanel.setVisible(true);

}
else
startMenuPanel.setVisible(false);

}




}

No comments: