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: 32599
4
posted
0
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?
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.
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: 9
posted
0
@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: 9
posted
0
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.