Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

liliy

  • one year 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
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    in what programming language?

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

    java

  3. OttoMan
    • one year 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
    • one year 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

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.