List of usage examples for java.awt Color green
Color green
To view the source code for java.awt Color green.
Click Source Link
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false);//ww w.j a v a 2 s . co m frame.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel navigation_panel_wrap = new JPanel() { @Override public Dimension getPreferredSize() { return new Dimension(250, 700); } }; JPanel content_panel_wrap = new JPanel() { @Override public Dimension getPreferredSize() { return new Dimension(750, 700); } }; content_panel_wrap.setBackground(Color.green); navigation_panel_wrap.setBackground(Color.red); frame.add(navigation_panel_wrap); frame.add(content_panel_wrap); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { DefaultTableModel model = new DefaultTableModel() { public Class getColumnClass(int mColIndex) { int rowIndex = 0; Object o = getValueAt(rowIndex, mColIndex); if (o == null) { return Object.class; } else { return o.getClass(); }/*w ww . j av a 2 s .c om*/ } }; JTable table = new JTable(model); model.addColumn("Col1", new Object[] { Color.red }); model.addRow(new Object[] { Color.green }); model.addRow(new Object[] { Color.blue }); table.setDefaultRenderer(Color.class, new ColorTableCellRenderer()); JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:ComplexRenderingSample.java
public static void main(String args[]) { Object elements[][] = {//from w w w .jav a 2 s .c om { new Font("Helvetica", Font.PLAIN, 20), Color.red, new DiamondIcon(Color.blue), "Help" }, { new Font("TimesRoman", Font.BOLD, 14), Color.blue, new DiamondIcon(Color.green), "Me" }, { new Font("Courier", Font.ITALIC, 18), Color.green, new DiamondIcon(Color.black), "I'm" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.gray, new DiamondIcon(Color.magenta), "Trapped" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.pink, new DiamondIcon(Color.yellow), "Inside" }, { new Font("Courier", Font.BOLD, 16), Color.yellow, new DiamondIcon(Color.red), "This" }, { new Font("Helvetica", Font.ITALIC, 8), Color.darkGray, new DiamondIcon(Color.pink), "Computer" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); JList jlist = new JList(elements); ListCellRenderer renderer = new ComplexCellRenderer(); jlist.setCellRenderer(renderer); JScrollPane scrollPane = new JScrollPane(jlist); contentPane.add(scrollPane, BorderLayout.CENTER); JComboBox comboBox = new JComboBox(elements); comboBox.setRenderer(renderer); contentPane.add(comboBox, BorderLayout.NORTH); frame.setSize(300, 300); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setSize(300, 200);//www . j a v a 2s . c o m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton redButton = new JButton("Red"); JButton greenButton = new JButton("Green"); JButton blueButton = new JButton("Blue"); class Listener extends JPanel implements ActionListener { public void actionPerformed(ActionEvent event) { Color color; if (event.getSource() == redButton) { color = Color.red; redButton.setBackground(color); panel.setBackground(color); } else if (event.getSource() == greenButton) { color = Color.green; greenButton.setBackground(color); panel.setBackground(color); } else { color = Color.blue; blueButton.setBackground(color); panel.setBackground(color); } setBackground(color); repaint(); } } redButton.addActionListener(new Listener()); greenButton.addActionListener(new Listener()); blueButton.addActionListener(new Listener()); panel.add(redButton); panel.add(greenButton); panel.add(blueButton); frame.add(panel); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Changed Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTree tree = new JTree(); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); renderer.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 32)); int rowHeight = tree.getRowHeight(); if (rowHeight <= 0) { tree.setRowHeight(rowHeight - 1); }//from w w w. j a va2s . co m Color backgroundSelection = renderer.getBackgroundSelectionColor(); renderer.setBackgroundSelectionColor(Color.blue); renderer.setBackgroundNonSelectionColor(backgroundSelection); // Swap text colors Color textSelection = renderer.getTextSelectionColor(); renderer.setTextSelectionColor(Color.green); renderer.setTextNonSelectionColor(textSelection); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); 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 www .ja va 2 s .co m contentPane.add(rainbowButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:EditableColorColumn.java
public static void main(String args[]) { Color choices[] = { Color.red, Color.orange, Color.yellow, Color.green, Color.blue, Color.magenta }; ComboTableCellRenderer renderer = new ComboTableCellRenderer(); JComboBox comboBox = new JComboBox(choices); comboBox.setRenderer(renderer);/*from w w w.j a va 2 s.c om*/ TableCellEditor editor = new DefaultCellEditor(comboBox); JFrame frame = new JFrame("Editable Color Table"); TableModel model = new ColorTableModel(); JTable table = new JTable(model); TableColumn column = table.getColumnModel().getColumn(3); column.setCellRenderer(renderer); column.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(table); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(400, 150); frame.setVisible(true); }
From source file:CellBorderColorsPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4); try {/*from ww w . ja va 2 s . c om*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("CellBorderColorsPDF.pdf")); document.open(); PdfPTable table = new PdfPTable(1); PdfPCell cell = new PdfPCell(new Paragraph("test colors:")); table.addCell(cell); cell = new PdfPCell(new Paragraph("red")); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(Color.red); table.addCell(cell); cell = new PdfPCell(new Paragraph("green")); cell.setBorder(Rectangle.BOTTOM); cell.setBorderColorBottom(Color.magenta); cell.setBorderWidthBottom(10f); cell.setBackgroundColor(Color.green); table.addCell(cell); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(PageSize.A4.rotate()); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/* www. j a va 2s.co m*/ PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100); PdfPCell cell; cell = new PdfPCell(new Paragraph("t")); table.addCell(cell); cell = new PdfPCell(new Paragraph("d")); cell.setBorder(Rectangle.TOP); cell.setUseBorderPadding(true); cell.setBorderWidthTop(5f); cell.setBorderColorTop(Color.cyan); cell.setBackgroundColor(Color.blue); cell.setBorder(Rectangle.BOTTOM); cell.setBorderColorBottom(Color.magenta); cell.setBorderWidthBottom(10f); cell.setBackgroundColor(Color.green); table.addCell(cell); cell = new PdfPCell(new Paragraph("r")); table.addCell(cell); cell = new PdfPCell(new Paragraph("b")); table.addCell(cell); cell = new PdfPCell(new Paragraph("G:")); table.addCell(cell); cell = new PdfPCell(new Paragraph("0.25")); table.addCell(cell); cell = new PdfPCell(new Paragraph("0.5")); table.addCell(cell); cell = new PdfPCell(new Paragraph("0.75")); table.addCell(cell); cell = new PdfPCell(new Paragraph(":")); table.addCell(cell); cell = new PdfPCell(new Paragraph("a")); table.addCell(cell); cell = new PdfPCell(new Paragraph("b")); table.addCell(cell); cell = new PdfPCell(new Paragraph("o")); table.addCell(cell); document.add(table); document.close(); }
From source file:TreeNodeVector.java
public static void main(final String args[]) { JFrame frame = new JFrame("JTreeSample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> v1 = new TreeNodeVector<String>("Two", new String[] { "Mercury", "Venus", "Mars" }); Vector<Object> v2 = new TreeNodeVector<Object>("Three"); v2.add(System.getProperties()); v2.add(v1);//from w w w.java 2 s .co m Object rootNodes[] = { v1, v2 }; Vector<Object> rootVector = new TreeNodeVector<Object>("Root", rootNodes); JTree tree = new JTree(rootVector); UIManager.put("Tree.line", Color.GREEN); tree.putClientProperty("JTree.lineStyle", "Horizontal"); frame.add(new JScrollPane(tree), BorderLayout.CENTER); frame.setSize(300, 300); frame.setVisible(true); }