List of usage examples for javax.swing JButton JButton
public JButton(Action a)
Action
supplied. From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton("button"); InputMap map = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); list(map, map.keys());// ww w . j av a 2 s.c o m list(map, map.allKeys()); }
From source file:ABevelBorderLoweredBevelBorderRAISED.java
public static void main(String args[]) { JFrame frame = new JFrame("Bevel Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border myRaisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.PINK, Color.RED); // Border myLoweredBorder = BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.PINK, // Color.RED); JButton button = new JButton("Raised"); button.setBorder(myRaisedBorder);//from w ww. java 2 s . c o m frame.add(button); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JButton component = new JButton("button"); InputMap map = component.getInputMap(JComponent.WHEN_FOCUSED); list(map, map.keys());/*from ww w.j a v a 2 s . c o m*/ list(map, map.allKeys()); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(new Dimension(500, 500)); JDialog dialog = new JDialog(frame, "Export", ModalityType.MODELESS); dialog.setSize(300, 300);/*from w w w . java2 s .c o m*/ JDialog dialog1 = new JDialog(dialog, "Export", ModalityType.APPLICATION_MODAL); dialog1.setSize(200, 200); frame.add(new JButton(new AbstractAction("Dialog") { @Override public void actionPerformed(ActionEvent e) { frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dialog.setVisible(true); dialog1.setVisible(true); } })); frame.setVisible(true); }
From source file:PropertySplitPane.java
public static void main(String args[]) { JFrame frame = new JFrame("Property Split"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); JComponent topComponent = new JButton("A"); splitPane.setTopComponent(topComponent); JComponent bottomComponent = new JButton("B"); splitPane.setBottomComponent(bottomComponent); PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent changeEvent) { JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource(); String propertyName = changeEvent.getPropertyName(); if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) { int current = sourceSplitPane.getDividerLocation(); System.out.println("Current: " + current); Integer last = (Integer) changeEvent.getNewValue(); System.out.println("Last: " + last); Integer priorLast = (Integer) changeEvent.getOldValue(); System.out.println("Prior last: " + priorLast); }/*from w w w. j a v a2s . c o m*/ } }; splitPane.addPropertyChangeListener(propertyChangeListener); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Focus Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField);//from ww w. ja va2s .c o m frame.add(label, BorderLayout.WEST); frame.add(textField, BorderLayout.CENTER); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String... args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel contentPane = new JPanel(); contentPane.setOpaque(true);//ww w . j a v a 2s.c o m contentPane.setBackground(Color.WHITE); contentPane.setLayout(null); JLabel label = new JLabel("This JPanel uses Absolute Positioning", JLabel.CENTER); label.setSize(300, 30); label.setLocation(5, 5); JButton button = new JButton("USELESS"); button.setSize(100, 30); button.setLocation(95, 45); contentPane.add(label); contentPane.add(button); frame.setContentPane(contentPane); frame.setSize(310, 125); frame.setLocationByPlatform(true); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel userLabel = new JLabel("User Name"); JLabel passLabel = new JLabel("Password"); JTextField userText = new JTextField(20); JPasswordField passText = new JPasswordField(20); JButton loginButton = new JButton("Login"); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(4, 4, 4, 4); gbc.gridx = 0;/*from w w w . jav a2 s. c o m*/ gbc.gridy = 0; gbc.fill = GridBagConstraints.NONE; panel.add(userLabel, gbc); gbc.gridx = 1; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(userText, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.fill = GridBagConstraints.NONE; panel.add(passLabel, gbc); gbc.gridx = 1; gbc.gridy = 1; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(passText, gbc); gbc.gridx = 0; gbc.gridy = 2; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; gbc.gridwidth = 2; panel.add(loginButton, gbc); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new JScrollPane(panel)); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel ui = new JPanel(new BorderLayout(20, 20)); ui.setBorder(new LineBorder(Color.RED, 1)); JTextField fileName = new JTextField(); ui.add(fileName, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new GridLayout(1, 0, 10, 30)); ui.add(buttonPanel, BorderLayout.CENTER); JButton creater = new JButton("Create File"); buttonPanel.add(creater);/*w w w . ja v a 2 s. co m*/ JButton deleter = new JButton("Delete File"); buttonPanel.add(deleter); JOptionPane.showMessageDialog(null, ui); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("UIDefaults Example"); frame.setDefaultCloseOperation(3);//ww w . j ava2 s . c o m Container c = frame.getContentPane(); UIManager.put("Button.background", Color.red); UIManager.put("Button.foreground", Color.white); Font f = new Font("Serif", Font.ITALIC, 24); UIManager.put("Button.font", f); JButton north = new JButton("North"); JButton south = new JButton("South"); JButton east = new JButton("East"); JButton west = new JButton("West"); JButton center = new JButton("Center"); c.add(north, BorderLayout.NORTH); c.add(south, BorderLayout.SOUTH); c.add(east, BorderLayout.EAST); c.add(west, BorderLayout.WEST); c.add(center, BorderLayout.CENTER); frame.pack(); frame.show(); }