List of usage examples for javax.swing JButton JButton
public JButton()
From source file:MultiClickThreshholdDemo.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AbstractButton bn = new JButton(); bn.setMultiClickThreshhold(1000);/* www . j a v a2 s . c o m*/ bn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("action"); } }); frame.add(bn); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JButton button = new JButton(); Main f = null;//ww w .j a v a 2s . co m f = new Main(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(700, 400); panel1.setLayout(new BorderLayout()); panel1.setForeground(Color.white); button.setText("Convert"); panel1.add(button, BorderLayout.SOUTH); f.setContentPane(panel1); f.setVisible(true); f1 = new Main(); f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f1.setSize(457, 100); f1.setTitle("Conversion Progress"); f1.setLocationRelativeTo(null); panel2.setLayout(new BorderLayout()); panel2.setForeground(Color.white); JProgressBar progressBar = new JProgressBar(); progressBar.setValue(35); progressBar.setStringPainted(true); panel2.add(progressBar, BorderLayout.SOUTH); f1.setContentPane(panel2); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { f1.setVisible(true); } }); }
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout(5, 5)); int sz = 4;/*from w w w .j a v a 2 s . c om*/ Container content = new JPanel(new GridLayout(sz, 0, 2, 2)); for (int f = 0; f < sz * sz; f++) { content.add(new JButton()); } gui.add(content, BorderLayout.CENTER); Container info = new JPanel(new FlowLayout(FlowLayout.CENTER, 50, 5)); info.add(new JLabel("Flow")); info.add(new JLabel("Layout")); gui.add(info, BorderLayout.PAGE_START); gui.add(new JLabel("Label"), BorderLayout.LINE_END); JOptionPane.showMessageDialog(null, gui); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder leftBorder = BorderFactory.createTitledBorder("Left"); leftBorder.setTitleJustification(TitledBorder.LEFT); JButton leftButton = new JButton(); leftButton.setBorder(leftBorder);/*w w w . ja v a 2 s . c o m*/ Container contentPane = frame.getContentPane(); contentPane.add(leftButton); frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final 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); Container contentPane = frame.getContentPane(); contentPane.add(aboveTopButton);/* ww w . j a va2s . co m*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder centerBorder = BorderFactory.createTitledBorder("Center"); centerBorder.setTitleJustification(TitledBorder.CENTER); JButton centerButton = new JButton(); centerButton.setBorder(centerBorder); Container contentPane = frame.getContentPane(); contentPane.add(centerButton);// w w w . ja v a 2 s . c o m frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop"); belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP); JButton belowTopButton = new JButton(); belowTopButton.setBorder(belowTopBorder); Container contentPane = frame.getContentPane(); contentPane.add(belowTopButton);//from w w w .ja v a 2 s . c o m frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom"); belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM); JButton belowBottomButton = new JButton(); belowBottomButton.setBorder(belowBottomBorder); Container contentPane = frame.getContentPane(); contentPane.add(belowBottomButton);/* w ww .j a v a 2s . c o m*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom"); aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM); JButton aboveBottomButton = new JButton(); aboveBottomButton.setBorder(aboveBottomBorder); Container contentPane = frame.getContentPane(); contentPane.add(aboveBottomButton);/*from w ww .j av a 2 s . c o m*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:TitledJustBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder leftBorder = BorderFactory.createTitledBorder("Left"); leftBorder.setTitleJustification(TitledBorder.LEFT); JButton leftButton = new JButton(); leftButton.setBorder(leftBorder);//from www.j a v a 2 s . co m TitledBorder rightBorder = BorderFactory.createTitledBorder("Right"); rightBorder.setTitleJustification(TitledBorder.RIGHT); JButton rightButton = new JButton(); rightButton.setBorder(rightBorder); TitledBorder centerBorder = BorderFactory.createTitledBorder("Center"); centerBorder.setTitleJustification(TitledBorder.CENTER); JButton centerButton = new JButton(); centerButton.setBorder(centerBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(3, 1)); contentPane.add(leftButton); contentPane.add(rightButton); contentPane.add(centerButton); frame.setSize(300, 200); frame.setVisible(true); }