List of usage examples for java.awt Color DARK_GRAY
Color DARK_GRAY
To view the source code for java.awt Color DARK_GRAY.
Click Source Link
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("First Name"); label.setForeground(Color.DARK_GRAY); JFrame frame = new JFrame(); frame.add(label);//from w ww. j a v a 2 s .co m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(20, 20, 500, 500); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Object elements[][] = { { new Font("Courier", Font.BOLD, 16), Color.YELLOW, "This" }, { new Font("Helvetica", Font.ITALIC, 8), Color.DARK_GRAY, "Computer" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(elements); ListCellRenderer renderer = new ComplexCellRenderer(); jlist.setCellRenderer(renderer);/*www.j a va2s. c o m*/ JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT)); statusBar.setBorder(new CompoundBorder(new LineBorder(Color.DARK_GRAY), new EmptyBorder(4, 4, 4, 4))); final JLabel status = new JLabel(); statusBar.add(status);//from ww w .j a va2 s . c om JLabel content = new JLabel("Content in the middle"); content.setHorizontalAlignment(JLabel.CENTER); final JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(content); frame.add(statusBar, BorderLayout.SOUTH); frame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { status.setText(frame.getWidth() + "x" + frame.getHeight()); } }); frame.setBounds(20, 20, 200, 200); frame.setVisible(true); }
From source file:ComplexCellRenderer.java
public static void main(String args[]) { Object elements[][] = { { new Font("Helvetica", Font.PLAIN, 20), Color.RED, new MyIcon(), "A" }, { new Font("TimesRoman", Font.BOLD, 14), Color.BLUE, new MyIcon(), "A" }, { new Font("Courier", Font.ITALIC, 18), Color.GREEN, new MyIcon(), "A" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.GRAY, new MyIcon(), "A" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.PINK, new MyIcon(), "A" }, { new Font("Courier", Font.BOLD, 16), Color.YELLOW, new MyIcon(), "A" }, { new Font("Helvetica", Font.ITALIC, 8), Color.DARK_GRAY, new MyIcon(), "A" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ListCellRenderer renderer = new ComplexCellRenderer(); JComboBox comboBox = new JComboBox(elements); comboBox.setRenderer(renderer);//from ww w . j a v a 2s . c om frame.add(comboBox, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ComplexCellRenderer.java
public static void main(String args[]) { Object elements[][] = { { new Font("Helvetica", Font.PLAIN, 20), Color.RED, new MyIcon(), "A" }, { new Font("TimesRoman", Font.BOLD, 14), Color.BLUE, new MyIcon(), "A" }, { new Font("Courier", Font.ITALIC, 18), Color.GREEN, new MyIcon(), "A" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.GRAY, new MyIcon(), "A" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.PINK, new MyIcon(), "A" }, { new Font("Courier", Font.BOLD, 16), Color.YELLOW, new MyIcon(), "A" }, { new Font("Helvetica", Font.ITALIC, 8), Color.DARK_GRAY, new MyIcon(), "A" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(elements); ListCellRenderer renderer = new ComplexCellRenderer(); jlist.setCellRenderer(renderer);//from w w w . j a v a2 s .c om JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:PowerMethod.power_method.java
public static void main(String[] args) { ////////////////////////////////////////////////////// // Edit vals to contain values for matrix A // // Edit vals2 to contain values for initial vector // ////////////////////////////////////////////////////// double[][] vals = { { 3, 4 }, { 3, 1 } }; RealMatrix A = new Array2DRowRealMatrix(vals); double[][] vals2 = { { 1 }, { 1 } }; RealMatrix u = new Array2DRowRealMatrix(vals2); power_object a = power_method(A, u, .1, 7); List<RealMatrix> matrices = genMatrices(); List<trace_det> trace_dets = new ArrayList<>(); double trace; double det;//from w w w.j av a 2 s .c om int iterA; int iterInverseA; for (RealMatrix r : matrices) { MatrixMethods m = new MatrixMethods(r); RealMatrix inverseR = m.inverseMatrix(); power_object largestVal = power_method(r, u, .00005, 100); power_object smallestVal = power_method(inverseR, u, .00005, 100); if (largestVal == null || smallestVal == null) { continue; } trace = m.trace(); det = m.determinant(); iterA = largestVal.getNumN(); iterInverseA = smallestVal.getNumN(); trace_det td = new trace_det(trace, det, iterA, iterInverseA); trace_dets.add(td); } JFreeChart chart = ChartFactory.createXYLineChart("Trace vs. Determinant for Power Method", "Determinant", "Trace", createDataSetA(trace_dets), PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesPaint(2, Color.GREEN); renderer.setSeriesPaint(3, Color.BLACK); renderer.setSeriesPaint(4, Color.YELLOW); renderer.setSeriesPaint(5, Color.PINK); renderer.setSeriesPaint(6, Color.ORANGE); renderer.setSeriesPaint(7, Color.GRAY); renderer.setSeriesPaint(8, Color.MAGENTA); renderer.setSeriesPaint(9, Color.LIGHT_GRAY); renderer.setSeriesPaint(10, Color.DARK_GRAY); //renderer.setSeriesStroke( 0 , new BasicStroke( 3.0f ) ); //renderer.setSeriesStroke( 1 , new BasicStroke( 2.0f ) ); plot.setRenderer(renderer); ChartFrame frame = new ChartFrame("Power Method", chart); frame.pack(); frame.setVisible(true); JFreeChart inverseChart = ChartFactory.createXYLineChart("Trace vs. Determinant for Inverse Power Method", "Determinant", "Trace", createDataSetAInverse(trace_dets), PlotOrientation.VERTICAL, true, true, false); ChartPanel inverseChartPanel = new ChartPanel(inverseChart); inverseChartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot inversePlot = inverseChart.getXYPlot(); XYLineAndShapeRenderer inverseRenderer = new XYLineAndShapeRenderer(); inverseRenderer.setSeriesPaint(0, Color.RED); inverseRenderer.setSeriesPaint(1, Color.BLUE); inverseRenderer.setSeriesPaint(2, Color.GREEN); inverseRenderer.setSeriesPaint(3, Color.BLACK); inverseRenderer.setSeriesPaint(4, Color.YELLOW); inverseRenderer.setSeriesPaint(5, Color.PINK); inverseRenderer.setSeriesPaint(6, Color.ORANGE); inverseRenderer.setSeriesPaint(7, Color.GRAY); inverseRenderer.setSeriesPaint(8, Color.MAGENTA); inverseRenderer.setSeriesPaint(9, Color.LIGHT_GRAY); inverseRenderer.setSeriesPaint(10, Color.DARK_GRAY); inversePlot.setRenderer(renderer); ChartFrame inverseFrame = new ChartFrame("Power Method", inverseChart); inverseFrame.pack(); inverseFrame.setVisible(true); }
From source file:Graph_with_jframe_and_arduino.java
public static void main(String[] args) { // create and configure the window JFrame window = new JFrame(); window.setTitle("Sensor Graph GUI"); window.setSize(600, 400);// w w w .j a va 2 s . c om window.setLayout(new BorderLayout()); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // create a drop-down box and connect button, then place them at the top of the window JComboBox<String> portList_combobox = new JComboBox<String>(); Dimension d = new Dimension(300, 100); portList_combobox.setSize(d); JButton connectButton = new JButton("Connect"); JPanel topPanel = new JPanel(); topPanel.add(portList_combobox); topPanel.add(connectButton); window.add(topPanel, BorderLayout.NORTH); //pause button JButton Pause_btn = new JButton("Start"); // populate the drop-down box SerialPort[] portNames; portNames = SerialPort.getCommPorts(); //check for new port available Thread thread_port = new Thread() { @Override public void run() { while (true) { SerialPort[] sp = SerialPort.getCommPorts(); if (sp.length > 0) { for (SerialPort sp_name : sp) { int l = portList_combobox.getItemCount(), i; for (i = 0; i < l; i++) { //check port name already exist or not if (sp_name.getSystemPortName().equalsIgnoreCase(portList_combobox.getItemAt(i))) { break; } } if (i == l) { portList_combobox.addItem(sp_name.getSystemPortName()); } } } else { portList_combobox.removeAllItems(); } portList_combobox.repaint(); } } }; thread_port.start(); for (SerialPort sp_name : portNames) portList_combobox.addItem(sp_name.getSystemPortName()); //for(int i = 0; i < portNames.length; i++) // portList.addItem(portNames[i].getSystemPortName()); // create the line graph XYSeries series = new XYSeries("line 1"); XYSeries series2 = new XYSeries("line 2"); XYSeries series3 = new XYSeries("line 3"); XYSeries series4 = new XYSeries("line 4"); for (int i = 0; i < 100; i++) { series.add(x, 0); series2.add(x, 0); series3.add(x, 0); series4.add(x, 10); x++; } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); dataset.addSeries(series2); XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(series3); dataset2.addSeries(series4); //create jfree chart JFreeChart chart = ChartFactory.createXYLineChart("Sensor Readings", "Time (seconds)", "Arduino Reading", dataset); JFreeChart chart2 = ChartFactory.createXYLineChart("Sensor Readings", "Time (seconds)", "Arduino Reading 2", dataset2); //color render for chart 1 XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); r1.setSeriesPaint(0, Color.RED); r1.setSeriesPaint(1, Color.GREEN); r1.setSeriesShapesVisible(0, false); r1.setSeriesShapesVisible(1, false); XYPlot plot = chart.getXYPlot(); plot.setRenderer(0, r1); plot.setRenderer(1, r1); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.blue); //color render for chart 2 XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer(); r2.setSeriesPaint(0, Color.BLUE); r2.setSeriesPaint(1, Color.ORANGE); r2.setSeriesShapesVisible(0, false); r2.setSeriesShapesVisible(1, false); XYPlot plot2 = chart2.getXYPlot(); plot2.setRenderer(0, r2); plot2.setRenderer(1, r2); ChartPanel cp = new ChartPanel(chart); ChartPanel cp2 = new ChartPanel(chart2); //multiple graph container JPanel graph_container = new JPanel(); graph_container.setLayout(new BoxLayout(graph_container, BoxLayout.X_AXIS)); graph_container.add(cp); graph_container.add(cp2); //add chart panel in main window window.add(graph_container, BorderLayout.CENTER); //window.add(cp2, BorderLayout.WEST); window.add(Pause_btn, BorderLayout.AFTER_LAST_LINE); Pause_btn.setEnabled(false); //pause btn action Pause_btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (Pause_btn.getText().equalsIgnoreCase("Pause")) { if (chosenPort.isOpen()) { try { Output.write(0); } catch (IOException ex) { Logger.getLogger(Graph_with_jframe_and_arduino.class.getName()).log(Level.SEVERE, null, ex); } } Pause_btn.setText("Start"); } else { if (chosenPort.isOpen()) { try { Output.write(1); } catch (IOException ex) { Logger.getLogger(Graph_with_jframe_and_arduino.class.getName()).log(Level.SEVERE, null, ex); } } Pause_btn.setText("Pause"); } throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); // configure the connect button and use another thread to listen for data connectButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (connectButton.getText().equals("Connect")) { // attempt to connect to the serial port chosenPort = SerialPort.getCommPort(portList_combobox.getSelectedItem().toString()); chosenPort.setComPortTimeouts(SerialPort.TIMEOUT_SCANNER, 0, 0); if (chosenPort.openPort()) { Output = chosenPort.getOutputStream(); connectButton.setText("Disconnect"); Pause_btn.setEnabled(true); portList_combobox.setEnabled(false); } // create a new thread that listens for incoming text and populates the graph Thread thread = new Thread() { @Override public void run() { Scanner scanner = new Scanner(chosenPort.getInputStream()); while (scanner.hasNextLine()) { try { String line = scanner.nextLine(); int number = Integer.parseInt(line); series.add(x, number); series2.add(x, number / 2); series3.add(x, number / 1.5); series4.add(x, number / 5); if (x > 100) { series.remove(0); series2.remove(0); series3.remove(0); series4.remove(0); } x++; window.repaint(); } catch (Exception e) { } } scanner.close(); } }; thread.start(); } else { // disconnect from the serial port chosenPort.closePort(); portList_combobox.setEnabled(true); Pause_btn.setEnabled(false); connectButton.setText("Connect"); } } }); // show the window window.setVisible(true); }
From source file:org.signserver.admin.gui.SignServerAdminGUIApplication.java
/** * Main method launching the application. */// w w w . jav a 2 s.c o m public static void main(String[] args) { LOG.debug("SignServer Administration GUI startup"); final SplashScreen splash = SplashScreen.getSplashScreen(); if (splash == null) { LOG.debug("No splash screen available."); } else { // Fill in version and copyright information final Graphics2D image = splash.createGraphics(); image.setPaint(Color.BLACK); image.setFont(new Font("Arial", Font.BOLD, 14)); image.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); final ResourceMap resourceMap = getApplication().getContext() .getResourceMap(SignServerAdminGUIApplicationAboutBox.class); final String version = "Version " + resourceMap.getString("appVendorLabel1.text"); ; image.drawString(version, 512 - image.getFontMetrics().stringWidth(version), 215); image.setPaint(Color.DARK_GRAY); image.drawString(resourceMap.getString("appCopyright.text"), 12, 392); splash.update(); } try { // Parse the command line final CommandLine line = new GnuParser().parse(OPTIONS, args); if (line.hasOption(OPTION_HELP)) { printUsage(); } else { if (line.hasOption(OPTION_WS)) { protocol = Protocol.WS; } else { if (isNamingContextAvailable()) { protocol = Protocol.EJB; } else { JOptionPane.showMessageDialog(null, "Application server libraries not detected." + "\n\nTo connect to a locally running SignServer instance " + "\nplease append the appropriate application server " + "\nJAR-files and if needed a jndi.properties file." + "\n\nTo connect using web services invoke this command " + "\nwith the argument \"-ws\"."); protocol = Protocol.WS; } } if (line.hasOption(OPTION_CONNECTFILE)) { connectFile = new File(line.getOptionValue(OPTION_CONNECTFILE)); } if (line.hasOption(OPTION_DEFAULTCONNECTFILE)) { defaultConnectFile = new File(line.getOptionValue(OPTION_DEFAULTCONNECTFILE)); } if (line.hasOption(OPTION_BASEDIR)) { baseDir = new File(line.getOptionValue(OPTION_BASEDIR)); } try { launch(SignServerAdminGUIApplication.class, args); } catch (Exception ex) { displayException(ex); } } } catch (ParseException ex) { throw new IllegalArgumentException(ex.getLocalizedMessage(), ex); } }
From source file:GridLayoutDemo.java
private static JComponent createComponent(String s) { JLabel l = new JLabel(s); l.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.DARK_GRAY)); l.setHorizontalAlignment(JLabel.CENTER); return l;/*from ww w .ja v a 2s .co m*/ }
From source file:BoxLayoutDemo.java
private static JComponent createComponent(String s) { JLabel l = new JLabel(s); l.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.DARK_GRAY)); l.setHorizontalAlignment(JLabel.CENTER); l.setAlignmentX(Component.CENTER_ALIGNMENT); //use middle of row return l;/* w w w. j av a 2 s.c o m*/ }