Java Code Examples for javax.swing.JLabel#putClientProperty()
The following examples show how to use
javax.swing.JLabel#putClientProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetAccessibleNameTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void testAccessibleProperty() { String text = "html text"; JLabel testLabel = new JLabel("<html>" + text + "</html>"); if (!text.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) { throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," + " Expected: " + text + " Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY)); } String namePropertyText = "name property"; testLabel.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, namePropertyText); if (!namePropertyText.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) { throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," + " Expected: " + namePropertyText + " Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY)); } text = "different html text"; testLabel.setText("<html>" + text + "</html>"); if (!namePropertyText.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) { throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," + " Expected: " + namePropertyText + " Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY)); } }
Example 2
Source File: OpenPanel.java From settlers-remake with MIT License | 6 votes |
/** * Initialize the filter buttons */ private void initFilter() { JLabel filterLabel = new JLabel(Labels.getString("mapfilter.title")); filterLabel.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_SHORT); filterPanel.add(filterLabel); boolean first = true; ButtonGroup group = new ButtonGroup(); for (final EMapFilter filter : EMapFilter.values()) { JToggleButton bt = new JToggleButton(filter.getName()); bt.putClientProperty(ELFStyle.KEY, ELFStyle.TOGGLE_BUTTON_STONE); bt.addActionListener(e -> { currentFilter = filter; searchChanged(); }); if (first) { first = false; bt.setSelected(true); } group.add(bt); filterPanel.add(bt); } }
Example 3
Source File: ErrorPropertyEditor.java From ghidra with Apache License 2.0 | 5 votes |
public ErrorPropertyEditor(String errorMessage, Object value) { editorValue = value; String message = errorMessage; if (editorValue != null) { message += " - value: " + value.toString(); } // Use native java JLabel because we can't use docking widgets here errorLabel = new JLabel(message); errorLabel.setForeground(Color.RED); errorLabel.putClientProperty("html.disable", true); }
Example 4
Source File: StatusBar.java From netbeans with Apache License 2.0 | 5 votes |
public void setText(String cellName, String text, Coloring extraColoring, int importance) { JLabel cell = getCellByName(cellName); if (cell != null) { cell.setText(text); if (visible) { JTextComponent jtc = editorUI.getComponent(); Coloring c = jtc != null ? getColoring( org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(jtc), FontColorNames.STATUS_BAR_COLORING ) : null; if (c != null && extraColoring != null) { c = extraColoring.apply(c); } else if (c == null) { c = extraColoring; } if (CELL_POSITION.equals(cellName)){ cell.setToolTipText(caretPositionLocaleString); } else if (CELL_TYPING_MODE.equals(cellName)) { cell.setToolTipText(insText.equals(text)? insertModeLocaleString : overwriteModeLocaleString); } else { cell.setToolTipText(text == null || text.length() == 0 ? null : text); } if (c != null && cell instanceof Cell) { applyColoring((Cell) cell, c); } } else { // Status bar not visible => use global status bar if possible JLabel globalCell = cellName2GlobalCell.get(cellName); if (globalCell != null) { if (CELL_MAIN.equals(cellName)) { globalCell.putClientProperty("importance", importance); } globalCell.setText(text); } } } }
Example 5
Source File: QueryTableCellRenderer.java From netbeans with Apache License 2.0 | 5 votes |
public void setStyleProperties(JLabel renderer, TableCellStyle style) { if (style != null) { renderer.putClientProperty(PROPERTY_FORMAT, style.format); // NOI18N renderer.putClientProperty(PROPERTY_HIGHLIGHT_PATTERN, style.highlightPattern); // NOI18N ((JComponent) renderer).setToolTipText(style.tooltip); setRowColors(style, renderer); } }
Example 6
Source File: bug6302464.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void testFontRenderingContext(Object aaHint) { JLabel label = new JLabel("Test"); label.putClientProperty(KEY_TEXT_ANTIALIASING, aaHint); FontRenderContext frc = label.getFontMetrics( label.getFont()).getFontRenderContext(); if (!aaHint.equals(frc.getAntiAliasingHint())) { throw new RuntimeException("Wrong aa hint in FontRenderContext"); } }
Example 7
Source File: bug6302464.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static HashSet getAntialiasedColors(Object aaHint, int lcdContrast) { JLabel label = new JLabel("ABCD"); label.setSize(label.getPreferredSize()); label.putClientProperty(KEY_TEXT_ANTIALIASING, aaHint); label.putClientProperty(KEY_TEXT_LCD_CONTRAST, lcdContrast); int w = label.getWidth(); int h = label.getHeight(); BufferedImage buffImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = buffImage.createGraphics(); g.setColor(Color.WHITE); g.fillRect(0, 0, w, h); label.paint(g); g.dispose(); HashSet<Color> colors = new HashSet<>(); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { Color color = new Color(buffImage.getRGB(i, j)); colors.add(color); } } return colors; }
Example 8
Source File: IOLocationTileList.java From pumpernickel with MIT License | 5 votes |
public Component getListCellRendererComponent(JList list, IOLocation l, int index, boolean isSelected, boolean cellHasFocus) { String text = ""; BufferedImage image; text = l.getName(); image = getGraphicCache().requestThumbnail(l); if (image == null) { if (l.isDirectory()) { image = LocationPane.FOLDER_THUMBNAIL; } else { image = LocationPane.FILE_THUMBNAIL; } } IOLocationFilter f = null; if (list instanceof IOLocationTileList) { IOLocationTileList t = (IOLocationTileList) list; f = t.getFilter(); } boolean enabled = f == null ? true : f.filter(l) != null; JLabel label = getThumbnail(); label.setEnabled(enabled); label.setText(text); label.setIcon(new ImageIcon(image)); label.putClientProperty("selected", new Boolean(isSelected)); format(l, label); return label; }
Example 9
Source File: MainWindow.java From xdm with GNU General Public License v2.0 | 4 votes |
private JPanel createToolbar() { JPanel p = new JPanel(new BorderLayout()); Box toolBox = Box.createHorizontalBox(); toolBox.add(Box.createRigidArea(new Dimension(scale(20), scale(60)))); toolBox.setBackground(ColorResource.getTitleColor()); toolBox.setOpaque(true); JButton btn1 = createToolButton("ADD_URL", "tool_add.png"); btn1.setToolTipText(StringResource.get("MENU_ADD_URL")); toolBox.add(btn1); toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10)))); JButton btn2 = createToolButton("DELETE", "tool_del.png"); btn2.setToolTipText(StringResource.get("MENU_DELETE_DWN")); toolBox.add(btn2); toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10)))); JButton btn3 = createToolButton("PAUSE", "tool_pause.png"); btn3.setToolTipText(StringResource.get("MENU_PAUSE")); toolBox.add(btn3); toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10)))); JButton btn4 = createToolButton("RESUME", "tool_resume.png"); btn4.setToolTipText(StringResource.get("MENU_RESUME")); toolBox.add(btn4); toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10)))); JButton btn5 = createToolButton("OPTIONS", "tool_settings.png"); btn5.setToolTipText(StringResource.get("TITLE_SETTINGS")); toolBox.add(btn5); toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10)))); JButton btn6 = createToolButton("MENU_VIDEO_DWN", "tool_video.png"); btn6.setToolTipText(StringResource.get("MENU_VIDEO_DWN")); toolBox.add(btn6); toolBox.add(Box.createRigidArea(new Dimension(scale(10), scale(10)))); JButton btn7 = createToolButton("MENU_MEDIA_CONVERTER", "tool_convert.png"); btn7.setToolTipText(StringResource.get("MENU_MEDIA_CONVERTER")); toolBox.add(btn7); toolBox.add(Box.createHorizontalGlue()); btnMonitoring = new JLabel(ImageResource.getIcon("on.png", 85, 21)); // btnMonitoring.setForeground(Color.WHITE); btnMonitoring.setIconTextGap(scale(15)); btnMonitoring.putClientProperty("xdmbutton.norollover", "true"); // btnMonitoring.setBackground(ColorResource.getTitleColor()); btnMonitoring.setName("BROWSER_MONITORING"); btnMonitoring.setText(StringResource.get("BROWSER_MONITORING")); btnMonitoring.setHorizontalTextPosition(JButton.LEADING); btnMonitoring.setFont(FontResource.getBigFont()); btnMonitoring .setIcon(Config.getInstance().isBrowserMonitoringEnabled() ? ImageResource.getIcon("on.png", 85, 21) : ImageResource.getIcon("off.png", 85, 21)); btnMonitoring.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { toggleMonitoring((JLabel) e.getSource()); } }); toolBox.add(btnMonitoring); toolBox.add(Box.createRigidArea(new Dimension(scale(25), scale(10)))); p.add(toolBox); return p; }
Example 10
Source File: EditableDisplayerTest.java From netbeans with Apache License 2.0 | 4 votes |
public Component getCustomEditor() { JLabel result = new JLabel("Everything is exactly as it should be. Relax."); result.putClientProperty("title","Don't panic"); return result; }
Example 11
Source File: SettingsMenuPanel.java From settlers-remake with MIT License | 3 votes |
/** * Add a settings entry * * @param translationKey * Translation key to read translation * @param settingComponent * Component to display */ private void addSetting(String translationKey, JComponent settingComponent) { JLabel header = new JLabel(Labels.getString(translationKey)); header.putClientProperty(ELFStyle.KEY, ELFStyle.LABEL_SHORT); settinsgPanel.add(header); settinsgPanel.add(settingComponent); }