Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RadioButtons & JLabels not showing

 
Jean-francois Le Bas
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic