Example usage for javax.swing JLabel setForeground

List of usage examples for javax.swing JLabel setForeground

Introduction

In this page you can find the example usage for javax.swing JLabel setForeground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.")
public void setForeground(Color fg) 

Source Link

Document

Sets the foreground color of this component.

Usage

From source file:Main.java

public static void main(String[] args) {
    Color myColor = Color.RED;

    JLabel label = new JLabel("First Name");
    label.setForeground(myColor.brighter());

    JFrame frame = new JFrame();
    frame.add(label);//from w w  w. j a v a2  s.  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) {
    Color myColor = Color.decode("0XFFFFFF");

    JLabel label = new JLabel("First Name");
    label.setForeground(myColor);

    JFrame frame = new JFrame();
    frame.add(label);//from   ww  w  .ja  v  a2s .  c  om
    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) {
    Color myColor = new Color(0.1F, 0.2F, 0.3F);

    JLabel label = new JLabel("First Name");
    label.setForeground(myColor);

    JFrame frame = new JFrame();
    frame.add(label);// www.  ja va 2  s  . co  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) {
    Color myBlack = new Color(0, 0, 0, 0.5F); // Color black
    //  Color myWhite = new Color(255,255,255);     // Color white
    //  Color myGreen = new Color(0,200,0);         // A shade of green

    JLabel label = new JLabel("First Name");
    label.setForeground(myBlack);

    JFrame frame = new JFrame();
    frame.add(label);//from w  ww  .j av a2  s  . c  om
    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) {
    Color myBlack = new Color(0, 0, 0); // Color black
    //  Color myWhite = new Color(255,255,255);     // Color white
    //  Color myGreen = new Color(0,200,0);         // A shade of green

    JLabel label = new JLabel("First Name");
    label.setForeground(myBlack);

    JFrame frame = new JFrame();
    frame.add(label);//www  . ja  va 2 s  . 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("Full Name :", JLabel.LEFT);

    label.setOpaque(true);//  w w  w  .j a v a 2 s  .  com
    label.setForeground(new Color(150, 150, 25));
    label.setBackground(new Color(50, 50, 25));

    JOptionPane.showMessageDialog(null, label);

}

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);/*w  w  w .  j a v  a  2 s  .com*/
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame();
    frame.setTitle("JLabel Test");
    frame.setLayout(new FlowLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel("First Name");
    label.setFont(new Font("Courier New", Font.ITALIC, 12));
    label.setForeground(Color.GRAY);

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

From source file:MyLabel.java

public static void main(String[] args) {
    String lyrics = "<html>Line<br>line<br>line</html>";

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout(10, 10));

    JLabel label = new JLabel(lyrics);
    label.setFont(new Font("Georgia", Font.PLAIN, 14));
    label.setForeground(new Color(50, 50, 25));

    panel.add(label, BorderLayout.CENTER);
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JFrame f = new JFrame();
    f.add(panel);/*from  w ww .j av a2 s.  com*/
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:ListeningJColorChooserSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JColorChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JLabel label = new JLabel("www.java2s.com", JLabel.CENTER);
    label.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48));

    frame.add(label, BorderLayout.SOUTH);

    final JColorChooser colorChooser = new JColorChooser(label.getBackground());

    ColorSelectionModel model = colorChooser.getSelectionModel();
    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            Color newForegroundColor = colorChooser.getColor();
            label.setForeground(newForegroundColor);
        }/*w w  w  . ja v  a 2 s .com*/
    };
    model.addChangeListener(changeListener);

    frame.add(colorChooser, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);
}