List of usage examples for javax.swing UIManager getColor
public static Color getColor(Object key)
From source file:au.org.ala.delta.ui.MessageDialogHelper.java
/** * Creates a text area that looks like a JLabel that has a preferredSize calculated to fit * all of the supplied text wrapped at the supplied column. * @param text the text to display in the JTextArea. * @param numColumns the column number to wrap text at. * @return a new JTextArea configured for the supplied text. *//*from w ww .j a v a 2 s . c o m*/ private static JTextArea createMessageDisplay(String text, int numColumns) { JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setBackground(UIManager.getColor("Label.background")); textArea.setFont(UIManager.getFont("Label.font")); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); textArea.setColumns(numColumns); String wrapped = WordUtils.wrap(text, numColumns); textArea.setRows(wrapped.split("\n").length - 1); textArea.setText(text); // Need to set a preferred size so that under OpenJDK-6 on Linux the JOptionPanes get reasonable bounds textArea.setPreferredSize(new Dimension(0, 0)); return textArea; }
From source file:com.github.alexfalappa.nbspringboot.projects.initializr.InitializrProjectPanelVisual2.java
public InitializrProjectPanelVisual2() { initComponents();/* w ww . j a v a2s . com*/ // setup key listener on search field linked to dependencies panel FilterFieldListener ffl = new FilterFieldListener(pBootDependencies); txFilter.addKeyListener(ffl); txFilter.getDocument().addDocumentListener(ffl); // fix white area showing when the scroller is wider than the dependencies panel on some LAFs // for some reasons setting the UIManager color directly doesn't work it must be copied in a new Color object final Color cr = UIManager.getColor("Panel.background"); scroller.getViewport().setBackground(new Color(cr.getRGB())); }
From source file:ExtendedTableCellRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { super.setForeground(table.getSelectionForeground()); super.setBackground(table.getSelectionBackground()); } else {/*w w w . j a va 2s . com*/ super.setForeground((unselectedForeground != null) ? unselectedForeground : table.getForeground()); super.setBackground((unselectedBackground != null) ? unselectedBackground : table.getBackground()); } setFont(table.getFont()); if (hasFocus) { setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); if (table.isCellEditable(row, column)) { super.setForeground(UIManager.getColor("Table.focusCellForeground")); super.setBackground(UIManager.getColor("Table.focusCellBackground")); } } else { setBorder(NO_FOCUS_BORDER); } setValue(value); Color background = getBackground(); boolean colorMatch = (background != null) && (background.equals(table.getBackground())) && table.isOpaque(); setOpaque(!colorMatch); return this; }
From source file:de.aidger.view.utils.Charts.java
/** * Creates a xy area chart.//from www. ja v a 2 s.c o m * * @param title * the diagram title * @param dataset * the dataset. * @param width * the width of the chart as image * @param height * the height of the chart as image * @return the xy area chart as image */ public static ImageIcon createXYAreaChart(String title, XYDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createXYAreaChart(title, "", "", dataset, PlotOrientation.VERTICAL, false, false, false); Font titleFont = UIManager.getFont("TitledBorder.font"); chart.setBackgroundPaint(null); chart.getTitle().setFont(new Font(titleFont.getName(), titleFont.getStyle(), 14)); chart.getTitle().setPaint(UIManager.getColor("TitledBorder.titleColor")); chart.setBorderPaint(null); XYPlot plot = chart.getXYPlot(); plot.setInsets(new RectangleInsets(10, 1, 5, 1)); plot.setBackgroundPaint(null); plot.setOutlineVisible(false); plot.setNoDataMessage(_("No data to display.")); ValueAxis domainAxis = new DateAxis(); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setTickLabelFont(UIManager.getFont("RootPane.font")); ValueAxis rangeAxis = new NumberAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setDomainAxis(domainAxis); plot.setRangeAxis(rangeAxis); plot.setForegroundAlpha(0.5f); return new ImageIcon(chart.createBufferedImage(width, height)); }
From source file:uk.ac.lkl.cram.ui.chart.AbstractChartMaker.java
/** * Apply some defaults to a chart, including background paint * and font.// w w w. jav a 2 s. co m * @param chart the chart to which defaults should be applied */ private void setChartDefaults(JFreeChart chart) { Paint backgroundPaint = UIManager.getColor("InternalFrame.background"); //Set the background colour of the chart chart.setBackgroundPaint(backgroundPaint); //Set the background colour of the plot to be the same as the chart Plot plot = chart.getPlot(); plot.setBackgroundPaint(backgroundPaint); //No outline around the bars plot.setOutlineVisible(false); //Get the legend LegendTitle legend = chart.getLegend(); //Set the font of the legend to be the same as the platform legend.setItemFont(UIManager.getFont("Label.font")); //Set the background colour of the legend to be the same as the platform legend.setBackgroundPaint(backgroundPaint); //No frame around the legend legend.setFrame(BlockBorder.NONE); //Locate the legend to the right of the chart legend.setPosition(RectangleEdge.RIGHT); }
From source file:modmanager.swing.ImageListRenderer.java
@Override public Component getListCellRendererComponent(JList<? extends String> jlist, String e, int i, boolean isSelected, boolean isFocused) { if (isSelected) { this.setBackground(UIManager.getColor("List.selectionBackground")); } else {//w w w . j ava 2 s. c om this.setBackground(UIManager.getColor("List.background")); } imagePanel.setImage(images.get(e)); fileNameLabel.setText(FilenameUtils.getBaseName(e)); return this; }
From source file:CheckBoxNodeTreeSample.java
public CheckBoxNodeRenderer() { Font fontValue;//from w w w .j av a 2s .com fontValue = UIManager.getFont("Tree.font"); if (fontValue != null) { leafRenderer.setFont(fontValue); } Boolean booleanValue = (Boolean) UIManager.get("Tree.drawsFocusBorderAroundIcon"); leafRenderer.setFocusPainted((booleanValue != null) && (booleanValue.booleanValue())); selectionBorderColor = UIManager.getColor("Tree.selectionBorderColor"); selectionForeground = UIManager.getColor("Tree.selectionForeground"); selectionBackground = UIManager.getColor("Tree.selectionBackground"); textForeground = UIManager.getColor("Tree.textForeground"); textBackground = UIManager.getColor("Tree.textBackground"); }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.Utils.java
public static Color getLabelForegroundColor() { final Color labelForeground = UIManager.getColor("Label.foreground"); return labelForeground == null ? Color.BLACK : labelForeground; }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.Utils.java
public static Color getPanelBackgroundColor() { final Color panelBack = UIManager.getColor("Panel.background"); return panelBack == null ? Color.GRAY : panelBack; }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.Utils.java
public static boolean isDarkLAF() { final Color panelBack = UIManager.getColor("Panel.background"); if (panelBack == null) { return false; } else {//from w w w.ja va 2 s . co m return calculateBrightness(panelBack) < 150; } }