List of usage examples for javax.swing JLabel getFont
@Transient
public Font getFont()
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Displays the specified string into a {@link JLabel} and sets * the font to <code>bold</code>. * /*from w w w . j a va 2 s . c om*/ * @param s The string to display. * @param fontStyle The style of the font. * @return See above. */ public static JLabel setTextFont(String s, int fontStyle) { if (s == null) s = ""; JLabel label = new JLabel(s); Font font = label.getFont(); Font newFont = font.deriveFont(fontStyle); label.setFont(newFont); return label; }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Displays the specified string into a {@link JLabel} and sets * the font to <code>bold</code>. * // w w w . ja va 2 s . com * @param s The string to display. * @param fontStyle The style of font. * @param fontSize The size of the font. * @return See above. */ public static JLabel setTextFont(String s, int fontStyle, int fontSize) { if (s == null) s = ""; JLabel label = new JLabel(s); Font font = label.getFont(); label.setFont(font.deriveFont(fontStyle, fontSize)); return label; }
From source file:org.piraso.ui.base.PreferencePanel.java
private void initPreferenceComponentsVerticalChildLayout() { CellConstraints c = new CellConstraints(); int size = CollectionUtils.size(provider.getPreferences()); int l = 0, r = 2; chkPreferences = new JCheckBox[size]; preferenceKeys = new PreferenceProperty[size]; JLabel lblHeader = new JLabel(provider.getName()); Font of = lblHeader.getFont(); lblHeader.setFont(of.deriveFont(Font.BOLD)); pnlPreferences.add(lblHeader, c.xyw(2, r, 5)); r += 2;// w w w . j a v a 2s . co m Iterator<? extends PreferenceProperty> itrp = provider.getPreferences().iterator(); for (int j = 0; j < provider.getPreferences().size(); j++, l++) { PreferenceProperty prop = itrp.next(); preferenceKeys[l] = prop; chkPreferences[l] = new JCheckBox(); chkPreferences[l].setText(provider.getMessage(prop.getName())); chkPreferences[l].setSelected(prop.isDefaultValue()); chkPreferences[l].addActionListener(new CheckBoxClickHandler(l)); if (prop.isParent()) { chkPreferences[l].setFont(chkPreferences[l].getFont().deriveFont(Font.BOLD)); } if (prop.isChild()) { pnlPreferences.add(chkPreferences[l], c.xy(6, r)); } else { pnlPreferences.add(chkPreferences[l], c.xyw(4, r, 3)); } r += 2; } }
From source file:org.piraso.ui.base.PreferencePanel.java
private void initPreferenceComponentsHorizontalChildLayout() { handlers = new ArrayList<ParentChildHandler>(); CellConstraints c = new CellConstraints(); int size = CollectionUtils.size(provider.getPreferences()); int l = 0, r = 2; chkPreferences = new JCheckBox[size]; preferenceKeys = new PreferenceProperty[size]; JLabel lblHeader = new JLabel(provider.getName()); Font of = lblHeader.getFont(); lblHeader.setFont(of.deriveFont(Font.BOLD)); pnlPreferences.add(lblHeader, c.xyw(2, r, 5)); r += 2;// ww w . j a v a 2 s. co m JButton parentToggle = null; JPanel childrenPanel = null; ParentChildHandler parentChildHandler = null; Iterator<? extends PreferenceProperty> itrp = provider.getPreferences().iterator(); for (int j = 0; j < provider.getPreferences().size(); j++, l++) { PreferenceProperty prop = itrp.next(); preferenceKeys[l] = prop; chkPreferences[l] = new JCheckBox(); chkPreferences[l].setText(provider.getMessage(prop.getName())); chkPreferences[l].setSelected(prop.isDefaultValue()); if (prop.isChild()) { if (childrenPanel == null) { childrenPanel = new JPanel(); childrenPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1)); childrenPanel.setOpaque(false); childrenPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 1)); childrenPanel.setVisible(false); if (parentChildHandler != null) { parentChildHandler.setChildrenPanel(childrenPanel); } pnlPreferences.add(childrenPanel, c.xy(6, r)); r += 2; } if (parentChildHandler != null) { parentChildHandler.addPreference(chkPreferences[l]); } childrenPanel.add(chkPreferences[l]); parentToggle = null; } else { if (parentToggle != null) { parentChildHandler.hide(); } JPanel parentPanel = new JPanel(); parentPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1)); parentPanel.setOpaque(false); parentToggle = new JButton(expandImage); JLabel previewLabel = new JLabel(); previewLabel.setForeground(new Color(0, 128, 0)); previewLabel.setFont(previewLabel.getFont().deriveFont(Font.ITALIC)); parentChildHandler = new ParentChildHandler(parentToggle, previewLabel); parentChildHandler.addPreference(chkPreferences[l]); handlers.add(parentChildHandler); parentToggle.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); parentPanel.add(parentToggle); parentPanel.add(chkPreferences[l]); parentPanel.add(previewLabel); pnlPreferences.add(parentPanel, c.xyw(4, r, 3)); childrenPanel = null; r += 2; } chkPreferences[l].addActionListener(new CheckBoxClickHandler(l, parentChildHandler)); } }
From source file:org.rapidcontext.app.ui.ControlPanel.java
/** * Initializes the panel UI./*from www. j av a 2s . co m*/ */ private void initialize() { Rectangle bounds = new Rectangle(); GridBagConstraints c; JLabel label; Font font; Properties info; String str; // Set system UI looks if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_WINDOWS) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ignore) { // Ah well... at least we tried. } } // Set title, menu & layout setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("RapidContext Server"); setMenuBar(menuBar); initializeMenu(); getContentPane().setLayout(new GridBagLayout()); try { logotype = ImageIO.read(getClass().getResource("logotype.png")); Image img = ImageIO.read(getClass().getResource("logotype-icon-256x256.png")); setIconImage(img); if (SystemUtils.IS_OS_MAC_OSX) { MacApplication.get().setDockIconImage(img); } } catch (Exception ignore) { // Again, we only do our best effort here } // Add logotype c = new GridBagConstraints(); c.gridheight = 5; c.insets = new Insets(6, 15, 10, 10); c.anchor = GridBagConstraints.NORTHWEST; Image small = logotype.getScaledInstance(128, 128, Image.SCALE_SMOOTH); getContentPane().add(new JLabel(new ImageIcon(small)), c); // Add link label c = new GridBagConstraints(); c.gridx = 1; c.insets = new Insets(10, 10, 2, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Server URL:"), c); serverLink.setText("http://localhost:" + server.port + "/"); serverLink.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { AppUtils.openURL(serverLink.getText()); } catch (Exception e) { error(e.getMessage()); } } }); c = new GridBagConstraints(); c.gridx = 2; c.weightx = 1.0; c.insets = new Insets(10, 0, 2, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(serverLink, c); // Add login info label label = new JLabel("Login as 'admin' on a new server."); font = label.getFont(); font = font.deriveFont(Font.ITALIC, font.getSize() - 2); label.setFont(font); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 1; c.gridwidth = 2; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(label, c); // Add status label c = new GridBagConstraints(); c.gridx = 1; c.gridy = 2; c.insets = new Insets(0, 10, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Status:"), c); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 2; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(statusLabel, c); // Add version label c = new GridBagConstraints(); c.gridx = 1; c.gridy = 3; c.insets = new Insets(0, 10, 6, 10); c.anchor = GridBagConstraints.WEST; getContentPane().add(new JLabel("Version:"), c); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 3; c.insets = new Insets(0, 0, 6, 10); c.anchor = GridBagConstraints.WEST; info = Main.buildInfo(); str = info.getProperty("build.version") + " (built " + info.getProperty("build.date") + ")"; getContentPane().add(new JLabel(str), c); // Add buttons startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { start(); } }); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 4; c.weighty = 1.0; c.insets = new Insets(0, 10, 10, 10); c.anchor = GridBagConstraints.SOUTH; getContentPane().add(startButton, c); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { stop(); } }); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 4; c.weighty = 1.0; c.insets = new Insets(0, 0, 10, 0); c.anchor = GridBagConstraints.SOUTHWEST; getContentPane().add(stopButton, c); // Set size & position pack(); bounds = this.getBounds(); bounds.width = 470; bounds.x = 100; bounds.y = 100; setBounds(bounds); }
From source file:org.rdv.datapanel.AbstractDataPanel.java
JComponent getDescriptionComponent() { JLabel descriptionLabel = new JLabel(description); descriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(Font.BOLD)); descriptionLabel.setForeground(Color.white); return descriptionLabel; }
From source file:org.spoutcraft.launcher.skin.ModpackSelector.java
public ModpackSelector(LauncherFrame frame, AvailablePackList packList, UserModel userModel, MirrorStore mirrorStore) {/*from w w w . j a v a 2 s .c o m*/ this.frame = frame; this.mPackList = packList; this.mUserModel = userModel; this.mirrorStore = mirrorStore; this.mPackList.addPackListener(this); for (int i = 0; i < 7; i++) { PackButton button = new PackButton(); buttons.add(button); JLabel label = button.getJLabel(); JLabel icon = button.getDisconnectedIcon(); button.setActionCommand(PACK_SELECT_ACTION); button.addActionListener(this); if (i == 3) { button.setBounds(bigX, bigY, bigWidth, bigHeight); label.setBounds(bigX, bigY + bigHeight - 24, bigWidth, 24); icon.setBounds(bigX + bigWidth - 80, bigY, 80, 17); label.setFont(label.getFont().deriveFont(14F)); button.setIndex(0); } else if (i < 3) { int smallY = bigY - (spacing * 2) - ((smallHeight + spacing) * (i + 1)); button.setBounds(smallX, smallY, smallWidth, smallHeight); label.setBounds(smallX, smallY + smallHeight - 20, smallWidth, 20); icon.setBounds(smallX + smallWidth - 80, smallY, 80, 17); button.setIndex((i + 1) * -1); } else if (i > 3) { int smallY = bigY + bigHeight + ((smallHeight + spacing) * (i - 4)) + (spacing * 3); button.setBounds(smallX, smallY, smallWidth, smallHeight); label.setBounds(smallX, smallY + smallHeight - 20, smallWidth, 20); icon.setBounds(smallX + smallWidth - 80, smallY, 80, 17); button.setIndex(i - 3); } this.add(label); this.add(icon); this.add(button); } }
From source file:org.spoutcraft.launcher.technic.skin.ModpackSelector.java
public ModpackSelector(TechnicLoginFrame frame) { this.frame = frame; for (int i = 0; i < 7; i++) { PackButton button = new PackButton(); buttons.add(button);//ww w . jav a2s .c om JLabel label = button.getJLabel(); button.setActionCommand(PACK_SELECT_ACTION); button.addActionListener(this); if (i == 3) { button.setBounds(bigX, bigY, bigWidth, bigHeight); label.setBounds(bigX, bigY + bigHeight - 24, bigWidth, 24); label.setFont(label.getFont().deriveFont(14F)); button.setIndex(0); } else if (i < 3) { int smallY = bigY - (spacing * 2) - ((smallHeight + spacing) * (i + 1)); button.setBounds(smallX, smallY, smallWidth, smallHeight); label.setBounds(smallX, smallY + smallHeight - 20, smallWidth, 20); button.setIndex((i + 1) * -1); } else if (i > 3) { int smallY = bigY + bigHeight + ((smallHeight + spacing) * (i - 4)) + (spacing * 3); button.setBounds(smallX, smallY, smallWidth, smallHeight); label.setBounds(smallX, smallY + smallHeight - 20, smallWidth, 20); button.setIndex(i - 3); } this.add(button.getJLabel()); this.add(button); } }
From source file:org.tinymediamanager.ui.tvshows.TvShowDetailsPanel.java
private void setBoldLabel(JLabel label) { label.setFont(label.getFont().deriveFont(Font.BOLD)); }
From source file:org.tinymediamanager.ui.tvshows.TvShowEpisodeDetailsPanel.java
/** * Instantiates a new tv show episode details panel. * //from w ww. ja va 2s. c o m * @param model * the selection model */ public TvShowEpisodeDetailsPanel(TvShowEpisodeSelectionModel model) { this.selectionModel = model; setLayout(new FormLayout(new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, ColumnSpec.decode("25px"), ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("55px"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblSeasonT = new JLabel(BUNDLE.getString("metatag.season")); //$NON-NLS-1$ TmmFontHelper.changeFont(lblSeasonT, 1.166, Font.BOLD); add(lblSeasonT, "2, 1"); lblSeason = new JLabel(""); TmmFontHelper.changeFont(lblSeason, 1.166); add(lblSeason, "4, 1"); btnPlay = new JButton(""); btnPlay.setIcon(IconManager.PLAY); btnPlay.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { MediaFile mf = selectionModel.getSelectedTvShowEpisode().getMediaFiles(MediaFileType.VIDEO).get(0); try { TmmUIHelper.openFile(mf.getFileAsPath()); } catch (Exception e) { LOGGER.error("open file", e); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, mf, "message.erroropenfile", new String[] { ":", e.getLocalizedMessage() })); } } }); add(btnPlay, "6, 1, 1, 4"); JLabel lblEpisodeT = new JLabel(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$ TmmFontHelper.changeFont(lblEpisodeT, 1.166, Font.BOLD); add(lblEpisodeT, "2, 2"); lblEpisode = new JLabel(""); TmmFontHelper.changeFont(lblEpisode, 1.166); add(lblEpisode, "4, 2"); JLabel lblAiredT = new JLabel(BUNDLE.getString("metatag.aired")); //$NON-NLS-1$ lblAiredT.setFont(lblAiredT.getFont().deriveFont(Font.BOLD)); add(lblAiredT, "2, 4"); lblAired = new JLabel(""); add(lblAired, "4, 4"); JLabel lblTagsT = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ lblTagsT.setFont(lblTagsT.getFont().deriveFont(Font.BOLD)); add(lblTagsT, "2, 6"); lblTags = new JLabel(""); add(lblTags, "4, 6"); JLabel lblDateAddedT = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ lblDateAddedT.setFont(lblDateAddedT.getFont().deriveFont(Font.BOLD)); add(lblDateAddedT, "2, 8"); lblDateAdded = new JLabel(""); add(lblDateAdded, "4, 8"); JLabel lblPathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ lblPathT.setFont(lblPathT.getFont().deriveFont(Font.BOLD)); add(lblPathT, "2, 10"); lblPath = new LinkLabel(""); lblPathT.setLabelFor(lblPath); lblPath.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!StringUtils.isEmpty(lblPath.getNormalText())) { // get the location from the label Path path = Paths.get(lblPath.getNormalText()); try { // check whether this location exists if (Files.exists(path)) { TmmUIHelper.openFile(path); } } catch (Exception ex) { LOGGER.error("open filemanager", ex); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path, "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() })); } } } }); add(lblPath, "4, 10, 3, 1"); initDataBindings(); }