List of usage examples for javax.swing JButton JButton
public JButton()
From source file:TitledPostBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop"); aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP); JButton aboveTopButton = new JButton(); aboveTopButton.setBorder(aboveTopBorder); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); JButton topButton = new JButton(); topButton.setBorder(topBorder);/*from w w w . j av a 2 s . c om*/ TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop"); belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP); JButton belowTopButton = new JButton(); belowTopButton.setBorder(belowTopBorder); TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom"); aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM); JButton aboveBottomButton = new JButton(); aboveBottomButton.setBorder(aboveBottomBorder); TitledBorder bottomBorder = BorderFactory.createTitledBorder("Bottom"); bottomBorder.setTitlePosition(TitledBorder.BOTTOM); JButton bottomButton = new JButton(); bottomButton.setBorder(bottomBorder); TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom"); belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM); JButton belowBottomButton = new JButton(); belowBottomButton.setBorder(belowBottomBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(3, 2)); contentPane.add(aboveTopButton); contentPane.add(aboveBottomButton); contentPane.add(topButton); contentPane.add(bottomButton); contentPane.add(belowTopButton); contentPane.add(belowBottomButton); frame.setSize(300, 200); frame.setVisible(true); }
From source file:TitledPostBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop"); aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP); JButton aboveTopButton = new JButton(); aboveTopButton.setBorder(aboveTopBorder); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); JButton topButton = new JButton(); topButton.setBorder(topBorder);/* w w w .j ava 2 s . co m*/ TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop"); belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP); JButton belowTopButton = new JButton(); belowTopButton.setBorder(belowTopBorder); TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom"); aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM); JButton aboveBottomButton = new JButton(); aboveBottomButton.setBorder(aboveBottomBorder); TitledBorder bottomBorder = BorderFactory.createTitledBorder("Bottom"); bottomBorder.setTitlePosition(TitledBorder.BOTTOM); JButton bottomButton = new JButton(); bottomButton.setBorder(bottomBorder); TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom"); belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM); JButton belowBottomButton = new JButton(); belowBottomButton.setBorder(belowBottomBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(3, 2)); contentPane.add(aboveTopButton); contentPane.add(aboveBottomButton); contentPane.add(topButton); contentPane.add(bottomButton); contentPane.add(belowTopButton); contentPane.add(belowBottomButton); frame.setSize(300, 200); frame.setVisible(true); }
From source file:DoubleTitle.java
public static void main(String args[]) { JFrame frame = new JFrame("Double Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT, TitledBorder.BOTTOM); JButton doubleButton = new JButton(); doubleButton.setBorder(doubleBorder); Container contentPane = frame.getContentPane(); contentPane.add(doubleButton, BorderLayout.CENTER); frame.setSize(300, 100);//from www.j a v a2s.co m frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Tabbed Pane Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Label"); label.setPreferredSize(new Dimension(1000, 1000)); JScrollPane jScrollPane = new JScrollPane(label); JButton jButton1 = new JButton(); jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane.setViewportBorder(new LineBorder(Color.RED)); jScrollPane.getViewport().add(jButton1, null); frame.add(jScrollPane, BorderLayout.CENTER); frame.setSize(400, 150);// w w w . j av a 2 s . co m frame.setVisible(true); }
From source file:DoubleTitle.java
public static void main(String args[]) { JFrame frame = new JFrame("Double Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT, TitledBorder.BOTTOM); JButton doubleButton = new JButton(); doubleButton.setBorder(doubleBorder); Container contentPane = frame.getContentPane(); contentPane.add(doubleButton, BorderLayout.CENTER); frame.setSize(300, 100);//w w w. jav a 2 s. co m frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Double Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT, TitledBorder.BOTTOM); JButton doubleButton = new JButton(); doubleButton.setBorder(doubleBorder); Container contentPane = frame.getContentPane(); contentPane.add(doubleButton, BorderLayout.CENTER); frame.setSize(300, 100);/*from www . ja v a 2s .c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton(); InputMap map = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); list(map, map.keys());/*from w ww .j a v a 2 s. c om*/ list(map, map.allKeys()); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(800, 600);/*from w ww . j a v a2 s . c om*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); device.setFullScreenWindow(frame); device.setDisplayMode(new DisplayMode(800, 600, 32, 60)); frame.setVisible(true); JButton btn = new JButton(); btn.setText("Button"); JPanel panel = new JPanel(); panel.add(btn); frame.add(panel); btn.addActionListener(e -> { JOptionPane.showMessageDialog(frame.getContentPane(), "JOptionPane"); }); }
From source file:AncestorSampler.java
public static void main(String args[]) { JFrame frame = new JFrame("Ancestor Sampler"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AncestorListener ancestorListener = new AncestorListener() { public void ancestorAdded(AncestorEvent ancestorEvent) { System.out.println("Added"); }/*from w w w.j a v a 2s . com*/ public void ancestorMoved(AncestorEvent ancestorEvent) { System.out.println("Moved"); } public void ancestorRemoved(AncestorEvent ancestorEvent) { System.out.println("Removed"); } }; JButton bn = new JButton(); bn.addAncestorListener(ancestorListener); frame.add(bn); //frame.remove(bn); frame.setSize(300, 200); frame.setVisible(true); }