Example usage for java.awt Color blue

List of usage examples for java.awt Color blue

Introduction

In this page you can find the example usage for java.awt Color blue.

Prototype

Color blue

To view the source code for java.awt Color blue.

Click Source Link

Document

The color blue.

Usage

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("First Name");
    label.setForeground(Color.blue);

    JFrame frame = new JFrame();
    frame.add(label);// w ww .  j a  va2s .  c  o  m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(20, 20, 500, 500);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("First Name");
    label.setForeground(Color.BLUE);

    JFrame frame = new JFrame();
    frame.add(label);/* w  w  w  . j a  va  2s . co m*/
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(20, 20, 500, 500);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] a) {
    Icon blueIcon = new MyIcon(Color.BLUE);
    Object stringArray[] = { "Do It", "No Way" };
    JOptionPane.showOptionDialog(new JDesktopPane(), "Continue printing?", "Select an Option",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray, stringArray[0]);

}

From source file:Main.java

public static void main(String args[]) {
    UIManager.put("ProgressBar.repaintInterval", 100);
    UIManager.put("ProgressBar.border", BorderFactory.createLineBorder(Color.blue, 2));
    JFrame f = new JFrame();
    f.setLayout(new GridLayout(0, 1, 5, 5));
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(createBar());/* ww  w  .  ja  va2s . c  o m*/
    f.add(createBar());
    f.add(createBar());
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:SplashScreenDemo.java

public static void main(String[] args) {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();
    Dimension size = splashScreen.getSize();
    int borderDim = (int) (size.height * 0.05);
    Graphics g = splashScreen.createGraphics();
    g.setColor(Color.blue);
    for (int i = 0; i < borderDim; i++)
        g.drawRect(i, i, size.width - 1 - i * 2, size.height - 1 - i * 2);

    FontMetrics fm = g.getFontMetrics();
    int sWidth = fm.stringWidth("Initializing...");
    int sHeight = fm.getHeight();
    if (sWidth < size.width && 2 * sHeight < size.height) {
        g.setColor(Color.blue);/*from w ww. j av  a  2  s  .c om*/
        g.drawString("Initializing...", (size.width - sWidth) / 2, size.height - 2 * sHeight);
    }

    splashScreen.update();

    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
    }
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    JLabel label = new JLabel(new ElliptIcon(380, 260, Color.red));
    label.setLayout(new GridLayout(2, 2));
    frame.setContentPane(label);// w  ww  . ja  va  2s  .co  m
    for (int i = 0; i < 4; i++) {
        label.add(new JLabel(new ElliptIcon(100, 60, Color.blue)));
    }
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Justified Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Border greenBorder = BorderFactory.createLineBorder(Color.GREEN, 2);
    Border blueBorder = BorderFactory.createLineBorder(Color.BLUE, 2);
    Border magentaBorder = BorderFactory.createLineBorder(Color.MAGENTA, 2);
    Border twoColorBorder = new CompoundBorder(magentaBorder, blueBorder);
    Border threeColorBorder = new CompoundBorder(twoColorBorder, greenBorder);

    JButton rainbowButton = new JButton("Rainbow");
    rainbowButton.setBorder(threeColorBorder);

    Container contentPane = frame.getContentPane();
    contentPane.add(rainbowButton);/*from  ww  w .j  a  v a2 s. c o m*/
    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JTextPane textPane = new JTextPane();
    StyledDocument doc = textPane.getStyledDocument();

    Style style = textPane.addStyle("I'm a Style", null);
    StyleConstants.setForeground(style, Color.red);

    doc.insertString(doc.getLength(), "BLAH ", style);

    StyleConstants.setForeground(style, Color.blue);

    doc.insertString(doc.getLength(), "BLEH", style);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame();
    f.add(new JComponent() {
        public void paintComponent(Graphics g) {

            // Some parameters.
            String text = "Some Label";
            int centerX = 150, centerY = 100;
            int ovalWidth = 200, ovalHeight = 100;

            // Draw oval
            g.setColor(Color.BLUE);
            g.fillOval(centerX - ovalWidth / 2, centerY - ovalHeight / 2, ovalWidth, ovalHeight);

            // Draw centered text
            FontMetrics fm = g.getFontMetrics();
            double textWidth = fm.getStringBounds(text, g).getWidth();
            g.setColor(Color.WHITE);
            g.drawString(text, (int) (centerX - textWidth / 2), (int) (centerY + fm.getMaxAscent() / 2));

        }/*from   w w  w  . j  av  a  2 s . co  m*/
    });

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(300, 300);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    int size = 200;
    BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g = image.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setColor(Color.BLUE);
    for (int i = 0; i < size; i += 5) {
        g.drawOval(i, i, size - i, size - i);
    }//ww w  .  j  ava 2  s.c  o m
    g.dispose();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(image, "png", baos);

    String data = DatatypeConverter.printBase64Binary(baos.toByteArray());
    String imageString = "data:image/png;base64," + data;
    String html = "<html><body><img src='" + imageString + "'></body></html>";
    System.out.println(html);
}