Dynamic Vari-Color Interface




import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JPanel;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import javax.swing.border.MatteBorder;
import javax.swing.border.BevelBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.UIManager;
import java.awt.Toolkit;
import java.awt.Dialog.ModalExclusionType;
import java.awt.Window.Type;
import java.awt.SystemColor;

public class TimeCase extends JFrame {

public String h;
public String m;
public String s;
int h2;
int m2;
int s2;

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TimeCase frame = new TimeCase();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
 * Create the frame.
 */
public TimeCase() {
getContentPane().setBackground(SystemColor.activeCaptionBorder);
setForeground(Color.WHITE);
setBackground(Color.WHITE);
setType(Type.POPUP);
setResizable(false);
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
setTitle("Time");
setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\Ali\\Desktop\\master-HMI250.jpg"));



Logics lg = new Logics ();

setBounds(100, 100, 436, 596);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(null);

JLabel lblNewLabel = new JLabel("Let's get Time");
lblNewLabel.setBounds(117, 25, 209, 39);
lblNewLabel.setFont(new Font("Microsoft JhengHei Light", Font.PLAIN, 28));
getContentPane().add(lblNewLabel);

JLabel lblHours = new JLabel("H");
lblHours.setBounds(59, 162, 69, 64);
lblHours.setFont(new Font("Aldhabi", Font.PLAIN, 66));
lblHours.setHorizontalAlignment(SwingConstants.CENTER);
getContentPane().add(lblHours);

JLabel labelMinute = new JLabel("M");
labelMinute.setBounds(182, 162, 69, 64);
labelMinute.setFont(new Font("Aldhabi", Font.PLAIN, 65));
labelMinute.setHorizontalAlignment(SwingConstants.CENTER);
getContentPane().add(labelMinute);

JLabel labelSecond = new JLabel("S");
labelSecond.setBounds(298, 162, 69, 64);
labelSecond.setFont(new Font("Aldhabi", Font.PLAIN, 66));
labelSecond.setHorizontalAlignment(SwingConstants.CENTER);
getContentPane().add(labelSecond);

JPanel panelHours = new JPanel();
panelHours.setBounds(59, 162, 69, 75);
panelHours.setBackground(new Color(192, 192, 192));
getContentPane().add(panelHours);

JPanel panelMinute = new JPanel();
panelMinute.setBounds(182, 162, 69, 75);
panelMinute.setBackground(new Color(192, 192, 192));
getContentPane().add(panelMinute);

JPanel panelSecond = new JPanel();
panelSecond.setBounds(298, 162, 69, 75);
panelSecond.setBackground(new Color(192, 192, 192));
getContentPane().add(panelSecond);

JButton btnHourP = new JButton("");
btnHourP.setBackground(Color.WHITE);
btnHourP.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcibW.jpg"));
btnHourP.setBounds(69, 103, 47, 48);
btnHourP.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

lblHours.setText(lg.hourP());
h=lblHours.getText();
btnHourP.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfci.jpg"));



}
});
getContentPane().add(btnHourP);

JButton btnMinuteP = new JButton("");
btnMinuteP.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcibW.jpg"));
btnMinuteP.setBounds(192, 103, 47, 48);
btnMinuteP.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

labelMinute.setText(lg.minuteP());
m=labelMinute.getText();
btnMinuteP.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfci.jpg"));
}
});
getContentPane().add(btnMinuteP);

JButton btnSecondP = new JButton("");

btnSecondP.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcibW.jpg"));
btnSecondP.setBounds(308, 103, 47, 48);
btnSecondP.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

labelSecond.setText(lg.secondP());
s=labelSecond.getText();
btnSecondP.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfci.jpg"));

}
});
getContentPane().add(btnSecondP);

JButton btnHourM = new JButton("");
btnHourM.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcibWdown.jpg"));
btnHourM.setBounds(69, 248, 47, 48);
btnHourM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

lblHours.setText(lg.hourM());
h=lblHours.getText();
btnHourM.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcidown.jpg"));
}
});
getContentPane().add(btnHourM);

JButton btnMiniuteM = new JButton("");
btnMiniuteM.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcibWdown.jpg"));
btnMiniuteM.setBounds(192, 248, 47, 48);
btnMiniuteM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

labelMinute.setText(lg.minuteM());
m=labelMinute.getText();
btnMiniuteM.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcidown.jpg"));

}
});
getContentPane().add(btnMiniuteM);

JButton btnSecondM = new JButton("");
btnSecondM.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcibWdown.jpg"));
btnSecondM.setBounds(308, 248, 47, 48);
btnSecondM.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

labelSecond.setText(lg.secondM());
s=labelSecond.getText();
btnSecondM.setIcon(new ImageIcon("C:\\Users\\Ali\\Desktop\\pic for project\\mmZEfcidown.jpg"));
}
});
getContentPane().add(btnSecondM);

JLabel lblStndTime = new JLabel("");
lblStndTime.setFont(new Font("Sitka Subheading", Font.PLAIN, 32));
lblStndTime.setBounds(117, 345, 206, 34);
lblStndTime.setHorizontalAlignment(SwingConstants.LEFT);
getContentPane().add(lblStndTime);

JLabel lblUniTime = new JLabel("");
lblUniTime.setFont(new Font("Sitka Subheading", Font.PLAIN, 32));
lblUniTime.setBounds(117, 390, 206, 34);
lblUniTime.setHorizontalAlignment(SwingConstants.LEFT);
getContentPane().add(lblUniTime);

JButton btnNewButton = new JButton("Click Me");

btnNewButton.setBackground(SystemColor.menu);
btnNewButton.setFont(new Font("Microsoft YaHei Light", Font.PLAIN, 21));
btnNewButton.setBounds(146, 463, 139, 64);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//
try
{

 h2=Integer.parseInt(h);
 m2=Integer.parseInt(m);
 s2=Integer.parseInt(s);


lblStndTime.setText(lg.stnTime(h2,m2,s2));
lblUniTime.setText(lg.universalTime(h2,m2,s2));
}
catch(java.lang.NumberFormatException ex)
{
btnNewButton.setForeground(Color.RED);
btnNewButton.setText("Invalid");
}
}

});
getContentPane().add(btnNewButton);

JLabel lblO = new JLabel("o");
lblO.setBounds(127, 175, 55, 25);
lblO.setVerticalAlignment(SwingConstants.TOP);
lblO.setHorizontalAlignment(SwingConstants.CENTER);
lblO.setFont(new Font("Tahoma", Font.BOLD, 20));
getContentPane().add(lblO);

JLabel label = new JLabel("o");
label.setBounds(249, 175, 55, 25);
label.setVerticalAlignment(SwingConstants.TOP);
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font("Tahoma", Font.BOLD, 20));
getContentPane().add(label);

JLabel label_1 = new JLabel("o");
label_1.setBounds(117, 211, 75, 25);
label_1.setVerticalAlignment(SwingConstants.TOP);
label_1.setHorizontalAlignment(SwingConstants.CENTER);
label_1.setFont(new Font("Tahoma", Font.BOLD, 20));
getContentPane().add(label_1);

JLabel label_2 = new JLabel("o");
label_2.setVerticalAlignment(SwingConstants.TOP);
label_2.setHorizontalAlignment(SwingConstants.CENTER);
label_2.setFont(new Font("Tahoma", Font.BOLD, 20));
label_2.setBounds(249, 212, 55, 25);
getContentPane().add(label_2);

JPanel panel = new JPanel();
panel.setBorder(UIManager.getBorder("FormattedTextField.border"));
panel.setBounds(36, 86, 359, 219);
getContentPane().add(panel);

JPanel panel_1 = new JPanel();
panel_1.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
panel_1.setBackground(SystemColor.menu);
panel_1.setBounds(69, 334, 289, 48);
getContentPane().add(panel_1);

JPanel panel_2 = new JPanel();
panel_2.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
panel_2.setBackground(SystemColor.menu);
panel_2.setBounds(69, 390, 289, 48);
getContentPane().add(panel_2);

}
}

Comments

Popular posts from this blog

Operating System | Best Definition of Opetating System

Umbrella activities in Software Engineering