Re: help needed @ JScrollpane on JTabbedpane
vikas talwar wrote:
Hi All,
I have created a JPanel object.
JPanel my_panel = new JPanel();
I have many component added on this JPanel object.
Now, I have make JScrollPane.
JScrollpane my_scroll = new JScrollpane(my_panel);
NOw my problem is with default Layout, I'm getting my component (at
JPanel) in vertical row.
You didn't say what layout you expected to see.
and when I use 'my_panel.setLayout(null)', my JScrollpane is not
working.
I'd *expect* layout not to work very well if you use a null layout. YMMV.
Please tell me if I'm not clear with my question.
OK. You are not clear with your question. :-)
In most programming newsgroups, if you have trouble clearly expressing
your problem in English, I find it best to express the problem in
program source code instead.
I'd write some complete minimal code that demonstrates the problem. For
example, the following example works* for me:
import javax.swing.*;
public class ScrollPanelApp {
private static void createAndShowGUI() {
JPanel panel = new JPanel();
panel.add(new JButton("Foo"));
panel.add(new JButton("Bar"));
panel.add(new JButton("Baz"));
panel.add(new JButton("Qux"));
panel.add(new JButton("Ok"));
panel.add(new JButton("Cancel"));
JScrollPane scrollpane = new JScrollPane(panel);
JFrame frame = new JFrame("Horizontal scrolling buttons");
frame.add(scrollpane);
frame.setBounds(100,100, 300, 200);
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() { createAndShowGUI(); }
});
}
}
It is only 22 lines (including the optional extra added
thread-safetiness) surely you could boil down your problem to a
similarly small example that people can look at and run?