Example usage for java.awt Color green

List of usage examples for java.awt Color green

Introduction

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

Prototype

Color green

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

Click Source Link

Document

The color green.

Usage

From source file:Main.java

public static void main(String[] args) {
    int specificX = 40;
    int specificY = 20;

    JPanel gui = new JPanel(new BorderLayout());
    JTextField tf = new JTextField(10);
    JPanel borderPanel = new JPanel(new GridLayout());
    borderPanel.add(tf);/*from  w w  w. ja v a 2s . c o m*/
    borderPanel.setBorder(new EmptyBorder(specificX, specificY, specificX, specificY));
    borderPanel.setBackground(Color.GREEN);
    gui.add(borderPanel);

    JOptionPane.showMessageDialog(null, gui);

}

From source file:MainClass.java

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

    Object iconObject = LookAndFeel.makeIcon(MainClass.class, "yourImage.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    Integer fifteen = new Integer(15);
    Object lazyArgs[] = new Object[] { Color.GREEN, Boolean.TRUE, fifteen, fifteen };
    Object lazyDiamond = new UIDefaults.ProxyLazyValue("DiamondIcon", lazyArgs);
    UIManager.put("Tree.openIcon", lazyDiamond);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);// w w w  . j  a  va 2  s .  c  om
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    SpringLayout layout = new SpringLayout();
    JPanel p = new JPanel(layout);
    p.setBorder(BorderFactory.createLineBorder(Color.GREEN, 10));

    JLabel l1 = new JLabel("label: width=90%", SwingConstants.CENTER);
    l1.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
    JButton l2 = new JButton("button: width=50%");

    Spring panelw = layout.getConstraint(WIDTH, p);

    SpringLayout.Constraints c1 = layout.getConstraints(l1);
    c1.setX(Spring.constant(0));/*from ww  w . jav a 2 s.co m*/
    c1.setY(Spring.constant(20));
    c1.setWidth(Spring.scale(panelw, 0.9f));
    p.add(l1);

    SpringLayout.Constraints c2 = layout.getConstraints(l2);
    c2.setWidth(Spring.scale(panelw, 0.5f));
    layout.putConstraint(SOUTH, l2, -20, SOUTH, p);
    layout.putConstraint(EAST, l2, -20, EAST, p);
    p.add(l2);

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.getContentPane().add(p);
    f.setSize(320, 240);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = img.createGraphics();
    g.setColor(Color.white);//from   w  w  w . java2s .co  m
    g.fillRect(0, 0, 20, 20);
    g.setColor(Color.black);
    g.fillRect(5, 5, 10, 10);

    Color[] mapping = new Color[] { Color.black, Color.white, // replace black with white 
            Color.white, Color.green // and white with green
    };

    ImageIO.write(img, "png", new File("original.png"));
    swapColors(img, mapping);
    ImageIO.write(img, "png", new File("swapped.png"));
}

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 a v a 2s.com
    }

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

From source file:LazySample.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Lazy Example");

    Object iconObject = LookAndFeel.makeIcon(LazySample.class, "World.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    Integer fifteen = new Integer(15);
    Object lazyArgs[] = new Object[] { Color.green, Boolean.TRUE, fifteen, fifteen };
    Object lazyDiamond = new UIDefaults.ProxyLazyValue("DiamondIcon", lazyArgs);
    UIManager.put("Tree.openIcon", lazyDiamond);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    Container contentPane = frame.getContentPane();
    contentPane.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);/* www .  java  2s.co m*/
    frame.setVisible(true);
}

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);/* ww  w. j a  v a  2 s.  c  om*/
    }
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    int w, h;//from   w  w  w. j  a v a  2 s.c o  m
    w = 150;
    h = 150;
    Ellipse2D.Double circle = new Ellipse2D.Double(12, 12, 12, 12);

    Document document = new Document(new Rectangle(w, h));

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("sun_tutorial.pdf"));
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    Graphics2D g2 = cb.createGraphics(w, h);

    g2.setColor(Color.green);

    g2.fill(circle);

    g2.dispose();

    document.close();
}

From source file:MainClass.java

public static void main(String[] a) {
    final int STRING_POSITION = 1;
    Object buttonColors[][] = { { Color.RED, "RED" }, { Color.BLUE, "BLUE" }, { Color.GREEN, "GREEN" },
            { Color.BLACK, "BLACK" }, null, // separator
            { Color.CYAN, "CYAN" } };

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ActionListener actionListener = new TheActionListener();

    JToolBar toolbar = new JToolBar();
    toolbar.setRollover(true);/*from w  w  w  . j  a v a2  s. co m*/

    for (Object[] color : buttonColors) {
        if (color == null) {
            toolbar.addSeparator();
        } else {
            Icon icon = MetalIconFactory.getTreeComputerIcon();
            JButton button = new JButton(icon);
            button.setActionCommand((String) color[STRING_POSITION]);
            button.addActionListener(actionListener);
            toolbar.add(button);
        }
    }

    Action action = new ShowAction(toolbar);
    JButton button = new JButton(action);
    toolbar.add(button);

    Container contentPane = frame.getContentPane();
    contentPane.add(toolbar, BorderLayout.NORTH);
    JTextArea textArea = new JTextArea();
    JScrollPane pane = new JScrollPane(textArea);
    contentPane.add(pane, BorderLayout.CENTER);
    frame.setSize(350, 150);
    frame.setVisible(true);

}

From source file:PatternColorPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {/*from   w  w  w.  j  a va2  s  . c o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PatternColorPDF.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();

        PdfPatternPainter pat = cb.createPattern(10, 10, null);
        pat.setLineWidth(2);
        pat.moveTo(0, -5);
        pat.lineTo(15, 10);
        pat.stroke();

        cb.setPatternFill(pat, Color.green);
        cb.rectangle(100, 400, 30, 210);
        cb.fillStroke();

    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}