List of usage examples for java.awt Color YELLOW
Color YELLOW
To view the source code for java.awt Color YELLOW.
Click Source Link
From source file:SystemTrayDemo2.java
public static void main(String[] args) { if (!SystemTray.isSupported()) { return;/*w ww.ja va2 s .co m*/ } SystemTray tray = SystemTray.getSystemTray(); Dimension size = tray.getTrayIconSize(); BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); Graphics g = bi.getGraphics(); g.setColor(Color.blue); g.fillRect(0, 0, size.width, size.height); g.setColor(Color.yellow); int ovalSize = (size.width < size.height) ? size.width : size.height; ovalSize /= 2; g.fillOval(size.width / 4, size.height / 4, ovalSize, ovalSize); try { PopupMenu popup = new PopupMenu(); MenuItem miExit = new MenuItem("Exit"); ActionListener al; al = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Goodbye"); System.exit(0); } }; miExit.addActionListener(al); popup.add(miExit); TrayIcon ti = new TrayIcon(bi, "System Tray Demo #2", popup); al = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(e.getActionCommand()); } }; ti.setActionCommand("My Icon"); ti.addActionListener(al); MouseListener ml; ml = new MouseListener() { public void mouseClicked(MouseEvent e) { System.out.println("Tray icon: Mouse clicked"); } public void mouseEntered(MouseEvent e) { System.out.println("Tray icon: Mouse entered"); } public void mouseExited(MouseEvent e) { System.out.println("Tray icon: Mouse exited"); } public void mousePressed(MouseEvent e) { System.out.println("Tray icon: Mouse pressed"); } public void mouseReleased(MouseEvent e) { System.out.println("Tray icon: Mouse released"); } }; ti.addMouseListener(ml); MouseMotionListener mml; mml = new MouseMotionListener() { public void mouseDragged(MouseEvent e) { System.out.println("Tray icon: Mouse dragged"); } public void mouseMoved(MouseEvent e) { System.out.println("Tray icon: Mouse moved"); } }; ti.addMouseMotionListener(mml); tray.add(ti); } catch (AWTException e) { System.out.println(e.getMessage()); return; } }
From source file:EditableColorColumn.java
public static void main(String args[]) { Color choices[] = { Color.red, Color.orange, Color.yellow, Color.green, Color.blue, Color.magenta }; ComboTableCellRenderer renderer = new ComboTableCellRenderer(); JComboBox comboBox = new JComboBox(choices); comboBox.setRenderer(renderer);/* w w w.j a v a 2 s . c om*/ TableCellEditor editor = new DefaultCellEditor(comboBox); JFrame frame = new JFrame("Editable Color Table"); TableModel model = new ColorTableModel(); JTable table = new JTable(model); TableColumn column = table.getColumnModel().getColumn(3); column.setCellRenderer(renderer); column.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(table); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(400, 150); frame.setVisible(true); }
From source file:ComplexRenderingSample.java
public static void main(String args[]) { Object elements[][] = {/*from ww w . ja v a 2 s.co m*/ { new Font("Helvetica", Font.PLAIN, 20), Color.red, new DiamondIcon(Color.blue), "Help" }, { new Font("TimesRoman", Font.BOLD, 14), Color.blue, new DiamondIcon(Color.green), "Me" }, { new Font("Courier", Font.ITALIC, 18), Color.green, new DiamondIcon(Color.black), "I'm" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.gray, new DiamondIcon(Color.magenta), "Trapped" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.pink, new DiamondIcon(Color.yellow), "Inside" }, { new Font("Courier", Font.BOLD, 16), Color.yellow, new DiamondIcon(Color.red), "This" }, { new Font("Helvetica", Font.ITALIC, 8), Color.darkGray, new DiamondIcon(Color.pink), "Computer" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); JList jlist = new JList(elements); ListCellRenderer renderer = new ComplexCellRenderer(); jlist.setCellRenderer(renderer); JScrollPane scrollPane = new JScrollPane(jlist); contentPane.add(scrollPane, BorderLayout.CENTER); JComboBox comboBox = new JComboBox(elements); comboBox.setRenderer(renderer); contentPane.add(comboBox, BorderLayout.NORTH); frame.setSize(300, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String... args) { JTextPane tPane = new JTextPane(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); appendToPane(tPane, "this is a test.\n", Color.RED, Color.WHITE); appendToPane(tPane, "this is a test \n", Color.PINK, Color.BLUE); appendToPane(tPane, "test", Color.GRAY, Color.BLACK); appendToPane(tPane, "test", Color.RED, Color.BLUE); appendToPane(tPane, "test", Color.RED, Color.YELLOW); f.getContentPane().add(tPane);// ww w .j ava2 s. c o m f.pack(); f.setVisible(true); }
From source file:ColorAction.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("SeparateGUITest"); frame.setSize(300, 200);//from w ww. j a v a 2 s. c om frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JPanel panel = new JPanel(); Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.blue, panel); Action yellowAction = new ColorAction("Yellow", new ImageIcon("yellow-ball.gif"), Color.yellow, panel); Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.red, panel); panel.add(new JButton(yellowAction)); panel.add(new JButton(blueAction)); panel.add(new JButton(redAction)); panel.registerKeyboardAction(yellowAction, KeyStroke.getKeyStroke(KeyEvent.VK_Y, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); panel.registerKeyboardAction(blueAction, KeyStroke.getKeyStroke(KeyEvent.VK_B, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); panel.registerKeyboardAction(redAction, KeyStroke.getKeyStroke(KeyEvent.VK_R, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); Container contentPane = frame.getContentPane(); contentPane.add(panel); JMenu m = new JMenu("Color"); m.add(yellowAction); m.add(blueAction); m.add(redAction); JMenuBar mbar = new JMenuBar(); mbar.add(m); frame.setJMenuBar(mbar); frame.show(); }
From source file:ColorComboBox.java
public static void main(String args[]) { Color colors[] = { Color.black, Color.blue, Color.cyan, Color.darkGray, Color.gray, Color.green, Color.lightGray, Color.magenta, Color.orange, Color.pink, Color.red, Color.white, Color.yellow }; JFrame frame = new JFrame("Color JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); final JComboBox comboBox = new JComboBox(colors); comboBox.setMaximumRowCount(5);//from w ww . jav a2 s .c o m comboBox.setEditable(true); comboBox.setRenderer(new ColorCellRenderer()); Color color = (Color) comboBox.getSelectedItem(); ComboBoxEditor editor = new ColorComboBoxEditor(color); comboBox.setEditor(editor); contentPane.add(comboBox, BorderLayout.NORTH); final JLabel label = new JLabel(); label.setOpaque(true); label.setBackground((Color) comboBox.getSelectedItem()); contentPane.add(label, BorderLayout.CENTER); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Color selectedColor = (Color) comboBox.getSelectedItem(); label.setBackground(selectedColor); } }; comboBox.addActionListener(actionListener); frame.setSize(300, 200); frame.setVisible(true); }
From source file:SystemTrayDemo1.java
public static void main(String[] args) throws Exception { if (!SystemTray.isSupported()) { return;/* www .j av a 2 s. c o m*/ } SystemTray tray = SystemTray.getSystemTray(); PropertyChangeListener pcl; pcl = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { System.out.println("Property changed = " + pce.getPropertyName()); TrayIcon[] tia = (TrayIcon[]) pce.getOldValue(); if (tia != null) { System.out.println("Old tray icon array contents: "); for (int i = 0; i < tia.length; i++) System.out.println(tia[i]); System.out.println(); } tia = (TrayIcon[]) pce.getNewValue(); if (tia != null) { System.out.println("New tray icon array contents: "); for (int i = 0; i < tia.length; i++) System.out.println(tia[i]); System.out.println(); } } }; tray.addPropertyChangeListener("trayIcons", pcl); Dimension size = tray.getTrayIconSize(); BufferedImage bi = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); Graphics g = bi.getGraphics(); g.setColor(Color.blue); g.fillRect(0, 0, size.width, size.height); g.setColor(Color.yellow); int ovalSize = (size.width < size.height) ? size.width : size.height; ovalSize /= 2; g.fillOval(size.width / 4, size.height / 4, ovalSize, ovalSize); TrayIcon icon = null; tray.add(icon = new TrayIcon(bi)); Thread.sleep(3000); tray.remove(icon); Thread.sleep(3000); System.exit(0); }
From source file:Main.java
public static void main(String[] args) { UIManager.put("ComboBox.background", new ColorUIResource(Color.yellow)); UIManager.put("JTextField.background", new ColorUIResource(Color.yellow)); UIManager.put("ComboBox.selectionBackground", new ColorUIResource(Color.magenta)); UIManager.put("ComboBox.selectionForeground", new ColorUIResource(Color.blue)); new Main();/*from w w w . ja v a 2 s . c om*/ }
From source file:ComplexCellRenderer.java
public static void main(String args[]) { Object elements[][] = { { new Font("Helvetica", Font.PLAIN, 20), Color.RED, new MyIcon(), "A" }, { new Font("TimesRoman", Font.BOLD, 14), Color.BLUE, new MyIcon(), "A" }, { new Font("Courier", Font.ITALIC, 18), Color.GREEN, new MyIcon(), "A" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.GRAY, new MyIcon(), "A" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.PINK, new MyIcon(), "A" }, { new Font("Courier", Font.BOLD, 16), Color.YELLOW, new MyIcon(), "A" }, { new Font("Helvetica", Font.ITALIC, 8), Color.DARK_GRAY, new MyIcon(), "A" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ListCellRenderer renderer = new ComplexCellRenderer(); JComboBox comboBox = new JComboBox(elements); comboBox.setRenderer(renderer);// ww w . ja va 2 s. co m frame.add(comboBox, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ComplexCellRenderer.java
public static void main(String args[]) { Object elements[][] = { { new Font("Helvetica", Font.PLAIN, 20), Color.RED, new MyIcon(), "A" }, { new Font("TimesRoman", Font.BOLD, 14), Color.BLUE, new MyIcon(), "A" }, { new Font("Courier", Font.ITALIC, 18), Color.GREEN, new MyIcon(), "A" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.GRAY, new MyIcon(), "A" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.PINK, new MyIcon(), "A" }, { new Font("Courier", Font.BOLD, 16), Color.YELLOW, new MyIcon(), "A" }, { new Font("Helvetica", Font.ITALIC, 8), Color.DARK_GRAY, new MyIcon(), "A" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(elements); ListCellRenderer renderer = new ComplexCellRenderer(); jlist.setCellRenderer(renderer);/*from w ww. j ava 2s .c o m*/ JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }