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:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();//from ww w . j a va2s . com PdfContentByte cb = writer.getDirectContent(); PdfSpotColor psc_cmyk = new PdfSpotColor("iTextSpotColorCMYK", 0.25f, new CMYKColor(0.3f, .9f, .3f, .1f)); SpotColor sc_cmyk = new SpotColor(psc_cmyk); Image img = Image.getInstance("dog.jpg"); PdfPatternPainter img_pattern = cb.createPattern(img.scaledWidth(), img.scaledHeight(), img.scaledWidth(), img.scaledHeight()); img_pattern.addImage(img, img.scaledWidth(), 0f, 0f, img.scaledHeight(), 0f, 0f); img_pattern.setPatternMatrix(1f, 0f, 0f, 1f, 60f, 60f); PdfShading axial = PdfShading.simpleAxial(writer, 36, 716, 396, 788, Color.orange, Color.blue); PdfShadingPattern axialPattern = new PdfShadingPattern(axial); ShadingColor axialColor = new ShadingColor(axialPattern); document.add(new Paragraph("This is a paragraph painted using a shading pattern", new Font(Font.HELVETICA, 24, Font.BOLD, axialColor))); document.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { if (!SystemTray.isSupported()) { return;//from w ww.j a va2 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) { for (int i = 0; i < tia.length; i++) System.out.println(tia[i]); } tia = (TrayIcon[]) pce.getNewValue(); if (tia != null) { for (int i = 0; i < tia.length; i++) System.out.println(tia[i]); } } }; 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); TrayIcon icon = null; tray.add(icon = new TrayIcon(bi)); Thread.sleep(3000); tray.remove(icon); tray.removePropertyChangeListener("trayIcons", pcl); Thread.sleep(3000); System.exit(0); }
From source file:ColorAction.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("SeparateGUITest"); frame.setSize(300, 200);/*from www . j a v a 2 s. c o m*/ 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:Main.java
public static void main(String[] args) throws Exception { if (!SystemTray.isSupported()) { return;//from www.j a va 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) { for (int i = 0; i < tia.length; i++) System.out.println(tia[i]); } tia = (TrayIcon[]) pce.getNewValue(); if (tia != null) { for (int i = 0; i < tia.length; i++) System.out.println(tia[i]); } } }; tray.addPropertyChangeListener("trayIcons", pcl); Dimension size = tray.getTrayIconSize(); TrayIcon[] icons = tray.getTrayIcons(); 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); TrayIcon icon = null; tray.add(icon = new TrayIcon(bi)); Thread.sleep(3000); tray.remove(icon); Thread.sleep(3000); System.exit(0); }
From source file:Borders.java
public static void main(String[] args) { JFrame frame = new JFrame("Borders"); int center = SwingConstants.CENTER; JLabel labelOne = new JLabel("raised BevelBorder", center); labelOne.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); JLabel labelTwo = new JLabel("EtchedBorder", center); labelTwo.setBorder(BorderFactory.createEtchedBorder()); JLabel labelThree = new JLabel("MatteBorder", center); labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink)); JLabel labelFour = new JLabel("TitledBorder", center); Border etch = BorderFactory.createEtchedBorder(); labelFour.setBorder(BorderFactory.createTitledBorder(etch, "Title")); JLabel labelFive = new JLabel("TitledBorder", center); Border low = BorderFactory.createLoweredBevelBorder(); labelFive//from w w w .j av a 2 s.c o m .setBorder(BorderFactory.createTitledBorder(low, "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM)); JLabel labelSix = new JLabel("CompoundBorder", center); Border one = BorderFactory.createEtchedBorder(); Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue); labelSix.setBorder(BorderFactory.createCompoundBorder(one, two)); frame.setLayout(new GridLayout(3, 2)); frame.add(labelOne); frame.add(labelTwo); frame.add(labelThree); frame.add(labelFour); frame.add(labelFive); frame.add(labelSix); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Barcode128Demo.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w . ja v a2s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Barcode128.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); String code402 = "123456789012345" + Barcode128.FNC1; String code90 = "www.java2s.com" + Barcode128.FNC1; String code421 = "123456"; String data = code402 + code90 + code421; Barcode128 shipBarCode = new Barcode128(); shipBarCode.setX(0.75f); shipBarCode.setN(1.5f); shipBarCode.setChecksumText(true); shipBarCode.setGenerateChecksum(true); shipBarCode.setSize(10f); shipBarCode.setTextAlignment(Element.ALIGN_CENTER); shipBarCode.setBaseline(10f); shipBarCode.setCode(data); shipBarCode.setBarHeight(50f); Image imgShipBarCode = shipBarCode.createImageWithBarcode(cb, Color.black, Color.blue); document.add(imgShipBarCode); } catch (Exception e) { e.printStackTrace(); } document.close(); }
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);/* www . j a v a2s . 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:Main.java
public static void main(String[] args) throws Exception { if (!SystemTray.isSupported()) { return;/*from ww w. j a 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) { for (int i = 0; i < tia.length; i++) System.out.println(tia[i]); } tia = (TrayIcon[]) pce.getNewValue(); if (tia != null) { for (int i = 0; i < tia.length; i++) System.out.println(tia[i]); } } }; tray.addPropertyChangeListener("trayIcons", pcl); PropertyChangeListener[] listeners = tray.getPropertyChangeListeners("trayIcons"); 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); TrayIcon icon = null; tray.add(icon = new TrayIcon(bi)); Thread.sleep(3000); tray.remove(icon); Thread.sleep(3000); System.exit(0); }
From source file:StylesExample5.java
public static void main(String[] args) { try {/*w w w . j a v a2 s . c o m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Styles Example 5"); // Create the StyleContext, the document and the pane StyleContext sc = new StyleContext(); final DefaultStyledDocument doc = new DefaultStyledDocument(sc); final JTextPane pane = new JTextPane(doc); // Create and add the style final Style heading2Style = sc.addStyle("Heading2", null); heading2Style.addAttribute(StyleConstants.Foreground, Color.red); heading2Style.addAttribute(StyleConstants.FontSize, new Integer(16)); heading2Style.addAttribute(StyleConstants.FontFamily, "serif"); heading2Style.addAttribute(StyleConstants.Bold, new Boolean(true)); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { // Add the text to the document doc.insertString(0, text, null); // Finally, apply the style to the heading doc.setParagraphAttributes(0, 1, heading2Style, false); // Set the foreground and font pane.setForeground(Color.blue); pane.setFont(new Font("serif", Font.PLAIN, 12)); } catch (BadLocationException e) { } } }); } catch (Exception e) { System.out.println("Exception when constructing document: " + e); System.exit(1); } f.getContentPane().add(new JScrollPane(pane)); f.setSize(400, 300); f.setVisible(true); }
From source file:com.offbynull.peernetic.debug.visualizer.App.java
public static void main(String[] args) throws Throwable { Random random = new Random(); Visualizer<Integer> visualizer = new JGraphXVisualizer<>(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Recorder<Integer> recorder = new XStreamRecorder(baos); visualizer.visualize(recorder, null); visualizer.step("Adding nodes 1 and 2", new AddNodeCommand<>(1), new ChangeNodeCommand(1, null, new Point(random.nextInt(400), random.nextInt(400)), Color.RED), new AddNodeCommand<>(2), new ChangeNodeCommand(2, null, new Point(random.nextInt(400), random.nextInt(400)), Color.BLUE)); Thread.sleep(500);/*from w w w.j a v a2s . c o m*/ visualizer.step("Adding nodes 3 and 4", new AddNodeCommand<>(3), new ChangeNodeCommand(3, null, new Point(random.nextInt(400), random.nextInt(400)), Color.ORANGE), new AddNodeCommand<>(4), new ChangeNodeCommand(4, null, new Point(random.nextInt(400), random.nextInt(400)), Color.PINK)); Thread.sleep(500); visualizer.step("Connecting 1/2/3 to 4", new AddEdgeCommand<>(1, 4), new AddEdgeCommand<>(2, 4), new AddEdgeCommand<>(3, 4)); Thread.sleep(500); visualizer.step("Adding trigger to 4 when no more edges", new TriggerOnLingeringNodeCommand(4, new RemoveNodeCommand<>(4))); Thread.sleep(500); visualizer.step("Removing connections from 1 and 2", new RemoveEdgeCommand<>(1, 4), new RemoveEdgeCommand<>(2, 4)); Thread.sleep(500); visualizer.step("Removing connections from 3", new RemoveEdgeCommand<>(3, 4)); Thread.sleep(500); recorder.close(); Thread.sleep(2000); JGraphXVisualizer<Integer> visualizer2 = new JGraphXVisualizer<>(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); Player<Integer> player = new XStreamPlayer<>(bais); visualizer2.visualize(); player.play(visualizer2); }