List of usage examples for javax.swing.plaf.metal MetalIconFactory getTreeComputerIcon
public static Icon getTreeComputerIcon()
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Text Pos"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(2, 2)); Border border = LineBorder.createGrayLineBorder(); Icon warnIcon = MetalIconFactory.getTreeComputerIcon(); JLabel label1 = new JLabel(); label1.setText("Left-Bottom"); label1.setHorizontalTextPosition(JLabel.LEFT); label1.setVerticalTextPosition(JLabel.BOTTOM); label1.setBorder(border);/*w ww.j a va2s . c om*/ frame.add(label1); JLabel label2 = new JLabel(warnIcon); label2.setText("Right-TOP"); label2.setHorizontalTextPosition(JLabel.RIGHT); label2.setVerticalTextPosition(JLabel.TOP); label2.setBorder(border); frame.add(label2); JLabel label3 = new JLabel(warnIcon); label3.setText("Center-Center"); label3.setHorizontalTextPosition(JLabel.CENTER); label3.setVerticalTextPosition(JLabel.CENTER); label3.setBorder(border); frame.add(label3); JLabel label4 = new JLabel(warnIcon); label4.setText("Center-Bottom"); label4.setHorizontalTextPosition(JLabel.CENTER); label4.setVerticalTextPosition(JLabel.BOTTOM); label4.setBorder(border); frame.add(label4); frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Text Pos"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(2, 2)); Border border = LineBorder.createGrayLineBorder(); Icon warnIcon = MetalIconFactory.getTreeComputerIcon(); JLabel label1 = new JLabel(warnIcon); label1.setText("Left-Bottom"); label1.setHorizontalTextPosition(JLabel.LEFT); label1.setVerticalTextPosition(JLabel.BOTTOM); label1.setBorder(border);/*from w w w .ja v a2s.co m*/ frame.add(label1); JLabel label2 = new JLabel(warnIcon); label2.setText("Right-TOP"); label2.setHorizontalTextPosition(JLabel.RIGHT); label2.setVerticalTextPosition(JLabel.TOP); label2.setBorder(border); frame.add(label2); JLabel label3 = new JLabel(warnIcon); label3.setText("Center-Center"); label3.setHorizontalTextPosition(JLabel.CENTER); label3.setVerticalTextPosition(JLabel.CENTER); label3.setBorder(border); frame.add(label3); JLabel label4 = new JLabel(warnIcon); label4.setText("Center-Bottom"); label4.setHorizontalTextPosition(JLabel.CENTER); label4.setVerticalTextPosition(JLabel.BOTTOM); label4.setBorder(border); frame.add(label4); frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] a) { final int STRING_POSITION = 1; Object buttonColors[][] = { { Color.RED, "RED" }, { Color.BLUE, "BLUE" }, { Color.GREEN, "GREEN" }, { Color.BLACK, "BLACK" }, null, // separator { Color.CYAN, "CYAN" } }; JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ActionListener actionListener = new TheActionListener(); JToolBar toolbar = new JToolBar(); toolbar.setRollover(true);/* w w w .java 2s. c o m*/ for (Object[] color : buttonColors) { if (color == null) { toolbar.addSeparator(); } else { Icon icon = MetalIconFactory.getTreeComputerIcon(); JButton button = new JButton(icon); button.setActionCommand((String) color[STRING_POSITION]); button.addActionListener(actionListener); toolbar.add(button); } } Action action = new ShowAction(toolbar); JButton button = new JButton(action); toolbar.add(button); Container contentPane = frame.getContentPane(); contentPane.add(toolbar, BorderLayout.NORTH); JTextArea textArea = new JTextArea(); JScrollPane pane = new JScrollPane(textArea); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(350, 150); frame.setVisible(true); }