(original) (raw)
import java.awt.EventQueue; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JToolBar; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JRadioButton; public class TestButton { private JFrame frame; /** * Launch the application. */ public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } EventQueue.invokeLater(new Runnable() { public void run() { try { TestButton window = new TestButton(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public TestButton() { initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JToolBar toolBar = new JToolBar(); frame.getContentPane().add(toolBar, BorderLayout.NORTH); JButton btnNewButton = new JButton(new ImageIcon("testicon.png")); toolBar.add(btnNewButton); JButton btnNewButton_1 = new JButton("New button"); frame.getContentPane().add(btnNewButton_1, BorderLayout.CENTER); } }