List of usage examples for java.awt Color blue
Color blue
To view the source code for java.awt Color blue.
Click Source Link
From source file:SystemTrayDemo1.java
public static void main(String[] args) throws Exception { if (!SystemTray.isSupported()) { return;/* www . ja v a 2 s. co 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:G2DCircleIntersectPDF.java
public static void main(String[] args) { Document document = new Document(); try {//ww w .j ava2 s. c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("G2DCircleIntersectPDF.pdf")); document.open(); DefaultFontMapper mapper = new DefaultFontMapper(); FontFactory.registerDirectories(); mapper.insertDirectory("c:\\windows\\fonts"); int w = 150; int h = 150; PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(w, h); Graphics2D g2 = tp.createGraphics(w, h, mapper); tp.setWidth(w); tp.setHeight(h); double ew = w / 2; double eh = h / 2; Ellipse2D.Double circle, circle1; circle = new Ellipse2D.Double(ew - 16, eh - 29, 50.0, 50.0); g2.setColor(Color.green); g2.fill(circle); g2.setColor(Color.red); circle1 = new Ellipse2D.Double(ew, eh, 50.0, 50.0); g2.fill(circle1); Area area1 = new Area(circle); Area area2 = new Area(circle1); g2.setColor(Color.BLUE); area1.intersect(area2); g2.fill(area1); g2.dispose(); cb.addTemplate(tp, 50, 400); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:be.vdab.util.Programma.java
public static void main(String[] args) { SortedSet<Voertuig> voertuigen = new TreeSet<Voertuig>(); Datum datum = null;/*from ww w . j a v a 2 s . c om*/ Volume volumePickup = null; Volume volumeVrachtwagen = null; try { datum = new Datum(21, 11, 2012); } catch (DatumException de) { System.out.println(de.getMessage()); } Mens bestuurder_BC = new Mens("Albert", Rijbewijs.B, Rijbewijs.C); Mens inzittende_A = new Mens("Karolien", Rijbewijs.A); Mens inzittende = new Mens("Zora"); Mens inzittende_B = new Mens("David", Rijbewijs.B); Mens inzittende_DDE = new Mens("Evert", Rijbewijs.D, Rijbewijs.DE); Mens bestuurder_DE = new Mens("Boris", Rijbewijs.DE); Personenwagen wagen1Opel = new Personenwagen("Opel", datum, 250000, 4, Color.blue, bestuurder_BC, inzittende_A, inzittende); Personenwagen wagen2 = new Personenwagen("Mazda", datum, 27000, 5, Color.blue, bestuurder_BC, inzittende_A); try { volumePickup = new Volume(3, 3, 2, Maat.meter); volumeVrachtwagen = new Volume(3, 6, 2, Maat.meter); } catch (VolumeException ve) { System.out.println(ve.getMessage()); } Pickup pickup1Opel = new Pickup("Opel", datum, 400000, 5, Color.RED, volumePickup, bestuurder_BC, inzittende_B, inzittende_DDE, inzittende_A); Pickup pickup2 = new Pickup("Toyota", datum, 39000, 4, Color.blue, volumePickup, bestuurder_BC); Vrachtwagen vrachtwagen1 = new Vrachtwagen("BMW", datum, 90000, 2, volumeVrachtwagen, 3000, 6, bestuurder_BC, inzittende_A); Vrachtwagen vrachtwagen2 = new Vrachtwagen("Mercedes", datum, 120000, 3, volumeVrachtwagen, 2000, 8, bestuurder_BC, inzittende); voertuigen.add(wagen1Opel); //gesorteerd op nummerplaat voertuigen.add(wagen2); voertuigen.add(pickup1Opel); voertuigen.add(pickup2); voertuigen.add(vrachtwagen1); voertuigen.add(vrachtwagen2); print(voertuigen); /* //copy manier1 //copy (niet nodig dadelijk naar list omzetten, maar dan zit het niet in een SortedSet, oplossing: zelf copy uitvoeren, maar niet enkel referenties Set<Voertuig> voertuigen2=null;//=new TreeSet<Voertuig>(voertuigen); //new TreeSet<Voertuig>( org.apache.commons.collections.ComparatorUtils.reversedComparator( Voertuig.getAankoopprijsComparator())); //transformeren naar List, ook een copy List<Voertuig> lijst=new ArrayList<Voertuig>(voertuigen);//niet voertuigen 2 //sort Collections.sort(lijst, org.apache.commons.collections.ComparatorUtils.reversedComparator( Voertuig.getAankoopprijsComparator())); print(lijst); */ Set<Voertuig> voertuigen2 = new TreeSet<Voertuig>(org.apache.commons.collections.ComparatorUtils .reversedComparator(Voertuig.getAankoopprijsComparator())); voertuigen2.addAll(voertuigen); print(voertuigen2); //Copy manier 2: beter Set<Voertuig> voertuigen3 = new TreeSet<Voertuig>(Voertuig.getMerkComparator()); voertuigen3.addAll(voertuigen);//deep copy of niet , staat niet in de api. Maakt het uit hier? wanneer wel?als je de vrachtwagens gaat wijzigen en je wil dat die alleen in de copy gewijzigd zijn dan deep copy nodig print(voertuigen3); try { schrijweg((TreeSet) voertuigen3, "wagenpark.ser"); } catch (FileNotFoundException fnfe) { System.out.println(fnfe.getMessage()); } catch (IOException ioe) { System.out.println(ioe.getMessage()); } TreeSet<Voertuig> voertuigen4 = lees("wagenpark.ser"); System.out.println("Voertuigen4"); print(voertuigen4); }
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 . j a va 2 s . c om*/ 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 av a 2 s . co m*/ JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:JButtonKnowsBgColor.java
public static void main(String[] args) { JButtonKnowsBgColor jbkbc = new JButtonKnowsBgColor("choose back", Color.RED, true); JButtonKnowsBgColor jbkbc1 = new JButtonKnowsBgColor("choose fore", Color.BLUE, false); JFrame jf = new JFrame(); jf.setLayout(new BorderLayout()); jf.getContentPane().add(jbkbc, BorderLayout.NORTH); jf.getContentPane().add(jbkbc1, BorderLayout.CENTER); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setSize(100, 200);/*w ww . ja va 2 s .c om*/ jf.setVisible(true); }
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();/* ww w . j a va 2 s .c o m*/ }
From source file:ColorComboBoxEditor.java
public static void main(String args[]) { Color colors[] = { Color.RED, Color.BLUE, Color.BLACK, Color.WHITE }; JFrame frame = new JFrame("Editable JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JComboBox comboBox = new JComboBox(colors); comboBox.setEditable(true);//ww w .j a v a2s . c om comboBox.setEditor(new ColorComboBoxEditor(Color.RED)); frame.add(comboBox, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ComboTableCellRenderer.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);//from ww w . ja v a 2 s .c om TableCellEditor editor = new DefaultCellEditor(comboBox); JFrame frame = new JFrame("Editable Color Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TableModel model = new ColorTableModel(); JTable table = new JTable(model); TableColumn column = table.getColumnModel().getColumn(1); column.setCellRenderer(renderer); column.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(400, 150); frame.setVisible(true); }
From source file:MessagePopup.java
public static void main(String args[]) { JFrame frame = new JFrame("Message Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Pop it"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); /*/*from w ww . ja v a 2 s . com*/ * // String msg = "this is a really long message this is a * really long message this is a really long message this is a * really long message this is a really long message this is a * really long message this is a really long message"; String * msg = " <html>this is a really long message <br> this is a * really long message this is a really long message this is a * really long message this is a really long message this is a * really long message this is a really long message"; * JOptionPane.showMessageDialog(source, msg); JOptionPane * optionPane = OptionPaneUtils.getNarrowOptionPane(72); * optionPane.setMessage(msg); * optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); * JDialog dialog = optionPane.createDialog(source, "Width 72"); * dialog.show(); int selection = * OptionPaneUtils.getSelection(optionPane); * JOptionPane.showMessageDialog(source, msg); String * multiLineMsg[] = {"Hello", "World"}; * JOptionPane.showMessageDialog(source, multiLineMsg); * * Object complexMsg[] = {"Above Message", new * DiamondIcon(Color.red), new JButton ("Hello"), new JSlider(), * new DiamondIcon(Color.blue), "Below Message"}; * JOptionPane.showInputDialog(source, complexMsg); JOptionPane * optionPane = new JOptionPane(); JSlider slider = * OptionPaneUtils.getSlider(optionPane); * optionPane.setMessage(new Object[] {"Select a value: " , * slider}); * optionPane.setMessageType(JOptionPane.QUESTION_MESSAGE); * optionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION); * JDialog dialog = optionPane.createDialog(source, "My * Slider"); dialog.show(); System.out.println ("Input: " + * optionPane.getInputValue()); */ JOptionPane optionPane = new JOptionPane(); optionPane.setMessage("I got an icon and a text label"); optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); Icon icon = new DiamondIcon(Color.blue); JButton jButton = OptionPaneUtils.getButton(optionPane, "OK", icon); optionPane.setOptions(new Object[] { jButton }); JDialog dialog = optionPane.createDialog(source, "Icon/Text Button"); dialog.show(); } }; button.addActionListener(actionListener); Container contentPane = frame.getContentPane(); contentPane.add(button, BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }