• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I can't read clearly the label of my JButton?

 
Tom Barns
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I'm creating an an applet with swing component and for some reason i can't read the labe of my JButton,just it looks as group off dots.
please any explanation
thanks.
Here is the code
code:
//----------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SwingApplet extends JApplet
{
public void init()
{
Container c =getContentPane();
JButton b1 = new JButton("Hello World");
c.add(b1);

}
}
//-------------------
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom,
What size is specified in the applet tag of your html? In this code the button takes up the entire area provided for the applet, and if the size of the applet is smaller than the label on the button ( and some border area ) only a small slice of the label will appear. (Which are probably the "dots".)
HTH,
-Nate
 
Aayush Patel
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey u can set the actionevent on button and used method button.getActionCommand will return label of that button...
b.addActionListener();
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
}
hope it will work fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic