Java Swing UIManager get text field foreground color

Description

Java Swing UIManager get text field foreground color

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.UIManager;

public class Main extends JFrame {
  public Main() {
    super("JButton");

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new FlowLayout());
    JLabel nameLabel = new JLabel("Name:");
    JTextField name = new JTextField(20);
    //w ww  .j  ava2s.  c  om
    Color c = UIManager.getColor("TextField.foreground");
    System.out.println(c);

    getContentPane().add(nameLabel);
    getContentPane().add(name);

  }

  public static void main(String[] args) {
    Main frame = new Main();
    frame.pack();
    frame.setVisible(true);
  }
}



PreviousNext

Related