Where is this method from? I've tried looking for it and i cant find it. The only example i've seen it used in was where JPanel is extended and it is called in the constructor. The problem is i do not want to extend JPanel so how do i go about creating an object(my question is what class) so that i can access this method? I don't know where JPanel inherited this method from.
JComponent panel1 = makeTextPanel("Panel");
tabs.addTab("Display", panel1);
http://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html
It is from here: TabbedPaneDemo.java
which can be found under the heading: "Code for Tabbed Panes" on that page .
protected Component makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
You don't have to extend anything. You can make it static
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.