Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

swing questions

Thread view: 
Manolis Christodoulou - 17 Jan 2004 17:22 GMT
First of all I would like to introduce myself. I'm not a professional
programer. I'm a medical doctor trying to make a swing ICD10 Code
Selection Tool (ICD10=International Classification of Diseases 10 -
W.H.O.). The whole ICD10 codes are in a HSQLDB database. No problem so
far. The Browser is based on a JDialog and is up and running. But I have
some esthetic problems I didn't make to solve so far, though I tried hard...

1) For every component I add to my JDialog, there is the following code
(for example with a JLabel status line)...

JLabel status=(new JLabel("Item not selected yet.") {
    public void paint(Graphics g) {
        ((Graphics2D)g).setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        super.paint(g);
    }
});

... in order to make the component have antialiased text in it.
Can this be done by default for the whole application? I tried to have
the same code in a JDialog derived class paint method, but didn't worked.

2) For every component that displays text I hava a line like this (the
same status component)...

status.setFont(new Font(null,Font.PLAIN,dpi));
/* ...where dpi is... */
int dpi = Toolkit.getDefaultToolkit().getScreenResolution()/8;

...and all this trouble because my screen resolution is 1600x1200 with
120dpi, and all fonts are too small. If I make them larger they will be
too large in a 1024x768 display. In my 120dpi screen the above method
gives 15 point fonts, while in a 96dpi screen gives 12point fonts.
Again, I wonder if this is the appropriate thing to do or there is
another more widely accepted method?

3) And the most annoying thing is with a JComboBox which is not editable
(it has a button in place of the editor part). I want the text on this
button to act like JLabel conserning wraping (I don't want to wrap text
to multiple lines). Any ideas?

Thanks in advance.
Andrew Thompson - 17 Jan 2004 18:13 GMT
...
| 1) For every component I add to my JDialog, there is the following code
| (for example with a JLabel status line)...

parts 1 & 2

JAliasLabel status = new JAliasLabel("Item not selected yet.");
...

class JAliasLabel extend JLabel
{
   int dpi =
Toolkit.getDefaultToolkit().getScreenResolution()/8;

   public JAliasLabel(String text)
   {
       super(text);
       setFont(new Font(null,Font.PLAIN,dpi));
   }

   public void paint(Graphics g) {
         ((Graphics2D)g).setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
         super.paint(g);
     }
}

HTH

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Manolis Christodoulou - 17 Jan 2004 20:02 GMT
> ...
> | 1) For every component I add to my JDialog, there is the
[quoted text clipped - 24 lines]
>       }
> }

Of course I'll do something like that, at a later time, if I won't find
a method to do it whithout have to derive every component I use.
Andrew Thompson - 17 Jan 2004 20:20 GMT
| > ...
| > | 1) For every component I add to my JDialog, there is the
[quoted text clipped - 4 lines]
| >
| > JAliasLabel status = new JAliasLabel("Item not selected yet.");

******* here is the important bit**************

JAliasLabel thisLabel = new JAliasLabel("Item not selected
yet.");
JAliasLabel thatLabel = new JAliasLabel("Item not selected
yet.");
JAliasLabel theOtherLabel = new JAliasLabel("Item not selected
yet.");

******that I forgot to point out in the original*******
| > ...
| >
[quoted text clipped - 19 lines]
| Of course I'll do something like that, at a later time, if I won't find
| a method to do it whithout have to derive every component I use.

Maybe that makes it more clear.  The point is,
if you declare a class that _extends_ JLabel,
you can create as many objects of it as you
like...

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Andrew Thompson - 17 Jan 2004 20:21 GMT
...
| Of course I'll do something like that, at a later time, if I won't find
| a method to do it whithout have to derive every component I use.

..and it is not a 'method', it is a 'class'
Andrew Thompson - 17 Jan 2004 20:28 GMT
If you are still unsure what I mean, you
can examine a concrete example of it here..
http://www.physci.org/launcher.jsp#JAnimateFrame

Alberto defined the Ball class (line 127), then
instantiated 5 ball objects within the
JAnimatePanel (line 54)..
Manolis Christodoulou - 17 Jan 2004 22:03 GMT
> If you are still unsure what I mean, you
> can examine a concrete example of it here..
[quoted text clipped - 3 lines]
> instantiated 5 ball objects within the
> JAnimatePanel (line 54)..

I'm pretty familiar with inheritance. The only reason I havn't done it
that way is that the code is in development stage. The thing I look for
is how to set[XXXX] things instead.
visionset - 18 Jan 2004 08:11 GMT
> The thing I look for
> is how to set[XXXX] things instead.

This is OO

--
Mike W
Manolis Christodoulou - 18 Jan 2004 01:09 GMT
>>The thing I look for
>>is how to set[XXXX] things instead.
>
> This is OO

ok, i give up :-)
Manolis Christodoulou - 18 Jan 2004 01:12 GMT
>>The thing I look for
>>is how to set[XXXX] things instead.
>
> This is OO

ok, i give up :-)

The other interesting thing I found out, concearnign my 3rd question, is
that the problem is with the HTML tags inside the displayed text. It
seems that don't work as expected.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.