Example usage for java.awt Color YELLOW

List of usage examples for java.awt Color YELLOW

Introduction

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

Prototype

Color YELLOW

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

Click Source Link

Document

The color yellow.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTable table = new JTable() {
        public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
            Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
            if (vColIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                c.setBackground(Color.yellow);
            } else {
                c.setBackground(getBackground());
            }/*from  w ww . j a  v  a2s .co  m*/
            return c;
        }
    };
}

From source file:Main.java

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

    JButton b1 = new JButton("Button 1") {
        public JToolTip createToolTip() {
            JToolTip tip = super.createToolTip();
            tip.setForeground(Color.YELLOW);
            return tip;
        }//from ww  w .  ja  v  a  2s .  c  om

        public Point getToolTipLocation(MouseEvent event) {
            return new Point((event.getX() + 100), (event.getY() + 100));
        }
    };
    b1.setToolTipText("HELLO");
    frame.add(b1, BorderLayout.NORTH);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    Color colors[] = { Color.GREEN, Color.ORANGE, Color.PINK, Color.RED, Color.WHITE, Color.YELLOW };
    JFrame frame = new JFrame("Color JComboBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JComboBox comboBox = new JComboBox(colors);
    comboBox.setMaximumRowCount(5);//from  ww  w.  j av a2 s. co m
    comboBox.setEditable(true);
    comboBox.setRenderer(new ColorCellRenderer());
    frame.add(comboBox, BorderLayout.NORTH);

    final JLabel label = new JLabel();
    label.setOpaque(true);
    label.setBackground((Color) comboBox.getSelectedItem());
    frame.add(label, BorderLayout.CENTER);

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Color selectedColor = (Color) comboBox.getSelectedItem();
            label.setBackground(selectedColor);
        }
    };
    comboBox.addActionListener(actionListener);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document.compress = false;//from w  w w  . j av  a  2s  .  com
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    cb.circle(26.0f, 50.0f, 25.0f);
    cb.fill();
    cb.saveState();
    cb.setColorFill(Color.yellow);
    cb.circle(26.0f, 50.0f, 20.0f);
    cb.fill();
    cb.saveState();
    cb.setColorFill(Color.red);
    cb.circle(26.0f, 50.0f, 15.0f);
    cb.fill();
    cb.restoreState();
    cb.circle(26.0f, 50.0f, 10.0f);
    cb.fill();
    cb.restoreState();
    cb.circle(26.0f, 50.0f, 5.0f);
    cb.fill();
    document.close();
}

From source file:MainClass.java

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

    JPanel panel = new JPanel();
    panel.setToolTipText("<HtMl>Tooltip<br>Message");
    frame.add(panel, BorderLayout.CENTER);

    JButton button = new JButton("Hello, World") {
        public JToolTip createToolTip() {
            JToolTip tip = super.createToolTip();
            tip.setBackground(Color.YELLOW);
            tip.setForeground(Color.RED);
            return tip;
        }//from   ww  w  .  j ava  2s.c  o  m

        public boolean contains(int x, int y) {
            if (x < 100) {
                setToolTipText("x < 100");
            } else {
                setToolTipText("else");
            }
            return super.contains(x, y);
        }
    };

    button.setToolTipText("Hello, World");
    frame.add(button, BorderLayout.NORTH);

    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:MainClass.java

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

    frame.setLayout(new GridLayout(2, 2));

    Color colors[] = { Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW };
    for (int i = 0; i < 4; i++) {
        MainClass panel = new MainClass(colors[i]);
        frame.add(panel);//from   w w  w  . j av  a 2  s.c om
    }

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

License:asdf

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from ww w .j a va 2  s  .c om*/
    float[] widths = { 1, 4 };
    PdfPTable table = new PdfPTable(widths);
    table.setWidthPercentage(30);
    PdfPCell cell = new PdfPCell(new Paragraph("fox"));
    cell.setBackgroundColor(Color.YELLOW);
    table.addCell(cell);
    table.addCell("asdf");
    document.add(table);
    document.close();
}

From source file:OvalPanel.java

License:asdf

public static void main(String args[]) {
    JFrame frame = new JFrame("Oval Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new GridLayout(2, 2));
    Color colors[] = { Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW };
    for (int i = 0; i < 4; i++) {
        OvalPanel panel = new OvalPanel(colors[i]);
        panel.add(new JButton("asdf"));
        frame.add(panel);/* w ww  . jav a2 s.  c  o m*/
    }
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String... args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel contentPane = new JPanel();

    JFormattedTextField ftf = new JFormattedTextField(NumberFormat.getNumberInstance());
    ftf.setColumns(10);// w  ww.j a  va2 s.  c om
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
    ftf.setValue(100);
    lastValidValue = "100";
    ftf.addCaretListener(e -> {
        System.out.println("Last Valid Value : " + lastValidValue);
        if (ftf.isEditValid()) {
            String latestValue = ftf.getText();
            System.out.println("Latest Value : " + latestValue);
            if (!(latestValue.equals(lastValidValue)))
                ftf.setBackground(Color.YELLOW.darker());
            else {
                lastValidValue = ftf.getText();
                ftf.setBackground(Color.WHITE);
            }
        } else {
            System.out.println("Invalid Edit Entered.");
        }
    });
    contentPane.add(ftf);
    frame.setContentPane(contentPane);
    frame.pack();
    frame.setVisible(true);
}

From source file:ACompoundBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Compound Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Border lineBorder = LineBorder.createBlackLineBorder();
    Border bevelBorder = BorderFactory.createRaisedBevelBorder();
    Border bevelLineBorder = new CompoundBorder(bevelBorder, lineBorder);
    JButton bevelLineButton = new JButton("Bevel Line");
    bevelLineButton.setBorder(bevelLineBorder);
    Border redBorder = BorderFactory.createLineBorder(Color.MAGENTA, 2);
    Border orangeBorder = BorderFactory.createLineBorder(Color.BLUE, 2);
    Border yellowBorder = BorderFactory.createLineBorder(Color.YELLOW, 5);
    Border greenBorder = BorderFactory.createLineBorder(Color.GREEN, 2);
    Border blueBorder = BorderFactory.createLineBorder(Color.ORANGE, 4);
    Border magentaBorder = BorderFactory.createLineBorder(Color.RED, 3);
    Border twoColorBorder = new CompoundBorder(magentaBorder, blueBorder);
    Border threeColorBorder = new CompoundBorder(twoColorBorder, greenBorder);
    Border fourColorBorder = new CompoundBorder(threeColorBorder, yellowBorder);
    Border fiveColorBorder = new CompoundBorder(fourColorBorder, orangeBorder);
    Border sixColorBorder = new CompoundBorder(fiveColorBorder, redBorder);
    JButton rainbowButton = new JButton("Rainbow");
    rainbowButton.setBorder(sixColorBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    contentPane.add(bevelLineButton);//from   w ww  .java2 s. c  o m
    contentPane.add(rainbowButton);
    frame.setSize(300, 100);
    frame.setVisible(true);
}