List of usage examples for java.awt Color BLACK
Color BLACK
To view the source code for java.awt Color BLACK.
Click Source Link
From source file:StocksTable5.java
public StocksTable5() { super("Stocks Table"); setSize(600, 300);/* w w w . jav a 2 s .co m*/ m_data = new StockTableData(); m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT); m_title.setFont(new Font("TimesRoman", Font.BOLD, 24)); m_title.setForeground(Color.black); getContentPane().add(m_title, BorderLayout.NORTH); m_table = new JTable(); m_table.setAutoCreateColumnsFromModel(false); m_table.setModel(m_data); for (int k = 0; k < StockTableData.m_columns.length; k++) { DefaultTableCellRenderer renderer = new ColoredTableCellRenderer(); renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment); TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null); m_table.addColumn(column); } JTableHeader header = m_table.getTableHeader(); header.setUpdateTableInRealTime(true); header.addMouseListener(m_data.new ColumnListener(m_table)); header.setReorderingAllowed(true); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:spectrex.Charts.java
/** * @param data initial data for chart creation * @param title text which would be displayed at the top of the frame and in * the frame's title//from w w w . ja v a 2s . com * @param columnLabel text which would be displayed on the left of the * Y-axis * @param rowLabel text which would be displayed under X-axis * @param frameSize size of chart frame * @return Bar chart JFrame link * @author ReaLgressA */ public static JFrame createBarChart(ChartData data, String title, String columnLabel, String rowLabel, Dimension frameSize) { JFreeChart chart = ChartFactory.createStackedBarChart(title, columnLabel, rowLabel, data.getDataset(), PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame(title, chart, true); frame.setVisible(true); frame.setSize(frameSize); frame.setResizable(true); return (JFrame) frame; }
From source file:AppletMenuBarDemo.java
public void init() { AppletMenuBar menubar = new AppletMenuBar(); menubar.setForeground(Color.black); menubar.setHighlightColor(Color.red); menubar.setFont(new Font("helvetica", Font.BOLD, 12)); this.setLayout(new BorderLayout()); this.add(menubar, BorderLayout.NORTH); PopupMenu file = new PopupMenu(); file.add("New..."); file.add("Open..."); file.add("Save As..."); PopupMenu edit = new PopupMenu(); edit.add("Cut"); edit.add("Copy"); edit.add("Paste"); menubar.addMenu("File", file); menubar.addMenu("Edit", edit); }
From source file:StocksTable.java
public StocksTable() { super("Stocks Table"); setSize(600, 300);// w w w . j a v a 2 s .com m_data = new StockTableData(); m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT); m_title.setFont(new Font("TimesRoman", Font.BOLD, 24)); m_title.setForeground(Color.black); getContentPane().add(m_title, BorderLayout.NORTH); m_table = new JTable(); m_table.setAutoCreateColumnsFromModel(false); m_table.setModel(m_data); for (int k = 0; k < StockTableData.m_columns.length; k++) { DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment); TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null); m_table.addColumn(column); } JTableHeader header = m_table.getTableHeader(); header.setUpdateTableInRealTime(false); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:org.jax.maanova.plot.PlotUtil.java
/** * Create a simple XY renderer which can be used for scatter plots * @return the renderer//from w ww . j a v a 2 s. c o m */ public static XYLineAndShapeRenderer createSimpleScatterPlotRenderer() { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setAutoPopulateSeriesShape(false); renderer.setAutoPopulateSeriesOutlinePaint(false); renderer.setAutoPopulateSeriesOutlineStroke(false); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseShape(new Ellipse2D.Float(-PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, -PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS)); renderer.setUseOutlinePaint(true); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setBaseOutlineStroke(new BasicStroke(0.25F)); renderer.setSeriesPaint(0, new Color(0x55, 0x55, 0xFF)); // blue renderer.setSeriesPaint(1, new Color(0xFF, 0x55, 0x55)); // red return renderer; }
From source file:org.drugis.addis.gui.LyndOBrienChartFactory.java
public static JFreeChart buildScatterPlot(LyndOBrienModel model) { XYDataset data = new ScatterPlotDataset(model); JFreeChart chart = ChartFactory.createScatterPlot("Benefit-Risk plane", model.getXAxisName(), model.getYAxisName(), data, PlotOrientation.VERTICAL, false, false, false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); renderer.setSeriesOutlinePaint(0, Color.black); renderer.setUseOutlinePaint(true);//from w w w . ja v a 2 s. c om renderer.setSeriesShape(0, new Ellipse2D.Double(-2.0, 2.0, 4.0, 4.0)); // draw lines through origin. chart.getXYPlot().setDomainZeroBaselineVisible(true); chart.getXYPlot().setRangeZeroBaselineVisible(true); // Explicitly set the stroke-width to avoid a rendering error in Linux Stroke stroke = new BasicStroke(1.0f); chart.getXYPlot().setDomainZeroBaselineStroke(stroke); return chart; }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D twoD = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); twoD.setRenderingHints(rh);// w ww . j a v a 2 s . co m twoD.setColor(Color.BLACK); twoD.drawString(raised, 5, 90); }
From source file:Main.java
public Main() { for (int i = 0; i < panels.length; i++) { final String[] labels = new String[] { "0", "1" }; final Random rand = new Random(); int index = rand.nextInt(labels.length); String randomTitle = labels[index]; final JLabel label = new JLabel(randomTitle, JLabel.CENTER); Timer lblt = new Timer(00, new ActionListener() { @Override//from w ww. j av a 2 s .c o m public void actionPerformed(ActionEvent ae) { label.setText(labels[rand.nextInt(labels.length)]); } }); lblt.setRepeats(true); lblt.start(); label.setForeground(Color.green); label.setVerticalAlignment(JLabel.CENTER); panels[i] = new JPanel(); panels[i].setBackground(Color.BLACK); panels[i].add(label); frame.getContentPane().add(panels[i]); } frame.setLayout(new GridLayout(grid, grid)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH); frame.setVisible(true); ActionListener action = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (int i = 0; i < panels.length; i++) { Color mix = new Color(255, 255, 255); Random random = new Random(); int r = random.nextInt(255); int g = random.nextInt(255); int b = random.nextInt(255); if (mix != null) { r = (r + mix.getRed()) / 2; g = (g + mix.getGreen()) / 2; b = (b + mix.getBlue()) / 2; } Color color = new Color(r, g, b); panels[i].setBackground(color); } } }; t = new Timer(00, action); t.setRepeats(true); t.start(); }
From source file:Scribble.java
/** Respond to mouse drags */ public boolean mouseDrag(Event e, int x, int y) { g.setColor(Color.black); g.drawLine(lastx, lasty, x, y); // Draw from last position to here lastx = x;//w w w . j a v a 2s.c om lasty = y; // And remember new last position return true; }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.RED);//from w w w . j a v a 2s .c o m g2d.drawLine(getWidth() / 2, 0, getWidth() / 2, getHeight()); g2d.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2); Font font = new Font("Arial", Font.BOLD, 48); g2d.setFont(font); FontMetrics fm = g2d.getFontMetrics(); int x = ((getWidth() - fm.stringWidth(text)) / 2); int y = ((getHeight() - fm.getHeight()) / 2) + fm.getAscent(); g2d.setColor(Color.BLACK); g2d.drawString(text, x, y); g2d.dispose(); }