Jbutton text shows as "..." unless tiny font or huge button

I am having trouble getting the text labels to show on my JButtons unless I make the text fontsize very small or make the button size very large.
What am I missing here?
Thanks in advance,
Greg C.
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class MyWindow extends JFrame
    implements ActionListener
  private static Container contentPane;
  public static final int WIDTH  = 259; //
  public static final int HEIGHT = 259; // 
  /* constructor *****************************************************/
  public MyWindow()
    super();
    setSize(WIDTH, HEIGHT);
    setTitle("JButton Test"); // how do we change the associated icon ?
    setResizable(false);      // locks in setSize d dimensions
    contentPane = getContentPane();
    this.makeButtons();
    try
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      SwingUtilities.updateComponentTreeUI(this);
    catch (Exception e)
      System.out.println("ERROR - NOT GOOD !!!");
  public void makeButtons() {
    setBackground(Color.green);  // fer kicks
    Font theFont = new Font("Arial", Font.BOLD, 12);
    setFont(theFont);
   MyWindow.contentPane.setLayout(null);
    int butX = 50;
    int butY = 75;
    int butW = 52; // 32 this is the Width I need!
    int butH = 48; // 28 this is the Height I need!
    Color color = Color.red;
    int fontSize = 12; // 12 this is the font size I need
    JButton m1 = formatButton("MC",color,fontSize,
                              butX,butY,
                              butW, butH);  // shows "MC"
    contentPane.add(m1);
    JButton m2 = formatButton("MC",color,fontSize, // same string
                              butX, butY+70,
                              butW-1, butH);  // -1 shows "..."
    contentPane.add(m2);
  public JButton formatButton(String s, Color fColor, int fSize,
                              int x, int y,
                              int w, int h)  {
    JButton temp = new JButton(s);
    temp.setForeground(fColor);
    temp.setFont(new Font("Arial", Font.PLAIN, fSize));
    temp.setBounds(x,y,w,h); // x,y,width, height
    temp.addActionListener(this);
    return temp;
  public void actionPerformed(ActionEvent g) {
}  // end class MyWindow

When you disable LayoutManagers (setLayout(null)) you yourself have to make sure everything has the proper size and location.
This is mostly thought of as BAD, as you'll leave no room for i18n or resizing.
The ... is a JButton "feature" to show that it's text does not fit (although the dots themselves may not fit).
All the advice given in other posts assume you have a LayoutManager (setPreferredSize() etc.), which you don't.

Similar Messages

  • TCS3 Frame Conditionl text causing tiny fonts in RH Topics

    With a linked FrameMaker book, in the Conversion Settings dialog box > Other Settings, I've selected Apply FrameMaker Conditional Text Build Expression. In FrameMaker I've selected Show as per Expression.
    The results are disappointing. In apparently random paragraphs in topics that include conditional text, RH is inserting this in the html:
    <span style="font-size: 4.0pt;">
    Sometimes it inserts it alone, and sometimes it includes it with other extraneous information such as:
    <span style="font-style: normal; font-weight: normal;
    font-size: 4.0pt; letter-spacing: 0.00em;">
    There are no paragraph ovrrides in any of these instances, and it only happens when Apply FrameMaker Conditional Text Build Expression is selected. I could build my expressions in Robohelp, but I'd prefer to manage conditions in Frame for reasons such as excluding many sections (topics in RH) that are conditionalized as "print only." With this check box selected, they don't appear in RH; but without it selected, I'd need to conditionalize the topic again in RH.
    Any thoughts?

    I just wanted to update in case anyone else has a similar issue.
    The problem has gone away and I'm not entirely sure how I did it. I suspect it has to do with how I displayed the conditional text in FrameMaker. Typically I'll just use the Show/Hide dialog box to move conditions to the Show or Hide areas. When I instead built an expression that excluded the conditions (e.g, NOT"Cond1"ANDNOT"Cond2" etc), the problems with the tiny fonts ended. Interestingly, the problem persisted when I built expressions that included conditions.

  • I have somehow messed up the display when in Hotmail. This app shows in a very tiny font. No other internet applications are affected. How can I fix this?

    The window opens but the actual application appears in tiny font in the middle of the page.

    Reset the page zoom on pages that cause problems: <b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    * http://kb.mozillazine.org/Zoom_text_of_web_pages

  • Java 7 Update 7 and 9 on Mac Lion OS 10.7.4 - Applet printing tiny fonts

    As of Java 7, when you go to print from an Applet the fonts are no longer readable (super tiny). A preview of the same on content on the screen is not an issue only show a font issue when you print the contents.
    To see this failure in action you can test using this page:
    [applet demo|https://www.peernet.com/PEERNETReportsServer3/ademos.htm]
    On this page,:
    1) press the preview button to show the page to be printed
    2) press the 'Print...' button, print to any printer and you see the textual information is just printed as dashes (super tiny font).
    Any suggestions on how to correct Java 7 printing from applets.
    BTW: Works fine from a full Java application.
    Edited by: 967205 on 23-Oct-2012 8:07 AM

    Hi Jen,
    I am having the same issue, from what i am reading and understanding is apple and there in genius ideas decided to block Java because its apparently a security risk - a joke i know!
    see i had my course materail for tafe all working then i decided to do the update that kept popping up since then it doesnt work, i installed java 7 update 17 on my old mac book pro and it works perfectly the only thing that is different between those 2 is safari my imac is running 6.0.3 and my macbook is still on the one before that..
    i am still currently working on a way to enable this again unless apple relise that this was a completly stupid idea and come to there sens before i come up with away then ill keep you updated when i get it working
    so for those who are reading this and havent updated yet my advise if you need java for online games or course materail or anything really DONT UPDATE
    thanks
    mel

  • JButton text not displaing on applet startup

    I'm having a problem with the text of a button not showing up when the applet starts up. It just has the button with the background and the text doesn't show up until you mouse over the button (not by design). It only happens on startup and it's not consistant. It seems to only happen in Internet Explorer, but not in Firefox. I'm using the java plugin Version 1.5.0 (build 1.5.0_02-b09) and internet explorer 6.0.2800.1106. Here's the java code for the button:
    public class AdminViewApplet extends JApplet implements ActionListener {
         private static final long serialVersionUID = 1L;
         private static final String ADMIN_VIEW_URL = "/admin/view";
         private static final String LOGIN_ID = "loginId";
         private static final String TOKEN = "token";
         private static final String EXCEPTION = "exception";
         public void init() {
              Color backgroundColor = new Color(204,204,204);
              JButton adminViewButton = new JButton("Admin View");
    adminViewButton.addActionListener(this);
              adminViewButton.setFont(new Font("Helvetica", Font.PLAIN, 11));
              adminViewButton.setMargin(new Insets(5, 5, 5, 5));
              adminViewButton.setBackground(backgroundColor); adminViewButton.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    JPanel pane = new JPanel(new GridLayout(1,1,0,0));
              pane.setBackground(backgroundColor);
    pane.add(adminViewButton);
    setContentPane(pane);
    public void actionPerformed(ActionEvent event) { ... }
    Here's the applet tag in the jsp:
         <applet archive="admin-view-applet.jar" code="com.healthpartners.share.applet.AdminViewApplet" width="80" height="28">
                        <param name="effectiveAccountId" value="<%= accountData.getAccountId() %>"></param>
                        <param name="realAccountId" value="<%= HPEnvironmentFactory.getHPEnvironment().getAccount(request.getUserPrincipal()).getAccountId() %>"></param>
                   </applet>
    Any help would be appreciated!
    Thanks,
    Tim

    Try compiling on 1.4.2. I've had to drop 1.5 as it was getting too buggy, when I was using different browsers and OSs.

  • No text showing up on iTunes tried reinstalling started today

    Starting today there is no text showing up on my iTunes I have tried reinstalling and nothing is working I haven't updated or anything don't know why the sudden issue

    That's consistent with trouble with the Segoe UI fonts on your system.
    If you're using Windows XP or Windows Vista, try Vortical's technique from the following post:
    Re: iTunes 10.1 Missing Text
    But if you're using Windows 7, try itunesTRK's suggestion from the following post:
    menu bar invisible

  • How do I retain Jbutton text for action event & set img icon on Jbutton

    I need to retain the text on my button as I use this to identify the action event in actionPerformed method when the button is pressed.
    Hoe do I add an image icon to the Jbutton without effecting this?
    [/b]
    class CalcPanel extends JPanel
        implements ActionListener, CurrencyVals
    //currency panel data members
        JButton[] cb = new JButton[4];
    JPanel cbkeys = new JPanel(new GridLayout(4,1));
    //Toolkit tk = Toolkit.getDefaultToolkit();
        //Image img = tk.getImage("D:/temp/ausflag.jpg");
    public CalcPanel(){
    ImageIcon b = new ImageIcon("D:/temp/ausflag.jpg","AUS");
        cb[AUS]= new JButton(b);  //cb[AUS]= new JButton("AUS");
          cbkeys.add(cb[AUS]);
          cb[AUS].addActionListener(this);
    setLayout(new BorderLayout());
        add(display, BorderLayout.NORTH);
        add(keys, BorderLayout.CENTER);
        add(cbkeys, BorderLayout.EAST);
        add(label, BorderLayout.SOUTH);
        public void actionPerformed(ActionEvent evt){
          Object source = evt.getSource();
          int id;
          if (keyBoard) {
            if (source instanceof JButton) {
              String s = ((JButton)source).getText();
    [/b]Regards
    Synfield

    if(keyBoard) { ??! [/b]... do have cause to feel flattered?
    Copy and paste this and save a small eg;- 25px high x 50px wide Jpeg image in the same file and call it "new.jpg", then study it, this posted program (again?) to see where your code went astray.
    THEN, figure out what you want to do with your code ...keep at it!
    Sue x
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ButtonIcon extends JFrame implements ActionListener {
    String []str ={"abc","def","ghi","jkl","mno","pqr","st","uvw"};
    JButton b[] = new JButton[str.length];
       JButton on = new JButton("ON");
       JButton off = new JButton("OFF");
       JButton picture;
       JPanel panel;
       String str2="";
       Font font = new Font("Comic Sans MS" ,0, 14);
       boolean keyBoard;
       ImageIcon icon = new ImageIcon("new.jpg");
    public ButtonIcon(){
       Container c = getContentPane();
       panel = new JPanel();
       panel.setLayout(new FlowLayout());
       picture = new JButton(icon);
       for (int j=0; j<=str.length-1; j++){
             b[j]= new JButton(str[j]);
             b[j].setFont(font);
             panel.add(b[j]);
             b[j].addActionListener(this);
       on.addActionListener(this);
       off.addActionListener(this);
       panel.add(on);
       panel.add(off);
       panel.add(picture);
       c.add(panel);
       public void paint (Graphics g) {
          super.paint (g);
          Graphics2D G = (Graphics2D) g;
          G.setColor(Color.red);
          G.setFont(font);
          G.drawString(str2, 25, 150);
    public void actionPerformed(ActionEvent evt){
        String command = evt.getActionCommand();
        if (keyBoard) {
           if (evt.getSource() instanceof JButton ) {
               str2 += command;
           if (evt.getActionCommand().equals("OFF")) str2 = "";
        if(command.equals("ON")) keyBoard = true;
        if(command.equals("OFF")) keyBoard = false;
    repaint();
    public static void main (String []args){
       ButtonIcon boo = new ButtonIcon();
       boo.setSize(300,200);
       boo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
       boo.setVisible(true);

  • Conditional text showing as white space w/ condition indicators On

    We are using condition indicators with both a color
    and an overline, underline, strikethrough, etc. When
    we have the condition indcators on, and do Show All,
    some text shows up as white space until we change
    the indicators. Unfortunately, the behavior is not
    consistent in that when I change an Overline to As Is
    with some colors (like the standard Red or Blue),
    the text remains whtte. It's only if I alaso change
    the color to one of the custom colors we are using
    for headings that we can actually see the text.
    A similar disappearance is happening with cross
    references that use a charaacter tag Hyperlink
    with standard Blue as the color (no underline) in
    the cross ref format. The text tagged with Hyperlink
    disappears while black text (Default para font) shows
    up. If we change the cross Ref format to use a different
    character tag, it shows up.
    Track changges is Off. It has neer been turned on.
    Bug or feature?

    Sodal, I tried and I got a "Missing arguments for command '\position'."
    I had used a field on bottom of page 1 before but I got a "field not found on subform CONT" error.
    Does anything else come to mind.  Thanks!!

  • Tiny font on Menu Bar & on window when using Apple Mail on new Macbook Air

    I have a new MacBook Air and all is good - except my Mail window has tiny fonts, including on the tool bar, and the Menu Bar is also has smaller fonts when Mail is active. I have made the actual messages readable but the rest of the screen is almost too small to read.

    I just got my new MacBook Air and I was also really, really disappointed that the menu bar fonts - and all default text sizes in general - are much too small. I wonder if it has to do with the fact that the optimal resolution for the monitor is now 1440x900 instead of 1280x800 as it was in the older MacBook Air models. I guess I just have to go to the optician and get myself a pair of glasses...
    But I think this is clearly a design -related problem that Apple should fix asap!

  • Why does text show differently (vertical alignment) when viewed on a PC than on a Mac?

    The text shows misaligned (different) when viewed on different platforms (Mac or PC)
    The Menu section on this website ~> Menu
    Is there a way around this or a fix it. I was trying to look at the code in Dreamweaver and I did see some weird (>Span<) tags, I'm wondering if it might have to do with it.
    The goal is to align the right side (prices) perfectly. I even had to do the 'tracking' individually to every line. It does work, depending on what platform I'm working on, if I work and publish from a Mac, it would look fine no matter what browser I use, but when viewed on a PC the text gets misaligned. The same happens if I work and publish from a PC, it would show misaligned on a Mac.
    Hope there is a reasonable explanation for this.
    - Thank you,
    Ricardo

    The primary cause of the misalignment is the fact the text is using a "Web Safe" font. A "web safe" font is not a single font. Rather it's a list/stack of fonts for the site visitor's browser to try until it finds one that's available the visitor's computer. That means on one computer the text is in one font (i.e. Arial) and on another computer it's another (i.e. Helvetica) with the subsequent fallout caused by the varying character widths between the two fonts. The best way to reduce this variation between site viewers is to use a Web Font (either an Edge Web Font or a Self-Hosted Web Font).
    The alignment still won't be entirely consistent across browsers (or even versions of browsers), because each browser has it's own text layout engine and the engines do sometime change, but the variation will be radically reduced.

  • JButton not showing

    Hi all, I've tried really hard to figure this one out and am just not getting it.
    All I want to do is add a JButton to a JPanel and then add that panel to the ContentPane of a JApplet. The button doesn't show though, unless I add it directly to the ContentPane.
    I know this is really basic stuff and I've done it successfully many times in the past and now, even after reviewing code that works, I can't figure out why this doesn't.
    Please help. :)
    Thanks much.

    Thanks, it didn't seem to work though. Below is the reduced code for testing:
    JApplet:
    public void init(){
    setBounds(0,0,500,500);
    panelControl=new WebCamControlPanel(this);
    setContentPane(panelControl);
    }//end init
    JPanel:
    public WebCamControlPanel(JApplet applet){
    button=new JButton("Save");
    add(button);
    All the instance vars are declared as you'd expect and it compiles fine. I had to type this in instead on copy/paste so forgive any typos or trivial errors. I burnt out ;-)
    Any help is welcome.
    Thanks:)

  • A tiny font is used in many places across Java Swing applications (help!)

    In many places in Java but mostly in text boxes I'm seeing a very small font that is quite hard to read.
    I am seeing this all over the place in Java programs and it is getting on my nerves.
    I'm not sure what is causing this.
    I also encountered this issue when running Java on Windows XP.
    I really need help on how to solve this,
    Or maybe it is actually a bug with Java itself and Windows?
    An image of the problem in SwingSet2:
    [SwingSet 2 Tiny Font Example|http://img687.imageshack.us/img687/1373/swingset2tinyfont.png]
    System spec:
    Windows 7 Professional 32-bit (Aero is on)
    Java 6 Update 20
    English system locale and language
    No special dpi settings (default)
    Screen Resolution: 1280x1024
    Avast Antivirus 5.0
    An intel graphics card
    Edited by: Temp111 on May 9, 2010 7:38 AM

    camickr wrote:
    That is not a problem. Somewhere in that code the programmer uses setFont(....) to make it a smaller font. The default font of a text component does not behave like that.
    For more help create a [SSCCE (Short, Self Contained, Compilable and Executable, Example Program)|http://sscce.org/], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.No, it's defiantly a problem. Probably in the default fonts that Swing uses in some places.
    I detected one place where I can easily trigger this issue, a JTextArea And the Windows Look and Feel, So here is a SSCCE for you:
    [Picture Of Tiny Font SSCCE With Tiny Font issue|http://img88.imageshack.us/img88/7876/tinyfont.png]
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    public class TinyFont {
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              } catch (ClassNotFoundException e) {
                   e.printStackTrace();
              } catch (InstantiationException e) {
                   e.printStackTrace();
              } catch (IllegalAccessException e) {
                   e.printStackTrace();
              } catch (UnsupportedLookAndFeelException e) {
                   e.printStackTrace();
              JFrame frame = new JFrame("Tiny Font");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JTextArea textArea = new JTextArea("Tiny Font Test");
              frame.add(textArea);
              frame.setSize(150, 100);
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
    }But I also encountered this issue in other places that use Swing.
    Try SwingSet2 Source Code Tab for example: [SwingSet2|http://java.sun.com/products/jfc/jws/SwingSet2.jnlp]

  • Tiny font issue.. unacceptable!

    For some reason, in many Java apps I visit, the font is illegible. See URLs below for example screenshots:
    http://www.samhulick.com/smallfont1.gif
    http://www.samhulick.com/smallfont2.gif
    As you can see in the second screenshot, some of the text is OK, but most is not.
    What's wrong with this? This happens in both IE6 and Mozilla 1.3beta. here's the Java version info:
    JRE 1.4.1_02
    Default Virt. Machine 1.4.1_02-b06
    Java Plugin 1.4.1_02

    What do you mean? That's just a cropped image from my screenshot. Those two GIFs were screenshots of Java apps running on my home computer. What you see is what you get.. that's actually what displays on my screen.
    So how do I resolve this? How can I get the Java applets to show an actual legible font size??

  • WML, XHTML, Tiny Fonts 5800. Am I barking up the w...

    Fellow Nokkers, Spend a lot of time on the BBC Mobile site but while sport pages responds to the Font Size settings the news sections doesn't. I need an Electron Microscope to read the tiny tiny font.
    Why might BBC Sport and News react differently? Is it me, the phone or the BBC? Or is it my wifes fault?
    Thanks for any help because the internet is so much less usefull when you can't read.... Cheers Tim.

    Can anyone help with my 3 Pixel Jog Error I get when I run a Browser Compatibility check in DW CS3? The error would show up in IE 6. I am currently connecting my site to a web host. In the meantime, I would like to try to get this one error corrected that I have. Thanks!

  • How can I prevent my texts showing on another family members iPhone?

    How can I prevent my texts showing on another family members iPhone?

    Stop using the same apple ID for iMessage on both phones.
    Your question has already been asked and answered many many times. Search before posting please.

Maybe you are looking for