List of usage examples for javax.swing JFrame add
public Component add(Component comp)
From source file:Main.java
public static void main(String[] args) { JTextPane textPane = new JTextPane(); textPane.setText("12345678\n\t1\t2\t3a"); JScrollPane scrollPane = new JScrollPane(textPane); scrollPane.setPreferredSize(new Dimension(700, 100)); setTabs(textPane, 8);// w w w.j a v a2s.c o m JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scrollPane); frame.pack(); frame.setVisible(true); }
From source file:GradientsDirection.java
public static void main(String[] args) { JFrame frame = new JFrame("GradientsDirection"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new GradientsDirection()); frame.setSize(350, 350);/*from ww w . j a va 2s .co m*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel panel = new JPanel(); panel.setLayout(new OverlayLayout(panel)); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add("1", new JTextField("one")); tabbedPane.add("2", new JTextField("two")); tabbedPane.setAlignmentX(1.0f);//from ww w . j a v a 2 s .co m tabbedPane.setAlignmentY(0.0f); JCheckBox checkBox = new JCheckBox("Check Me"); checkBox.setOpaque(false); checkBox.setAlignmentX(1.0f); checkBox.setAlignmentY(0.0f); panel.add(checkBox); panel.add(tabbedPane); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel); frame.setLocationByPlatform(true); frame.setSize(400, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTextPane textPane = new JTextPane(); textPane.setText("This is a test string"); StyleConstants.setBold(BOLD, true); StyleConstants.setItalic(ITALIC, true); int start = 5; int end = 10; textPane.getStyledDocument().setCharacterAttributes(start, end - start, BOLD, false); textPane.getStyledDocument().setCharacterAttributes(start, end - start, ITALIC, false); for (int i = start; i < end; i++) System.out.println(/*from w ww . ja v a 2 s . co m*/ textPane.getStyledDocument().getCharacterElement(i).getAttributes().containsAttributes(BOLD)); // all now print true JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(textPane)); frame.pack(); frame.setVisible(true); }
From source file:NestedJSplitPane.java
public static void main(String[] a) { int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT; int VERTSPLIT = JSplitPane.VERTICAL_SPLIT; boolean continuousLayout = true; JLabel label1 = new JLabel("a"); JLabel label2 = new JLabel("b"); JLabel label3 = new JLabel("c"); JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2); splitPane1.setOneTouchExpandable(true); splitPane1.setDividerSize(2);/*from w ww . j ava 2 s .c o m*/ splitPane1.setDividerLocation(0.5); JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3); splitPane2.setOneTouchExpandable(true); splitPane2.setDividerLocation(0.4); splitPane2.setDividerSize(2); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(splitPane2); frame.pack(); frame.setVisible(true); }
From source file:GradientsRedYellow.java
public static void main(String[] args) { JFrame frame = new JFrame("GradientsRedYellow"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new GradientsRedYellow()); frame.setSize(350, 350);//from ww w. j av a2 s .c om frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("GradientsRedYellow"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Main()); frame.setSize(350, 350);// w w w . j a v a 2 s .c o m frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:SimpleDnD.java
public static void main(String[] args) { JTextField field = new JTextField(10); JButton button = new JButton("Button"); JFrame f = new JFrame(); f.setTitle("Simple Drag & Drop"); f.setLayout(new FlowLayout()); f.add(button); f.add(field);// ww w . jav a2 s. com field.setDragEnabled(true); button.setTransferHandler(new TransferHandler("text")); f.setSize(330, 150); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Scale.java
public static void main(String[] args) { JFrame frame = new JFrame("Scaling"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Scale()); frame.setSize(330, 160);/*from w w w .j ava 2s.c o m*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:TreeRowHeightCalculation.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.setRowHeight(0);// w w w. j a v a2 s. co m JFrame frame = new JFrame("tree row height calculation"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }