List of usage examples for java.awt Color Color
public Color(ColorSpace cspace, float[] components, float alpha)
From source file:OutlineActionsHyperLinkPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w . jav a2 s . co m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("OutlineActionsHyperLinkPDF.pdf")); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.open(); document.add(new Paragraph("Outline action example")); PdfContentByte cb = writer.getDirectContent(); PdfOutline root = cb.getRootOutline(); PdfOutline links = new PdfOutline(root, new PdfAction("http://www.java2s.com"), "Useful links"); links.setColor(new Color(0xFF, 0x00, 0x00)); links.setStyle(Font.BOLD); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:com.pos.spatobiz.app.Main.java
/** * @param args the command line arguments *//*from w w w. j a v a2 s. com*/ public static void main(String[] args) { // change bright color DesktopManager.setBrightColor(new Color(141, 223, 0)); // change dark color DesktopManager.setDarkColor(new Color(32, 52, 0)); // get ApplicationContext ApplicationContext applicationContext = SpringUtilities.getApplicationContext(); // get Application Application application = (Application) applicationContext.getBean("application"); // start Application DesktopManager.startApplication(application); }
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();/*from w ww . j av a2s . c o m*/ PdfPTable datatable = new PdfPTable(10); int headerwidths[] = { 10, 24, 12, 12, 7, 7, 7, 7, 7, 7 }; datatable.setWidths(headerwidths); datatable.setWidthPercentage(100); datatable.getDefaultCell().setPadding(5); PdfPCell cell = new PdfPCell( new Phrase("Report", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLD))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderWidth(2); cell.setColspan(10); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); cell.setUseDescender(true); datatable.addCell(cell); document.add(datatable); document.close(); }
From source file:PropertyChangeListenerDemo.java
public static void main(String args[]) { Runnable runner = new Runnable() { public void run() { JFrame frame = new JFrame("Button Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button1 = new JButton("Select Me"); final JButton button2 = new JButton("No Select Me"); final Random random = new Random(); // Define ActionListener ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JButton button = (JButton) actionEvent.getSource(); int red = random.nextInt(255); int green = random.nextInt(255); int blue = random.nextInt(255); button.setBackground(new Color(red, green, blue)); }/*from w w w.j ava2 s . c o m*/ }; // Define PropertyChangeListener PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String property = propertyChangeEvent.getPropertyName(); if ("background".equals(property)) { button2.setBackground((Color) propertyChangeEvent.getNewValue()); } } }; button1.addActionListener(actionListener); button1.addPropertyChangeListener(propertyChangeListener); button2.addActionListener(actionListener); frame.add(button1, BorderLayout.NORTH); frame.add(button2, BorderLayout.SOUTH); frame.setSize(300, 100); frame.setVisible(true); } }; EventQueue.invokeLater(runner); }
From source file:TableHeaderPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); try {//from w w w. jav a 2 s .c o m PdfWriter.getInstance(document, new FileOutputStream("TableHeaderPDF.pdf")); document.open(); Table datatable = new Table(3); int headerwidths[] = { 10, 24, 12 }; datatable.setWidths(headerwidths); datatable.setWidth(46); datatable.setPadding(3); Cell cell = new Cell(new Phrase("title", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLD))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setLeading(30); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); datatable.addCell(cell); datatable.setDefaultCellBorderWidth(2); datatable.setDefaultHorizontalAlignment(1); datatable.addCell("Header 1"); datatable.addCell("Header \n 2"); datatable.addCell("Header 3"); datatable.endHeaders(); datatable.setDefaultCellBorderWidth(1); datatable.setDefaultHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell("1"); datatable.addCell("2"); datatable.addCell("3"); datatable.setDefaultHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell("4"); datatable.addCell("5"); datatable.addCell("6"); document.add(datatable); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:TableCellFitPagePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); try {// w w w . j a v a2 s.com PdfWriter.getInstance(document, new FileOutputStream("TableCellFitPagePDF.pdf")); document.open(); Table datatable = new Table(3); int headerwidths[] = { 10, 24, 12 }; datatable.setWidths(headerwidths); datatable.setWidth(46); datatable.setPadding(3); Cell cell = new Cell(new Phrase("title", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLD))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setLeading(30); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); datatable.addCell(cell); datatable.setDefaultCellBorderWidth(2); datatable.setDefaultHorizontalAlignment(1); datatable.addCell("Header 1"); datatable.addCell("Header \n 2"); datatable.addCell("Header 3"); datatable.endHeaders(); datatable.setDefaultCellBorderWidth(1); for (int i = 0; i < 200; i++) { datatable.setDefaultHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell("1"); datatable.addCell("2"); datatable.addCell("3"); } datatable.setCellsFitPage(true); document.add(datatable); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:ColorComboRenderer.java
public static void main(String[] a) { JComboBox cbColor = new JComboBox(); int[] values = new int[] { 0, 128, 192, 255 }; for (int r = 0; r < values.length; r++) for (int g = 0; g < values.length; g++) for (int b = 0; b < values.length; b++) { Color c = new Color(values[r], values[g], values[b]); cbColor.addItem(c);//from w w w . j a v a 2 s. c om } cbColor.setRenderer(new ColorComboRenderer()); JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.getContentPane().add(cbColor); f.pack(); f.setSize(new Dimension(300, 80)); f.show(); }
From source file:ColorDrag.java
public static void main(String args[]) { // Create two JLabel objects final JLabel label1 = new JLabel("Drag here"); JLabel label2 = new JLabel("Drop here"); // Register TransferHandler objects on them: label1 transfers its // foreground color and label2 transfers its background color. label1.setTransferHandler(new TransferHandler("foreground")); label2.setTransferHandler(new TransferHandler("background")); // Give label1 a foreground color other than the default // Make label2 opaque so it displays its background color label1.setForeground(new Color(100, 100, 200)); label2.setOpaque(true);//from ww w. ja v a2 s. c o m // Now look for drag gestures over label1. When one occurs, // tell the TransferHandler to begin a drag. // Exercise: modify this gesture recognition so that the drag doesn't // begin until the mouse has moved 4 pixels. This helps to keep // drags distinct from sloppy clicks. To do this, you'll need both // a MouseListener and a MouseMotionListener. label1.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { TransferHandler handler = label1.getTransferHandler(); handler.exportAsDrag(label1, e, TransferHandler.COPY); } }); // Create a window, add the labels, and make it all visible. JFrame f = new JFrame("ColorDrag"); f.getContentPane().setLayout(new FlowLayout()); f.getContentPane().add(label1); f.getContentPane().add(label2); f.pack(); f.setVisible(true); }
From source file:edu.gmu.isa681.client.Main.java
public static void main(String[] args) { log.info("Setting look and feel..."); try {//from ww w .j a v a 2s . c o m for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ex1) { log.warn(ex1.getMessage(), ex1); log.warn("Nimbus is not available."); log.warn("Switching to system look and feel"); log.warn("Some GUI discrepancies may occur!"); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex2) { log.error(ex2.getMessage(), ex2); log.error("Could not setup a look and feel."); System.exit(1); } } log.info("Initializing GUI..."); final JFrame frame = new JFrame(); frame.setTitle("GoForward"); frame.setBackground(new Color(0, 100, 0)); UIManager.put("nimbusBase", new Color(0, 100, 0)); //UIManager.put("nimbusBlueGrey", new Color(0, 100, 0)); UIManager.put("control", new Color(0, 100, 0)); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { frame.setPreferredSize(frame.getSize()); } }); Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); if (dim.width < 1366) { frame.setPreferredSize(new Dimension(800, 600)); } else { frame.setPreferredSize(new Dimension(1200, 700)); } //frame.setResizable(false); frame.setLocationByPlatform(true); frame.pack(); Client client = new Client("localhost", Constants.SERVER_PORT); Controller controller = new Controller(client, frame); controller.applicationStarted(); frame.setLocationRelativeTo(null); frame.setVisible(true); log.info("Started"); }
From source file:visualize.Visualize.java
public static void main(String[] args) throws NotEnoughDataPointsException, IllDefinedDataPointsException { XYSeries seriesQ = new XYSeries("quadratic"); XYSeries seriesL = new XYSeries("linear"); XYSeries seriesI = new XYSeries("intepolated"); final ArrayList<Point> pointsQ = new ArrayList<Point>(); for (double x = -5.0; x <= 5.0; x = x + 0.5) pointsQ.add(new Point(new double[] { x, 2.0 * x * x * x - 10 * x * x })); final LinearFunction fl = new LinearFunction(); final HigherOrderPolynomialFunction fq = new HigherOrderPolynomialFunction(3); final InterpolatedPolynomial<LinearFunction, HigherOrderPolynomialFunction> fi = new InterpolatedPolynomial<LinearFunction, HigherOrderPolynomialFunction>( new LinearFunction(), fq.copy(), 0.5); fl.fitFunction(pointsQ);// w w w . j a va2 s. c om fq.fitFunction(pointsQ); fi.fitFunction(pointsQ); System.out.println(fl); System.out.println(fq); System.out.println(fi.interpolatedFunction); for (double x = -5.0; x <= 5.0; x = x + 0.5) { seriesQ.add(x, fq.predict(x)); seriesL.add(x, fl.predict(x)); seriesI.add(x, fi.predict(x)); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(seriesQ); dataset.addSeries(seriesL); dataset.addSeries(seriesI); JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", "x-axis", "y-axis", dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); final XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, new Color(0, 0, 255)); renderer.setSeriesStroke(0, new BasicStroke(0.5f)); renderer.setSeriesPaint(1, new Color(255, 0, 0)); renderer.setSeriesStroke(1, new BasicStroke(0.5f)); renderer.setSeriesPaint(2, new Color(0, 200, 40)); renderer.setSeriesStroke(2, new BasicStroke(1.5f)); //chart.getXYPlot().setRenderer(new XYSplineRenderer(100)); JPanel panel = new JPanel(); ChartPanel chartPanel = new ChartPanel(chart); panel.add(chartPanel); JFrame frame = new JFrame(); frame.setContentPane(panel); frame.validate(); Dimension d = new Dimension(800, 500); frame.setSize(d); frame.setVisible(true); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("starting"); for (int lambda = 0; lambda <= 100; ++lambda) { fi.setLambda(lambda / 100.0); fi.fitFunction(pointsQ); System.out.println(fi.interpolatedFunction); dataset.getSeries(2).clear(); for (double x = -5.0; x <= 5.0; x = x + 0.5) seriesI.add(x, fi.predict(x)); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } // makeScreenshot( lambda ); } }