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:com.game.ui.views.CharachterEditorPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel("Pls select a value to choose an enemy or you can create a new "
            + "Enemy entity below. Once selected an Enemy character, its' details will be available below");
    noteLbl.setAlignmentX(0);//from w ww .  ja v  a  2  s  .  c om
    //        noteLbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (GameCharacter character : GameBean.enemyDetails) {
        System.out.println(character.getName());
        model.addElement(character.getName());
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel enemyDtlLbl = new JLabel("Enemy Character Details : ");
    enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(enemyDtlLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel imageLbl = new JLabel("Image Path : ");
    panel1.add(imageLbl, c);
    c.gridx = 1;
    JTextField image = new JTextField("");
    image.setColumns(20);
    panel1.add(image, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel healthLbl = new JLabel("Health Pts : ");
    panel1.add(healthLbl, c);
    c.gridx = 1;
    JTextField health = new JTextField("");
    health.setColumns(20);
    panel1.add(health, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    JLabel armoursPtsLbl = new JLabel("Armour Points : ");
    panel1.add(armoursPtsLbl, c);
    c.gridx = 1;
    JTextField armourPts = new JTextField("");
    armourPts.setColumns(20);
    panel1.add(armourPts, c);
    c.gridx = 0;
    c.gridy = 6;
    JLabel attackRngeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRngeLbl, c);
    c.gridx = 1;
    JTextField attackRnge = new JTextField("");
    attackRnge.setColumns(20);
    panel1.add(attackRnge, c);
    c.gridx = 0;
    c.gridy = 7;
    JLabel movementLbl = new JLabel("Movement : ");
    panel1.add(movementLbl, c);
    c.gridx = 1;
    JTextField movement = new JTextField("");
    movement.setColumns(20);
    panel1.add(movement, c);
    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    add(panel1);
    c.gridx = 0;
    c.gridy = 9;
    JLabel validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    add(validationMess, c);
    add(Box.createVerticalGlue());
}

From source file:net.nosleep.superanalyzer.analysis.views.SummaryView.java

private void addStatTriple(JPanel panel, StringTriple triple) {

    JLabel wordLabel = new JLabel(triple.Name + ": ");
    wordLabel.setOpaque(false);//  ww  w . ja  v a  2s.  c  o m
    wordLabel.setFont(Theme.getFont(12));
    wordLabel.setHorizontalAlignment(JLabel.RIGHT);
    panel.add(wordLabel);

    JLabel wordField = new JLabel();
    wordField.setOpaque(false);
    wordField.setFont(Theme.getBoldFont(12));
    wordField.setBorder(new javax.swing.border.EmptyBorder(1, 1, 1, 1));
    wordField.setForeground(Theme.getColorSet()[0]);
    panel.add(wordField);

    wordField.setText(triple.Value);
    wordField.setToolTipText(Misc.getTooltip(triple.Info));
}

From source file:org.pmedv.core.dialogs.AbstractNiceDialog.java

private JPanel createHeader(String title, String subTitle, ImageIcon icon) {

    int headerHeight = 50;

    FormLayout formLayout = new FormLayout("8dlu, 10dlu, fill:pref:grow, 7dlu, pref, 7dlu",
            "4dlu, 13dlu,max(" + (headerHeight - 17) + "dlu;default),default");

    // GradientPanel header = new GradientPanel(formLayout,Color.WHITE,Color.LIGHT_GRAY);

    Color blue = new Color(153, 204, 255);
    GradientPanel header = new GradientPanel(formLayout, Color.WHITE, blue);
    header.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    header.setBackground(Color.white);

    JLabel titleLabel = new JLabel(title);
    JLabel subTitleLabel = new JLabel(subTitle);
    JLabel iconLabel = (icon == null ? new JLabel() : new JLabel(icon));

    titleLabel.setForeground(Color.black);
    subTitleLabel.setForeground(Color.black);

    titleLabel.setFont(new Font("Arial", Font.BOLD, 15));
    subTitleLabel.setFont(new Font("Arial", Font.PLAIN, 12));

    CellConstraints cc = new CellConstraints();
    header.add(titleLabel, cc.xywh(2, 2, 2, 1));
    header.add(subTitleLabel, cc.xywh(2, 3, 2, 1));
    header.add(iconLabel, cc.xywh(5, 1, 1, 3, "right,center"));

    return (header);

}

From source file:analisisnumerico.Main.java

public Main() {
    setTitle("Analisis Numerico");
    setBounds(145, 80, 780, 480);/*from  w ww.jav a2s .co  m*/
    this.setUndecorated(true);
    initComponents();
    jPanel2.setBackground(new Color(219, 68, 55));
    JLabel text = new JLabel("Analisis Numerico");
    text.setBounds(14, 0, 160, 40);
    text.setForeground(Color.WHITE);
    jPanel2.add(text);
    jButton1.setSize(20, 20);
    jButton2.setSize(20, 20);
    Fondo f = new Fondo();
    jPanel1.add(f);
    m.setBounds(0, 0, 780, 480);
    f.add(m);
    jButton2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setExtendedState(ICONIFIED);
        }
    });
    jButton2.setVisible(true);
    jButton1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    jButton1.setVisible(true);

    jButton6.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Biseccion s = new Biseccion(F);
            f.removeAll();
            s.setBounds(0, 0, 780, 480);
            f.add(s);
            f.setVisible(true);
            f.updateUI();
        }
    });

    jButton7.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Secante s = new Secante(F);
            f.removeAll();
            s.setBounds(0, 0, 780, 480);
            f.add(s);
            f.setVisible(true);
            f.updateUI();
        }
    });

    jButton3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Menu m = new Menu(F);
            f.removeAll();
            m.setBounds(0, 0, 780, 480);
            f.add(m);
            f.setVisible(true);
            f.updateUI();
        }
    });

    jButton8.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Newton n = new Newton(F);
            f.removeAll();
            n.setBounds(0, 0, 780, 480);
            f.add(n);
            f.setVisible(true);
            f.updateUI();
        }
    });
    jButton5.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Grafica g = new Grafica(F);
            f.removeAll();
            g.setBounds(0, 0, 780, 480);
            f.add(g);
            f.setVisible(true);
            f.updateUI();

        }
    });
    jButton4.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SistemasEcuaciones m = new SistemasEcuaciones();
            f.removeAll();
            m.setBounds(0, 0, 780, 480);
            f.add(m);
            f.setVisible(true);
            f.updateUI();
        }
    });
}

From source file:com.willwinder.universalgcodesender.uielements.panels.MachineStatusPanel.java

private void setPostionValueColor(JLabel label, double newValue) {
    if (!label.getText().equals(decimalFormatter.format(newValue))) {
        label.setForeground(Color.red);
    } else {/*from   w w  w .j  av  a  2  s .  co m*/
        label.setForeground(Color.black);
    }
}

From source file:MultiLineLabel.java

public void addText(String text, int size) {
    if (spacing > 0)
        add(Box.createVerticalStrut(spacing));

    String strs[] = splitLines(text);
    JLabel l;
    Font font = new Font("SansSerif", fontAttributes, size);

    for (int i = 0; strs != null && i < strs.length; i++) {
        l = new JLabel(strs[i]);
        l.setFont(font);/*w  w w. ja v a 2s .co m*/
        l.setAlignmentX(alignment);

        if (col != null)
            l.setForeground(col);

        add(l);
    }
}

From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java

private JLabel getTagComponent(final Server server, final Color foreground) {
    final JLabel tags = new JLabel();

    final Font tagFont = new Font(tags.getFont().getName(), Font.PLAIN, 11);
    tags.setFont(tagFont);//from   w  ww  .ja  va2  s .c  o m
    tags.setText(Utils.implode(new ArrayList<String>(server.getTags()), ", "));
    tags.setForeground(foreground);
    return tags;
}

From source file:com.smart.aqimonitor.client.AqiMonitor.java

/**
 * Create the frame.// w w w . j  a v  a  2s.  c om
 */
public AqiMonitor() {
    refSelf = this;
    setPreferredSize(new Dimension(640, 480));
    setTitle("\u7A7A\u6C14\u8D28\u91CF\u76D1\u6D4B");
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(AqiMonitor.class.getResource("/lombok/installer/eclipse/STS.png")));
    setMinimumSize(new Dimension(640, 480));
    setMaximumSize(new Dimension(1024, 768));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 636, 412);
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(640, 480));
    contentPane.setMinimumSize(new Dimension(640, 480));
    contentPane.setMaximumSize(new Dimension(1024, 768));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JPanel mainPanel = new JPanel();
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout(0, 0));

    JPanel contentPanel = new JPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane
            .setViewportBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    contentPanel.add(scrollPane, BorderLayout.CENTER);

    textPane = new AqiTextPane();
    textPane.addInputMethodListener(new InputMethodListener() {

        public void caretPositionChanged(InputMethodEvent event) {

        }

        public void inputMethodTextChanged(InputMethodEvent event) {
            textPane.setCaretPosition(document.getLength() + 1);
        }
    });
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.setForeground(Color.BLACK);
    scrollPane.setViewportView(textPane);
    document = textPane.getStyledDocument();

    document.addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            if (e.getDocument() == document) {
                textPane.setCaretPosition(document.getLength());
            }
        }
    });

    JPanel buttonPanel = new JPanel();
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.setLayout(new BorderLayout(0, 0));

    JLabel lblTipsLabel = new JLabel(
            "Tips\uFF1A\u6587\u4EF6\u4FDD\u5B58\u683C\u5F0Fcsv\u53EF\u7528Excel\u6253\u5F00");
    lblTipsLabel.setForeground(Color.BLUE);
    buttonPanel.add(lblTipsLabel, BorderLayout.WEST);

    JPanel panel = new JPanel();
    buttonPanel.add(panel, BorderLayout.CENTER);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnRetrieve = new JButton("\u624B\u52A8\u83B7\u53D6\u6570\u636E");
    panel.add(btnRetrieve);
    btnRetrieve.setVerticalAlignment(SwingConstants.BOTTOM);

    JButton btnNewButton = new JButton("\u5173\u4E8E");
    btnNewButton.setToolTipText("\u5173\u4E8E");
    btnNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextArea textArea = new JTextArea(
                    "\n        csv\n\n        smartstudio@foxmail.com");
            textArea.setColumns(35);
            textArea.setRows(6);
            textArea.setLineWrap(true);// 
            textArea.setEditable(false);// 
            textArea.setOpaque(false);
            JOptionPane.showMessageDialog(contentPane, textArea, "", JOptionPane.PLAIN_MESSAGE);
        }
    });

    JButton btnSetting = new JButton("\u8BBE\u7F6E");
    btnSetting.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            Point parentPos = refSelf.getLocation();

            AqiSettingDialog settingDialog = new AqiSettingDialog(refSelf, pm25InDetailJob.getAqiParser());
            settingDialog.setModal(true);
            settingDialog.setLocation(parentPos.x + 100, parentPos.y + 150);
            settingDialog.init();
            settingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            settingDialog.setVisible(true);
        }
    });

    JButton btnExportDir = new JButton("\u67E5\u770B\u6570\u636E");
    btnExportDir.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {

                String[] cmd = new String[5];

                String filePath = pm25InDetailJob.getAqiParser().getFilePath();
                File file = new File(filePath);
                if (!file.exists()) {
                    FileUtil.makeDir(file);
                }
                if (!file.isDirectory()) {
                    JOptionPane.showMessageDialog(contentPane, "", "",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                cmd[0] = "cmd";
                cmd[1] = "/c";
                cmd[2] = "start";
                cmd[3] = " ";
                cmd[4] = pm25InDetailJob.getAqiParser().getFilePath();

                Runtime.getRuntime().exec(cmd);

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    panel.add(btnExportDir);
    panel.add(btnSetting);
    panel.add(btnNewButton);
    btnRetrieve.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!isRetrieving) {
                isRetrieving = true;
                Thread firstRun = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        pm25InDetailJob.refresh();
                        isRetrieving = false;
                    }
                });

                firstRun.start();
            }
        }
    });

    init();
}

From source file:MainClass.java

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    Font theFont = null;//from w  w  w.jav a  2 s  .c o  m
    Color theForeground = null;
    String theText = null;

    JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected,
            cellHasFocus);

    if (value instanceof Object[]) {
        Object values[] = (Object[]) value;
        theFont = (Font) values[0];
        theForeground = (Color) values[1];
        theText = (String) values[2];
    } else {
        theFont = list.getFont();
        theForeground = list.getForeground();
        theText = "";
    }
    if (!isSelected) {
        renderer.setForeground(theForeground);
    }
    renderer.setText(theText);
    renderer.setFont(theFont);
    return renderer;
}

From source file:MemoryMonitor.java

public MemoryMonitor() {
    setLayout(new BorderLayout());
    setBorder(new TitledBorder(new EtchedBorder(), "Memory Monitor"));
    add(surf = new Surface());
    controls = new JPanel();
    controls.setPreferredSize(new Dimension(135, 80));
    Font font = new Font("serif", Font.PLAIN, 10);
    JLabel label = new JLabel("Sample Rate");
    label.setFont(font);/*from ww  w .j  a v  a2 s  .  c  o  m*/
    label.setForeground(Color.red);
    controls.add(label);
    tf = new JTextField("1000");
    tf.setPreferredSize(new Dimension(45, 20));
    controls.add(tf);
    controls.add(label = new JLabel("ms"));
    label.setFont(font);
    label.setForeground(Color.red);
    controls.add(dateStampCB);
    dateStampCB.setFont(font);
    addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            removeAll();
            if ((doControls = !doControls)) {
                surf.stop();
                add(controls);
            } else {
                try {
                    surf.sleepAmount = Long.parseLong(tf.getText().trim());
                } catch (Exception ex) {
                }
                surf.start();
                add(surf);
            }
            validate();
            repaint();
        }
    });
}