java - How to make a scrollable Jpanel inside a JTabbedPanel? -
i'm trying make jframe
contains jtabbedpane
. there 3 tabs , each tab has panel inside it. first panel (aka first tab) must have 3 elements positioned vertically: jlabel
, picture , text area. tabs must visible @ top while contents of tab can scrolled through. no matter tried (windowbuilder, other stackoverflow answers) can't seem make work.
without code have tried, can give example.
// tabbed pane jtabbedpane tabbedpane = new jtabbedpane(jtabbedpane.top); contentpane.add(tabbedpane, borderlayout.center); // first panel jpanel pan1 = new jpanel(new gridlayout(3, 1)); // content of first panel jlabel lbl1 = new jlabel("test1"); pan1.add(lbl1); jtextfield textfield_3 = new jtextfield(); textfield_3.setcolumns(10); pan1.add(textfield_3); jtextfield textfield_4 = new jtextfield(); textfield_4.setcolumns(10); pan1.add(textfield_4); // second panel jpanel pan2 = new jpanel(new gridlayout(3, 1)); // content of second panel jlabel lbl2 = new jlabel("test2"); pan2.add(lbl2); // first scroll pane jscrollpane scrollpane1 = new jscrollpane(pan1); // second scroll pane jscrollpane scrollpane2 = new jscrollpane(pan2); tabbedpane.add("tab1", scrollpane1); tabbedpane.add("tab2", scrollpane2);
change panel's content labels, pictures etc. change layout, too. if provide code, can give exact solution.
Comments
Post a Comment