Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ SimpleTabbedPane.java

  • Loading branch information...
commit 8cfd2a32adba3c1fb029121e19003b1d8d5013ef 1 parent 4d7b51d
@ReneNyffenegger authored
Showing with 52 additions and 0 deletions.
  1. +52 −0 java/swing/JComponent/JTabbedPane/SimpleTabbedPane.java
View
52 java/swing/JComponent/JTabbedPane/SimpleTabbedPane.java
@@ -0,0 +1,52 @@
+import javax.swing.*;
+import java .awt .*;
+
+public class SimpleTabbedPane extends JFrame {
+
+ void addTab(String text, JTabbedPane tabPane) {
+
+ JPanel panel = new JPanel(false);
+ JLabel label = new JLabel("Label: " + text);
+
+ label.setHorizontalAlignment(JLabel.CENTER);
+
+ panel.setLayout(new GridLayout(1, 1));
+ panel.add(label);
+
+ tabPane.addTab("Tab " + text, panel);
+ }
+
+
+ SimpleTabbedPane() {
+ super("Simple Tabbed Pane");
+
+ JTabbedPane tabPane = new JTabbedPane();
+
+ // Make tabs scrollable
+ tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+
+ addTab("foo", tabPane);
+ addTab("bar", tabPane);
+ addTab("baz", tabPane);
+
+ for (int q=1 ; q < 20; q++) {
+ addTab(Integer.toString(q), tabPane);
+ }
+
+ JPanel pane = new JPanel(new GridLayout(1, 1));
+ pane.add(tabPane);
+
+
+ add(pane, BorderLayout.CENTER);
+
+ pack();
+
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ setSize(400,100);
+ setVisible(true);
+ }
+
+ public static void main(String[] args) {
+ new SimpleTabbedPane();
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.