Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-26-2008, 07:46 AM
Member
 
Join Date: Jul 2008
Posts: 3
tanmoy.b81 is on a distinguished road
JApplet Problem
hello everybody,

I am new to this forum as well as in AWT/Swing. I am facing a problem and do not know how to solve this problem.

My code :

Code:
import java.awt.*; import javax.swing.*; public class NewClass extends JApplet{ public void init() { JButton jb = new JButton("Send"); jb.setVisible(true); getContentPane().add(jb); } public void paint(Graphics g) { g.drawString("Hello",10,10); } }
Now my problem is first time the button is not visible, when I am moving the mouse pointer on that area then the button is being visible.

Why it is happening like this?

Please help me out..........

Thanks in advance...........................

Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-26-2008, 10:08 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,104
hardwired is on a distinguished road
Code:
// <applet code="NewClassApplet" width="400" height="400"></applet> import java.awt.*; import javax.swing.*; public class NewClassApplet extends JApplet { public void init() { JButton jb = new JButton("Send"); // This is useless here. //jb.setVisible(true); JPanel panel = new JPanel(); panel.add(jb); getContentPane().add(panel); // An alternate approach: //getContentPane().add(panel, "Last"); } public void paint(Graphics g) { // One of the few times you need to call // "super" in a paint method is if // the container has light-weight children. // This method will draw on top of children. super.paint(g); g.drawString("Hello",10,10); } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-28-2008, 07:56 AM
Member
 
Join Date: Jul 2008
Posts: 3
tanmoy.b81 is on a distinguished road
Thanks lot hardwired
hi hardwired,
Thanks a lot for replying me. It's working properly. I have posted this thread on various forums but nobody replied me. Thanks to u and this forum for solving my problem. It's really helpful for me.

Thanks again.............




Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JApplet problems Rgfirefly24 New To Java 2 04-24-2008 08:36 PM
Database to JApplet Preethi New To Java 0 03-26-2008 06:18 AM
Another problem in JApplet :S juju Java Applets 2 12-30-2007 08:46 PM
help with converting to JApplet Simmy AWT / Swing 2 08-09-2007 09:45 AM
JApplet and html paty Java Applets 1 08-02-2007 06:41 PM


All times are GMT +3. The time now is 04:40 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org