Example usage for java.awt Color RED

List of usage examples for java.awt Color RED

Introduction

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

Prototype

Color RED

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

Click Source Link

Document

The color red.

Usage

From source file:CreateColorSamplePopup.java

public static void main(String args[]) {
    final JColorChooser colorChooser = new JColorChooser(Color.RED);

    ActionListener okActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("Color change rejected");
        }//from ww w.  ja v  a2 s . c o  m
    };

    // For cancel selection, change button background to red
    ActionListener cancelActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("cancled");
        }
    };

    final JDialog dialog = JColorChooser.createDialog(null, "Change Button Background", true, colorChooser,
            okActionListener, cancelActionListener);

    dialog.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("Hello");
    label.setOpaque(true);/*from  w  w w .  j  a  va  2 s  .  c  o  m*/
    label.setBackground(Color.red);

    JPanel bottomPanel = new JPanel(new BorderLayout());
    bottomPanel.add(label, BorderLayout.LINE_END);

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(bottomPanel, BorderLayout.PAGE_END);
    mainPanel.setPreferredSize(new Dimension(400, 400));

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(mainPanel);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextPane textPane = new JTextPane();

    Style style = textPane.addStyle(null, null);
    StyleConstants.setForeground(style, Color.red);
    textPane.setLogicalStyle(style);/*www.ja va  2 s.  c  o m*/

    style = textPane.addStyle(null, null);
    StyleConstants.setForeground(style, Color.red);
    textPane.setLogicalStyle(style);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextPane textPane = new JTextPane();

    Style style = textPane.addStyle(null, null);
    StyleConstants.setForeground(style, Color.red);
    textPane.setLogicalStyle(style);// w w w  .j a  va  2s. co m

    // Set paragraph style; removes logical style
    style = textPane.addStyle(null, null);
    StyleConstants.setUnderline(style, true);
    textPane.setParagraphAttributes(style, true);
    // paragraph is now underlined, not red
}

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);//from  w ww.  j  av  a2 s .  c o  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:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("JLabel Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel("First Name");
    label.setFont(new Font("Courier New", Font.ITALIC, 18));
    label.setForeground(Color.RED);

    frame.add(label);/*from  w  w w . j a va  2s. c  o m*/
    frame.pack();
    frame.setVisible(true);
}

From source file:EtchedBorderSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Sample Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border etchedBorder = new EtchedBorder(EtchedBorder.RAISED, Color.RED, Color.PINK);

    JLabel aLabel = new JLabel("Bevel");
    aLabel.setBorder(etchedBorder);/*from   w w w.j  av  a2s.c o m*/
    aLabel.setHorizontalAlignment(JLabel.CENTER);

    frame.add(aLabel);
    frame.setSize(400, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel ui = new JPanel(new BorderLayout(20, 20));

    ui.setBorder(new LineBorder(Color.RED, 1));

    JTextField fileName = new JTextField();
    ui.add(fileName, BorderLayout.NORTH);

    JPanel buttonPanel = new JPanel(new GridLayout(1, 0, 10, 30));
    ui.add(buttonPanel, BorderLayout.CENTER);

    JButton creater = new JButton("Create File");
    buttonPanel.add(creater);/*  w  w  w. j av a 2  s.  co  m*/
    JButton deleter = new JButton("Delete File");
    buttonPanel.add(deleter);

    JOptionPane.showMessageDialog(null, ui);

}

From source file:BevelBorderWithDiffBorderColor.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Sample Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border bevelBorder = new BevelBorder(BevelBorder.RAISED, Color.RED, Color.RED.darker(), Color.PINK,
            Color.PINK.brighter());

    JLabel aLabel = new JLabel("Bevel");
    aLabel.setBorder(bevelBorder);// w  w w.  j a va 2  s . c  o  m
    aLabel.setHorizontalAlignment(JLabel.CENTER);

    frame.add(aLabel);
    frame.setSize(400, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("");
    Container contentPane = frame.getContentPane();
    Icon icon = new PieIcon(Color.red);
    JButton b = new JButton("Button!", icon);
    contentPane.add(b, BorderLayout.NORTH);
    b = new JButton(icon);
    contentPane.add(b, BorderLayout.SOUTH);
    frame.setSize(300, 200);/*from   w w  w . ja  v a 2s  .c  o  m*/
    frame.show();
}