Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

liliy

  • 3 years ago

I need to make a GUI and display the correct time under a clock. How do I center the time Text ?

  • This Question is Closed
  1. OttoMan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    in what programming language?

  2. liliy
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    java

  3. OttoMan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    So you want to create a GUI and show the time, have I understood it right?

  4. OttoMan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Go ahead and create two classes Main and GUI ---Main Class---- import javax.swing.JFrame; public class Main { public static void main(String args[]){ displayGUI(); } public static void displayGUI(){ JFrame window = new JFrame(); window.setTitle("Display Clock"); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setResizable(false); new GUI(window); } } ---Class Main END---- ---Class GUI--- import java.awt.Container; import javax.swing.RootPaneContainer; public class GUI{ public GUI(RootPaneContainer rpc){ Container cp = rpc.getContentPane(); Container rootWindow = (Container) rpc; cp.setLayout(null); rootWindow.setSize(500,500); rootWindow.setVisible(true); } } ---Class GUI End--- Now you have an empty GUI, one you get this working let me know and we can process onto displaying clock.

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy