Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I am unable to see the fields inside my frame

 
sampath surineni
Greenhorn
Posts: 29
Android Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm coding an alarm application.
I have a snooze class which gets called when the alarm sounds. It used to work fine before using JMF.But after using JMF I see only the outer frame of my snooze UI.

I tried starting a new thread for the class but got the same result. I'm pasting here code of the classes in which I think the problem is in.

Please help me solve the problem.

IsTime class. Which checks whether it is the time to sound alarm.


Media class which plays song when it is time


Snooze class where the real problem is
 
Tony Docherty
Bartender
Posts: 2957
59
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you already have a JFrame displaying your clock you shouldn't be creating new JFrame for your snooze panel, you should be using a JDialog.
Your classes shouldn't extend Thread, they should implement Runnable.
You should call Swing methods like setVisible() on the Event Dispatch Thread.
 
sampath surineni
Greenhorn
Posts: 29
Android Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:If you already have a JFrame displaying your clock you shouldn't be creating new JFrame for your snooze panel, you should be using a JDialog.
Your classes shouldn't extend Thread, they should implement Runnable.
You should call Swing methods like setVisible() on the Event Dispatch Thread.


But Mr.Tony Docherty I was coding this app taking asource code as an example. They did the same thing and it is working there. I tried using runnable but the result is same. I didn't understand what you said by calling Swing methods like setVisible() on the Event Dispatch Thread. But there is a set visible method call in my constructor.

Sorry if I'm being foolish. I'm a beginner and thank you for reply
 
Tony Docherty
Bartender
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first two points are all about good Java coding practices. They are not essential to make it work.
The final point is critical: See the currency in swing tutorial
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic