• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

RadioButtons & JLabels not showing

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 80634
471
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 80634
471
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic