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 / September 2004

Tip: Looking for answers? Try searching our database.

JSpinner size problem

Thread view: 
Steven T Abell - 08 Sep 2004 20:15 GMT
I made a JSpinner with the height of a JTextField with the default font.
The spin buttons don't size down correctly,
ending up in the layout about twice the height of the textfield.
I've applied various forms of arm-twisting without results.
Is this a known bug, or is there a trick, or am I just doing it wrong?

Steve
Andrew Thompson - 08 Sep 2004 20:23 GMT
> I made a JSpinner with the height of a JTextField with the default font.
> The spin buttons don't size down correctly,
> ending up in the layout about twice the height of the textfield.
> I've applied various forms of arm-twisting without results.

Try posting compileable code, that is
both more productive, *and* less painful..
<http://www.physci.org/codes/sscce.jsp>

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Steven T Abell - 08 Sep 2004 20:56 GMT
>>I made a JSpinner with the height of a JTextField with the default font.
>>The spin buttons don't size down correctly,
[quoted text clipped - 4 lines]
> both more productive, *and* less painful..
> <http://www.physci.org/codes/sscce.jsp>

There's always the possibility that someone already knows the problem,
but here it is:

import    javax.swing.*;
import    javax.swing.border.*;

public static void main(String[] avs)
{
JSpinner oSpinner = new JSpinner();
oSpinner.setBorder(new TitledBorder("Spinner"));
JPanel oPanel = new JPanel();
oPanel.setLayout(new BorderLayout());
oPanel.add(oSpinner,BorderLayout.NORTH);
JFrame oFrame = new JFrame();
oFrame.setContentPane(oPanel);
oFrame.show();
}
Andrew Thompson - 08 Sep 2004 21:30 GMT
>> <http://www.physci.org/codes/sscce.jsp>
..
> There's always the possibility that someone already knows the problem,

Very true (and noted in the document), but
it does help get people's interest and help..

> but here it is:

Well.. no.  Did you actually try compiling that?
I *went* to do so, but the moment came when I
went to save it as it's class name and..

After making a few 'tweaks I came up with this
(that actually does compile).

<sscce>
import java.awt.BorderLayout;
import  javax.swing.*;
import  javax.swing.border.*;

public class SpinnerHeightTest {

 public static void main(String[] avs)
 {
 JSpinner oSpinner = new JSpinner();
 oSpinner.setBorder(new TitledBorder("Spinner"));
 JPanel oPanel = new JPanel();
 oPanel.setLayout(new BorderLayout());
 oPanel.add(oSpinner,BorderLayout.NORTH);
 JFrame oFrame = new JFrame();
 oFrame.setContentPane(oPanel);

 // oFrame.show();  //deprecated in 1.5
 oFrame.setVisible(true);
 // always a good idea
 oFrame.pack();
 }
}
</sscce>

Before the call to pack() the UI was only
the title bar, after, I did not observe the
behaviour you described.  Using WinXp and
Java 1.5.0 beta, the JSpinner seemed the size
I would expect of a JTextField.

(shrugs)  Back to you.

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Steven T Abell - 08 Sep 2004 23:02 GMT
> Did you actually try compiling that?

I copied it out of the file in which I wrote it.
Within the class defined there, it does compile and run.

> Before the call to pack() the UI was only
> the title bar, after, I did not observe the
[quoted text clipped - 3 lines]
>
> (shrugs)  Back to you.

I'm using XP and 1.4.2.
I dug deeper into the bug database, found something similar.
In 1.4.2, JSpinner's sizing machinery doesn't account for borders.
I've treated the problem by embedding the spinner in a panel,
then putting the border on the panel.
Paul Lutus - 09 Sep 2004 06:08 GMT
> I made a JSpinner with the height of a JTextField with the default font.
> The spin buttons don't size down correctly,
> ending up in the layout about twice the height of the textfield.
> I've applied various forms of arm-twisting without results.
> Is this a known bug, or is there a trick, or am I just doing it wrong?

How could we possibly know? Personally, my crystal ball is somewhat dirty
and it isn't letting me see the code you didn't post.

Signature

Paul Lutus
http://www.arachnoid.com



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



©2008 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.