List of usage examples for javax.swing UIManager getFont
public static Font getFont(Object key)
From source file:uk.ac.lkl.cram.ui.chart.AbstractChartMaker.java
/** * Apply some defaults to a chart, including background paint * and font.//from w ww .ja v a 2 s . c o 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:net.sf.texprinter.utils.UIUtils.java
/** * Set the label font to the editor. When the content type * is set to 'text/html', the plain visualization is very ugly, so this * method will set the default JLabel font to a JEditorPane. * * @param editor The editor. The CSS stylesheet will be added to it. * @param justify A flag representing full justification. If true, the * text will be fully justified./* ww w. j av a 2 s .co m*/ */ public static void setDefaultFontToEditorPane(JEditorPane editor, boolean justify) { // get the system font Font font = UIManager.getFont("Label.font"); // set the body rule String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; margin-left: 0px; margin-top: 0px; " + (justify ? "text-align: justify;" : "") + " }"; // set the list rule String listRule = "ol { margin-left: 20px; list-style-type: square; }"; // add the body rule ((HTMLDocument) editor.getDocument()).getStyleSheet().addRule(bodyRule); // add the list rule ((HTMLDocument) editor.getDocument()).getStyleSheet().addRule(listRule); }
From source file:uk.ac.lkl.cram.ui.chart.TLALearningTypeChartFactory.java
private static JFreeChart createChart(PieDataset dataset) { //Create a pie chart from the chart factory with no title, a legend and no tooltips JFreeChart chart = ChartFactory.createPieChart(null, dataset, true, false, false); //Set the background colour of the chart Paint backgroundPaint = Color.white; chart.setBackgroundPaint(backgroundPaint); //Get the plot from the chart PiePlot plot = (PiePlot) chart.getPlot(); //Set the background colour of the plot to be the same as the chart plot.setBackgroundPaint(backgroundPaint); //Remove shadows from the plot plot.setShadowXOffset(0);//from w w w . j a va 2 s . c om plot.setShadowYOffset(0); //Remove the outline from the plot plot.setOutlineVisible(false); //Remove the labels from the plot plot.setLabelGenerator(null); //Set the colours for the segments plot.setSectionPaint(LearningTypeChartMaker.ACQUISITION, LearningTypeChartMaker.ACQUISITION_COLOR); plot.setSectionPaint(LearningTypeChartMaker.COLLABORATION, LearningTypeChartMaker.COLLABORATION_COLOR); plot.setSectionPaint(LearningTypeChartMaker.DISCUSSION, LearningTypeChartMaker.DISCUSSION_COLOR); plot.setSectionPaint(LearningTypeChartMaker.INQUIRY, LearningTypeChartMaker.INQUIRY_COLOR); plot.setSectionPaint(LearningTypeChartMaker.PRACTICE, LearningTypeChartMaker.PRACTICE_COLOR); plot.setSectionPaint(LearningTypeChartMaker.PRODUCTION, LearningTypeChartMaker.PRODUCTION_COLOR); //Get the legend from the chart LegendTitle legend = chart.getLegend(); //Set the font of the legend to be the same as the platform UI legend.setItemFont(UIManager.getFont("Label.font")); //Set the background colour of the legend to be the same as the chart legend.setBackgroundPaint(backgroundPaint); //Remove the border from the legend legend.setFrame(BlockBorder.NONE); //Locate the legend to the right of the plot legend.setPosition(RectangleEdge.RIGHT); return chart; }
From source file:com.hp.alm.ali.idea.ui.editor.field.HTMLAreaField.java
public static void enableCapability(final JTextPane desc, Project project, String value, boolean editable, boolean navigation) { value = removeSmallFont(value);/*from w w w . j a va 2 s . c om*/ HTMLEditorKit kit = new HTMLLetterWrappingEditorKit(); desc.setEditorKit(kit); desc.setDocument(kit.createDefaultDocument()); if (!editable && navigation) { value = NavigationDecorator.explodeHtml(project, value); } desc.setText(value); if (!editable) { desc.setCaret(new NonAdjustingCaret()); } desc.addCaretListener(new BodyLimitCaretListener(desc)); if (editable) { String element = checkElements(desc.getDocument().getDefaultRootElement()); if (element != null) { desc.setToolTipText("Found unsupported element '" + element + "', editing is disabled."); editable = false; } } desc.setEditable(editable); if (editable && SpellCheckerManager.isAvailable() && ApplicationManager.getApplication().getComponent(AliConfiguration.class).spellChecker) { desc.getDocument().addDocumentListener(new SpellCheckDocumentListener(project, desc)); } Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; ((HTMLDocument) desc.getDocument()).getStyleSheet().addRule(bodyRule); // AGM uses plain "p" to create lines, we need to avoid excessive spacing this by default creates String paragraphRule = "p { margin-top: 0px; }"; ((HTMLDocument) desc.getDocument()).getStyleSheet().addRule(paragraphRule); Keymap keymap = KeymapManager.getInstance().getActiveKeymap(); new AnAction() { public void actionPerformed(AnActionEvent e) { // following is needed to make copy work in the IDE try { StringSelection selection = new StringSelection(desc.getText(desc.getSelectionStart(), desc.getSelectionEnd() - desc.getSelectionStart())); CopyPasteManager.getInstance().setContents(selection); } catch (Exception ex) { // no clipboard, so what } } }.registerCustomShortcutSet(new CustomShortcutSet(keymap.getShortcuts(IdeActions.ACTION_COPY)), desc); new AnAction() { public void actionPerformed(AnActionEvent e) { // avoid pasting non-supported HTML markup by always converting to plain text Transferable contents = CopyPasteManager.getInstance().getContents(); try { desc.getActionMap().get(DefaultEditorKit.cutAction).actionPerformed(null); desc.getDocument().insertString(desc.getSelectionStart(), (String) contents.getTransferData(DataFlavor.stringFlavor), null); } catch (Exception ex) { // no clipboard, so what } } }.registerCustomShortcutSet(new CustomShortcutSet(keymap.getShortcuts(IdeActions.ACTION_PASTE)), desc); installNavigationShortCuts(desc); }
From source file:com.limegroup.gnutella.gui.themes.setters.SubstanceThemeSetter.java
public void apply() { SubstanceLookAndFeel.setSkin(_skinClassName); ThemeMediator.applyCommonSkinUI();//from w w w. j av a 2 s .com float scaledFontPolicyFactor = WINDOWS_SCALED_FONT_POLICY_FACTOR; if (OSUtils.isMacOSX()) { scaledFontPolicyFactor = MAC_SCALED_FONT_POLICY_FACTOR; } else if (OSUtils.isLinux()) { scaledFontPolicyFactor = LINUX_SCALED_FONT_POLICY_FACTOR; } if (LookUtils.IS_OS_WINDOWS) { fixWindowsOSFont(); } else if (LookUtils.IS_OS_LINUX) { fixLinuxOSFont(); } SubstanceLookAndFeel.setFontPolicy(SubstanceFontUtilities.getScaledFontPolicy(scaledFontPolicyFactor)); //reduceFont("Label.font"); //reduceFont("Table.font"); //ResourceManager.setFontSizes(-1); //ResourceManager.setFontSizes(0); UIManager.put("Tree.leafIcon", UIManager.getIcon("Tree.closedIcon")); // remove split pane borders UIManager.put("SplitPane.border", BorderFactory.createEmptyBorder()); if (!OSUtils.isMacOSX()) { UIManager.put("Table.focusRowHighlightBorder", UIManager.get("Table.focusCellHighlightBorder")); } UIManager.put("Table.focusCellHighlightBorder", BorderFactory.createEmptyBorder(1, 1, 1, 1)); // Add a bold text version of simple text. Font normal = UIManager.getFont("Table.font"); FontUIResource bold = new FontUIResource(normal.getName(), Font.BOLD, normal.getSize()); UIManager.put("Table.font.bold", bold); UIManager.put("Tree.rowHeight", 0); }
From source file:es.emergya.ui.gis.ControlPanel.java
public ControlPanel(final CustomMapView view) { super(new FlowLayout(FlowLayout.LEADING, 12, 0)); this.view = view; // Posicion: panel con un label de icono y un textfield JPanel posPanel = new JPanel(); posPanel.setOpaque(true);/*from w w w . j a v a 2 s . c o m*/ posPanel.setVisible(true); JLabel mouseLocIcon = new JLabel(LogicConstants.getIcon("map_icon_coordenadas")); posPanel.add(mouseLocIcon); final JTextField posField = new JTextField(15); posField.setEditable(false); posField.setBorder(null); posField.setForeground(UIManager.getColor("Label.foreground")); posField.setFont(UIManager.getFont("Label.font")); posPanel.add(posField); view.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { LatLon ll = ((ICustomMapView) e.getSource()).getLatLon(e.getX(), e.getY()); String position = ""; String format = LogicConstants.get("FORMATO_COORDENADAS_MAPA", "UTM"); if (format.equals(LogicConstants.COORD_UTM)) { UTM u = new UTM(LogicConstants.getInt("ZONA_UTM")); EastNorth en = u.latlon2eastNorth(ll); position = String.format("x: %.1f y: %.1f", en.getX(), en.getY()); } else { position = String.format("Lat: %.4f Lon: %.4f", ll.lat(), ll.lon()); } posField.setText(position); validate(); } @Override public void mouseDragged(MouseEvent e) { } }); posPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); add(posPanel); // Panel de centrado: label, desplegable y parte cambiante JPanel centerPanel = new JPanel(); centerPanel.add(new JLabel(i18n.getString("map.centerIn"))); centerOptions = new JComboBox(new String[] { i18n.getString("map.street"), i18n.getString("map.resource"), i18n.getString("map.incidence"), i18n.getString("map.location") }); centerPanel.add(centerOptions); centerData = new JPanel(new CardLayout()); centerPanel.add(centerData); JPanel centerStreet = new JPanel(); street = new JTextField(30); street.setName(i18n.getString("map.street")); autocompleteKeyListener = new AutocompleteKeyListener(street); street.addKeyListener(autocompleteKeyListener); street.addActionListener(this); centerStreet.add(street); centerData.add(centerStreet, i18n.getString("map.street")); JPanel centerResource = new JPanel(); resources = new JComboBox(avaliableResources); resources.setName(i18n.getString("map.resource")); resources.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); resources.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { isComboResourcesShowing = true; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { isComboResourcesShowing = false; } @Override public void popupMenuCanceled(PopupMenuEvent e) { // view.repaint(); } }); centerResource.add(resources); centerData.add(centerResource, i18n.getString("map.resource")); centerResource = new JPanel(); incidences = new JComboBox(avaliableIncidences); incidences.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); incidences.setName(i18n.getString("map.incidence")); incidences.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { isComboIncidencesShowing = true; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { isComboIncidencesShowing = false; } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); centerResource.add(incidences); centerData.add(centerResource, i18n.getString("map.incidence")); JPanel centerLocation = new JPanel(); cx = new JTextField(10); cx.setName("x"); cx.addActionListener(this); centerLocation.add(cx); cy = new JTextField(10); cy.setName("y"); cy.addActionListener(this); centerLocation.add(cy); centerData.add(centerLocation, i18n.getString("map.location")); centerOptions.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { ((CardLayout) centerData.getLayout()).show(centerData, (String) e.getItem()); } }); JButton centerButton = new JButton(i18n.getString("map.center")); centerButton.addActionListener(this); centerPanel.add(centerButton); add(centerPanel); }
From source file:au.org.ala.delta.intkey.ui.MultiStateInputDialog.java
/** * ctor/*w w w. ja v a 2 s. co m*/ * * @param owner * Owner frame of dialog * @param ch * the character whose states are being set * @param initialSelectedStates * initial states that should be selected in the dialog. In * general this should be any states already set for the * character. In the case that this is a controlling character * being set before its dependent character, all states that make * the dependent character applicable should be selected. * @param dependentCharacter * the dependent character - if the dialog is being used to set a * controlling character before its dependent character, this * argument should be a reference to the dependent character. In * all other cases it should be null. * @param imageSettings * image settings * @param displayNumbering * true if numbering should be displayed * @param enableImagesButton * the if the images button should be enabled * @param imagesStartScaled * true if images should start scaled. */ public MultiStateInputDialog(Frame owner, MultiStateCharacter ch, Set<Integer> initialSelectedStates, au.org.ala.delta.model.Character dependentCharacter, ImageSettings imageSettings, boolean displayNumbering, boolean enableImagesButton, boolean imagesStartScaled, boolean advancedMode) { super(owner, ch, imageSettings, displayNumbering, enableImagesButton, imagesStartScaled, advancedMode); ResourceMap resourceMap = Application.getInstance().getContext() .getResourceMap(MultiStateInputDialog.class); resourceMap.injectFields(this); setTitle(title); setPreferredSize(new Dimension(600, 350)); if (dependentCharacter != null) { _pnlControllingCharacterMessage = new JPanel(); _pnlControllingCharacterMessage.setFocusable(false); _pnlControllingCharacterMessage.setBorder(new EmptyBorder(5, 0, 0, 0)); _pnlMain.add(_pnlControllingCharacterMessage, BorderLayout.SOUTH); _pnlControllingCharacterMessage.setLayout(new BorderLayout(0, 0)); _lblWarningIcon = new JLabel(""); _lblWarningIcon.setFocusable(false); _lblWarningIcon.setIcon(UIManager.getIcon("OptionPane.warningIcon")); _pnlControllingCharacterMessage.add(_lblWarningIcon, BorderLayout.WEST); _txtControllingCharacterMessage = new JTextArea(); _txtControllingCharacterMessage.setText(MessageFormat.format(setControllingCharacterMessage, _formatter.formatCharacterDescription(dependentCharacter), _formatter.formatCharacterDescription(ch))); _txtControllingCharacterMessage.setFocusable(false); _txtControllingCharacterMessage.setBorder(new EmptyBorder(0, 5, 0, 0)); _txtControllingCharacterMessage.setEditable(false); _pnlControllingCharacterMessage.add(_txtControllingCharacterMessage); _txtControllingCharacterMessage.setWrapStyleWord(true); _txtControllingCharacterMessage.setFont(UIManager.getFont("Button.font")); _txtControllingCharacterMessage.setLineWrap(true); _txtControllingCharacterMessage.setBackground(SystemColor.control); } _scrollPane = new JScrollPane(); _pnlMain.add(_scrollPane, BorderLayout.CENTER); _list = new JList(); _scrollPane.setViewportView(_list); _listModel = new DefaultListModel(); for (int i = 0; i < ch.getNumberOfStates(); i++) { _listModel.addElement(_formatter.formatState(ch, i + 1)); } _list.setModel(_listModel); _list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { // Treat double click on a list item as the ok button being // pressed. _okPressed = true; handleBtnOKClicked(); } } }); // Select the list items that correspond to the initial selected states. if (initialSelectedStates != null) { List<Integer> listIndiciesToSelect = new ArrayList<Integer>(); for (int stateNumber : new ArrayList<Integer>(initialSelectedStates)) { listIndiciesToSelect.add(stateNumber - 1); } Integer[] wrappedPrimitivesList = listIndiciesToSelect .toArray(new Integer[initialSelectedStates.size()]); _list.setSelectedIndices(ArrayUtils.toPrimitive(wrappedPrimitivesList)); } _inputData = new HashSet<Integer>(); }
From source file:lcmc.LCMC.java
/** Create the GUI and show it. */ protected static void createAndShowGUI(final Container mainFrame) { final java.util.List<Object> buttonGradient = Arrays.asList(new Object[] { new Float(.3f), new Float(0f), new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND), new ColorUIResource(0xFFFFFF), new ColorUIResource(ClusterBrowser.BUTTON_PANEL_BACKGROUND) }); final java.util.List<Object> checkboxGradient = Arrays.asList( new Object[] { new Float(.3f), new Float(0f), new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND), new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND), new ColorUIResource(0xFFFFFF) }); ToolTipManager.sharedInstance().setInitialDelay(TOOLTIP_INITIAL_DELAY); ToolTipManager.sharedInstance().setDismissDelay(TOOLTIP_DISMISS_DELAY); UIManager.put("TableHeader.background", Tools.getDefaultColor("DrbdMC.TableHeader")); UIManager.put("TableHeader.font", UIManager.getFont("Label.font")); UIManager.put("Button.gradient", buttonGradient); UIManager.put("Button.select", ClusterBrowser.PANEL_BACKGROUND); UIManager.put("CheckBox.gradient", checkboxGradient); UIManager.put("CheckBoxMenuItem.gradient", checkboxGradient); UIManager.put("RadioButton.gradient", checkboxGradient); UIManager.put("RadioButton.rollover", Boolean.TRUE); UIManager.put("RadioButtonMenuItem.gradient", checkboxGradient); UIManager.put("ScrollBar.gradient", buttonGradient); UIManager.put("ToggleButton.gradient", buttonGradient); UIManager.put("Menu.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND); UIManager.put("MenuItem.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND); UIManager.put("List.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND); UIManager.put("ComboBox.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND); UIManager.put("OptionPane.background", ClusterBrowser.BUTTON_PANEL_BACKGROUND); UIManager.put("Panel.background", ClusterBrowser.PANEL_BACKGROUND); /* Create and set up the window. */ Tools.getGUIData().setMainFrame(mainFrame); /* Display the window. */ mainFrame.setSize(Tools.getDefaultInt("DrbdMC.width"), Tools.getDefaultInt("DrbdMC.height")); mainFrame.setVisible(true);/*from w ww.j ava 2s . c o m*/ }
From source file:de.ailis.xadrian.components.ComplexEditor.java
/** * Constructor// w ww. j ava2 s . c o m * * @param complex * The complex to edit * @param file * The file from which the complex was loaded. Null if it not * loaded from a file. */ public ComplexEditor(final Complex complex, final File file) { super(); setLayout(new BorderLayout()); this.complex = complex; this.file = file; // Create the text pane this.textPane = new JTextPane(); this.textPane.setEditable(false); this.textPane.setBorder(null); this.textPane.setContentType("text/html"); this.textPane.setDoubleBuffered(true); this.textPane.addHyperlinkListener(this); this.textPane.addCaretListener(this); // Create the popup menu for the text pane final JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new CopyAction(this)); popupMenu.add(new SelectAllAction(this)); popupMenu.addSeparator(); popupMenu.add(new AddFactoryAction(this)); popupMenu.add(new ChangeSectorAction(this.complex, this, "complex")); popupMenu.add(new ChangeSunsAction(this)); popupMenu.add(new ChangePricesAction(this)); popupMenu.add(new JCheckBoxMenuItem(new ToggleBaseComplexAction(this))); SwingUtils.setPopupMenu(this.textPane, popupMenu); final HTMLDocument document = (HTMLDocument) this.textPane.getDocument(); // Set the base URL of the text pane document.setBase(Main.class.getResource("templates/")); // Modify the body style so it matches the system font final Font font = UIManager.getFont("Label.font"); final String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt; }"; document.getStyleSheet().addRule(bodyRule); // Create the scroll pane final JScrollPane scrollPane = new JScrollPane(this.textPane); add(scrollPane); // Redraw the content redraw(); fireComplexState(); }
From source file:uk.ac.lkl.cram.ui.chart.FeedbackChartMaker.java
/** * Create a chart from the provided category dataset * @return a Chart that can be rendered in a ChartPanel *///from ww w .j a va 2 s. com @Override protected JFreeChart createChart() { //Create a vertical bar chart from the chart factory, with no title, no axis labels, a legend, tooltips but no URLs JFreeChart chart = ChartFactory.createBarChart(null, null, null, (CategoryDataset) dataset, PlotOrientation.VERTICAL, true, true, false); //Get the font from the platform UI Font chartFont = UIManager.getFont("Label.font"); //Get the plot from the chart CategoryPlot plot = (CategoryPlot) chart.getPlot(); //Get the renderer from the plot BarRenderer barRenderer = (BarRenderer) plot.getRenderer(); //Set the rendered to use a standard bar painter (nothing fancy) barRenderer.setBarPainter(new StandardBarPainter()); //Set the colours for the bars barRenderer.setSeriesPaint(0, PEER_ONLY_COLOR); barRenderer.setSeriesPaint(1, TEL_COLOR); barRenderer.setSeriesPaint(2, TUTOR_COLOR); //Set the tooltip to be series, category and value barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator( "<html><center>{0} ({2} hours)<br/>Double-click for more</center></html>", NumberFormat.getInstance())); //Get the category axis (that's the X-axis in this case) CategoryAxis categoryAxis = plot.getDomainAxis(); //Set the font for rendering the labels on the x-axis to be the platform default categoryAxis.setLabelFont(chartFont); //Hide the tick marks and labels for the x-axis categoryAxis.setTickMarksVisible(false); categoryAxis.setTickLabelsVisible(false); //Set the label for the x-axis categoryAxis.setLabel("Feedback to individuals or group"); //Get the number axis (that's the Y-axis in this case) NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); //Use the same font as the x-axis numberAxis.setLabelFont(chartFont); //Set the label for the vertical axis numberAxis.setLabel("Hours"); return chart; }