File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes RadioButtons & JLabels not showing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "RadioButtons & JLabels not showing" Watch "RadioButtons & JLabels not showing" New topic
Author

RadioButtons & JLabels not showing

Jean-francois Le Bas
Greenhorn

Joined: Aug 16, 2012
Posts: 10
hi

i created a component which extends a JDialog. It creates a JPanel (with a big size) inside a JScrollPane. Then i add RadioButtons and JLabels to the JPanel

two problems :
1 - the RadioButtons and JLabels don't show.
2 - the scrollBars of the JScrollPane don't show

here is my code :



thanks for your help
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36501
    
  16
You have some peculiar naming there. Classes should start with capital letters. You are using the name of an existing class (JOptionPane) as part of a class which appears not to extend it.
What on earth does myFrame = this; mean? That looks very very strange. You appear to be adding the dialog to itself.
What sort of layout are you applying to the component you are adding the radio buttons to?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

You shouldn't add(...) the panel (or any other component) to the scroll pane. For the correct approach, read the API for JScrollPane and follow the link to the tutorial on How to Use Scroll Panes.

Also, learn to follow Java coding conventions. Class names should start with an uppercase letter; variable names with a lowercase letter. And BeForthrightWhenCrossPostingToOtherSites: http://stackoverflow.com/questions/11984457/why-arent-my-radiobuttons-jlabels-showing

luck, db
There are no new questions, but there may be new answers.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36501
    
  16
And welcome to the Ranch
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
typical first-time poster - "I want an answer, and I want it now - bugger anyone wasting their time, not my problem"

I see you have your answer here
http://stackoverflow.com/questions/11984457/why-arent-my-radiobuttons-jlabels-showing

well, next time you have a problem, my thoughts will be "bugger you, I'm not wasting my time giving you a solution, not my problem".
i.e. what goes around, comes around.

[edit]
must be a time-delay lock here :-)
Jean-francois Le Bas
Greenhorn

Joined: Aug 16, 2012
Posts: 10
@Campbell Ritchie :
You have some peculiar naming there. Classes should start with capital letters.

okay i fixed this thanks for the notice. I will do this in the future now.

You are using the name of an existing class (JOptionPane) as part of a class which appears not to extend it.

it's just the name of the class. I called it that way because it look a little bit like a JOptionPane, nothing more

What on earth does myFrame = this; mean? That looks very very strange. You appear to be adding the dialog to itself.

it's just the same as typing simply: add(component) or this.add(component) but i prefer that way.

What sort of layout are you applying to the component you are adding the radio buttons to?

it's the standart layout the Flow Layout or do i have to specify a Layout?.

@Darryl Burke:
You shouldn't add(...) the panel (or any other component) to the scroll pane. For the correct approach, read the API for JScrollPane and follow the link to the tutorial on How to Use Scroll Panes.

okay so now i created the JScrollPane with passing the panel to the constructor but it's the same problem, nothing appears:

typical first-time poster - "I want an answer, and I want it now - bugger anyone wasting their time, not my problem"

don't think that way
since yesterday i tried to make the damn RadioButtons appears and it's a long time when you're doing only this.
that's why i neeed help. I didn't pass 5 min on it without looking for an answer.
i tried with no Layouts at all and i could show the radiobuttons but only when i pass the mouse over (strange!)
i tried every combination possible and looked over dozens of questions

so please if you can get this thing working, let me know. If you don't know, no problem.

And welcome to the Ranch

thanks!

Jeff
Jean-francois Le Bas
Greenhorn

Joined: Aug 16, 2012
Posts: 10
okay so i found how to solve it

for people who are looking for an answer to the same question:

simply replace
paneScroll.add(paneScrollpanel);
with
paneScroll.setViewportView(paneScrollpanel);

and now everyting works! the labels are displayed, the buttons also and the big panel is finally scrollable!

i spent a lot of time looking for an answer but i never found this tip!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RadioButtons & JLabels not showing
 
Similar Threads
Alignment Issue
urgent:override a jrame
JTree: Setting node to be a JPanel
Please Help in sorting JTable on multiple column.
Some code about GUI