GUI: font size issue, and Preview not representative

View: New views
5 Messages — Rating Filter:   Alert me  

GUI: font size issue, and Preview not representative

by gwideman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi folks:

(If this is in an FAQ somewhere I didn't see, please point the way!)



Using NB 6.7.1 on Windows.  Example case: the supplied GUIFormExamples example.



In the IDE (GUI designer) the forms look fine, with what looks on Windows to be 8pt Tahoma labels, but set in the designer at 11pt Tahoma to achieve that effect.  I can hit the Preview button and they still look good.



But then I build and run the app outside the IDE, and the fonts render much larger: what had the appearance of Windows 8pt Tahoma in the designer and Preview now looks like 11pt Tahoma Bold when run independently.



If I revise the app to show captions in all point sizes from 8pt to 14pt, on running independently the 8pt is too small, 9,  10 and 11 are progressively larger, but then 12 and 13 are all about the same size as 11, with 11pt being bold and 12 and 13 being plain.  No rhyme or reason to this.



What do I need to know to make this behave properly?  Mainly to get the running app to look like it did in the IDE and Preview.  I understand that there are issues around Java rendering with the assumption of 72dpi, but Windows rendering at 96 dpi, but I don't understand why I see "Java-correct" (small size) rendering in the IDE, and then large and goofy rendering in the independently running app.



FWIW, Windows XP SP3, with Java 1.5.0_06 and Java 1.6.0_15 installed. NB's About box says:

Product Version: NetBeans IDE 6.7.1 (Build 200907230233)

Java: 1.5.0_06; Java HotSpot(TM) Client VM 1.5.0_06-b05

System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)



(Hmmm.. why is it using 1.5x and not 1.6x? Further puzzle!)



Thanks,



-- Graham





GUI: font size issue, and Preview not representative

by bhobiger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did you set the Windows LaF? If not try


Code:
        try {

            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        } catch (Exception ex) {

            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Error setting LaF", ex);

        }



at the beginning of your main method.





GUI: font size issue, and Preview not representative

by gwideman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


bhobiger wrote:
> Did you set the Windows LaF?




Thanks, that does appear to make the running app's fonts agree with how it looks in the designer (both on Windows). Haven't yet tried it on another platform to see what happens there.



FWIW, for anyone else who might stumble on this message:



1. I added the suggested code at the beginning of the main(...) method (for example in class ContactEditor).



2. Also had to add:

import javax.swing.*;

import java.util.logging.*;



3. Replaced "MainFrame" with the class of the main form in the example, eg: Logger.getLogger(ContactEditor.class.getName())....



-- Graham





Re: GUI: font size issue, and Preview not representative

by Tonny Kohar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Sun, Nov 1, 2009 at 6:22 PM, gwideman <initcontact@...> wrote:

> Hi folks:
>
> (If this is in an FAQ somewhere I didn't see, please point the way!)
>
>
>
> Using NB 6.7.1 on Windows.  Example case: the supplied GUIFormExamples example.
>
>
>
> In the IDE (GUI designer) the forms look fine, with what looks on Windows to be 8pt Tahoma labels, but set in the designer at 11pt Tahoma to achieve that effect.  I can hit the Preview button and they still look good.
>
>
>
> But then I build and run the app outside the IDE, and the fonts render much larger: what had the appearance of Windows 8pt Tahoma in the designer and Preview now looks like 11pt Tahoma Bold when run independently.
>
>
>
> If I revise the app to show captions in all point sizes from 8pt to 14pt, on running independently the 8pt is too small, 9,  10 and 11 are progressively larger, but then 12 and 13 are all about the same size as 11, with 11pt being bold and 12 and 13 being plain.  No rhyme or reason to this.
>
>
>
> What do I need to know to make this behave properly?  Mainly to get the running app to look like it did in the IDE and Preview.  I understand that there are issues around Java rendering with the assumption of 72dpi, but Windows rendering at 96 dpi, but I don't understand why I see "Java-correct" (small size) rendering in the IDE, and then large and goofy rendering in the independently running app.
>
>
>
> FWIW, Windows XP SP3, with Java 1.5.0_06 and Java 1.6.0_15 installed. NB's About box says:
>
> Product Version: NetBeans IDE 6.7.1 (Build 200907230233)
>
> Java: 1.5.0_06; Java HotSpot(TM) Client VM 1.5.0_06-b05
>
> System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
>
>
>
> (Hmmm.. why is it using 1.5x and not 1.6x? Further puzzle!)
>

I do not know much about the font rendering issues, because I didn't
experience it. However my wild guess is because you are using 2
different java between development (use Java 1.5) and running (use
Java 1.6)

You can easily change Netbeans to use Java 1.6 by
- Close Netbeans
- Go to [netbeans-install-dir]/etc
- edit the file called netbeans.conf (it is only text file)
- edit the entry netbeans_jdkhome="path to your jdk 1.6"
- Run Netbeans again and check the Help-About to see whether this time
Netbeans use intended jdk version

Cheers
Tonny Kohar
--
Sketsa SVG Editor
imagine, design, create ...
http://www.kiyut.com

GUI: font size issue, and Preview not representative

by gwideman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

As noted before, the font issue was addressed by the look-and-feel controller.

But on the 1.5 vs 1.6 issue:

yes, I later discovered that part of the confusion was over the netbeans About box message:

Java: 1.5.0_06; Java HotSpot(TM) Client VM 1.5.0_06-b05

"Java" is ambiguous... it's actually reporting which vM/JRE is in use, and not mentioning anything about the JDK that NB is or isn't using.  The info is not wrong, just incomplete in a confusing way, because it doesn't convey that NB needs a JDK, it has found one (not mentioned here), and has (I think) found the JRE that goes with it.

So it turned out that I had installed JRE 1.6 but not JDK 1.6 (since I hadn't realized that the JDK was needed).  I had a previous install of JDK/JRE 1.5 still installed, and though I was expecting NB to use the latest "Java", instead it used 1.5 because that was the latest *JDK* it found.

Anyhow.... I uninstalled all java and NB related stuff, then installed 1.6 JDK, then installed NB, and all worked fine.  No doubt I did not need to uninstall to get to that point (could probably have updated NB's jdk_home conf variable), but I needed to tidy up install locations anyway.

Thanks for your reply, and I hope this note helps others stumbling along this path.

Graham