Advertisement
Guest User

Untitled

a guest
Mar 14th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. package layout_managers;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5. import java.awt.event.*;
  6. import java.util.Calendar;
  7.  
  8. public class GUI_Clock extends JFrame {
  9.     JPanel timeDisplay;
  10.     JLabel hours, minutes, seconds, am_pm;
  11.  
  12.     public GUI_Clock() {
  13.         setLayout(new GridLayout(2, 1));
  14.         hours = new JLabel();
  15.         hours.setBackground(Color.RED);
  16.         hours.setVisible(true);
  17.         minutes = new JLabel();
  18.         minutes.setBackground(Color.BLUE);
  19.         minutes.setVisible(true);
  20.         seconds = new JLabel();
  21.         seconds.setBackground(Color.GREEN);
  22.         seconds.setVisible(true);
  23.         am_pm = new JLabel();
  24.         am_pm.setBackground(Color.WHITE);
  25.         am_pm.setVisible(true);
  26.        
  27.         timeDisplay = new JPanel(new GridLayout(1, 3));
  28.         timeDisplay.add(hours);
  29.         timeDisplay.add(minutes);
  30.         timeDisplay.add(seconds);
  31.         //timeDisplay.add(am_pm);
  32.         add(timeDisplay);
  33.         add(am_pm);
  34.        
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement