List of usage examples for javax.swing JLabel getFont
@Transient
public Font getFont()
From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java
private JLabel getTagComponent(final Server server, final Color foreground) { final JLabel tags = new JLabel(); final Font tagFont = new Font(tags.getFont().getName(), Font.PLAIN, 11); tags.setFont(tagFont);//from ww w . ja v a2 s .c o m tags.setText(Utils.implode(new ArrayList<String>(server.getTags()), ", ")); tags.setForeground(foreground); return tags; }
From source file:org.apache.taverna.activities.xpath.ui.contextualview.XPathActivityMainContextualView.java
@Override public JComponent getMainFrame() { jpMainPanel = new JPanel(new GridBagLayout()); jpMainPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2), BorderFactory.createEmptyBorder())); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.weighty = 0;//from w w w. j av a2 s. c o m // --- XPath Expression --- c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 5, 5, 5); JLabel jlXPathExpression = new JLabel("XPath Expression:"); jlXPathExpression.setFont(jlXPathExpression.getFont().deriveFont(Font.BOLD)); jpMainPanel.add(jlXPathExpression, c); c.gridx++; c.weightx = 1.0; tfXPathExpression = new JTextField(); tfXPathExpression.setEditable(false); jpMainPanel.add(tfXPathExpression, c); // --- Label to Show/Hide Mapping Table --- final JLabel jlShowHideNamespaceMappings = new JLabel("Show namespace mappings..."); jlShowHideNamespaceMappings.setForeground(Color.BLUE); jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR)); jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible()); jlShowHideNamespaceMappings.setText( (spXPathNamespaceMappings.isVisible() ? "Hide" : "Show") + " namespace mappings..."); thisContextualView.revalidate(); } }); c.gridx = 0; c.gridy++; c.gridwidth = 2; c.weightx = 1.0; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; jpMainPanel.add(jlShowHideNamespaceMappings, c); // --- Namespace Mapping Table --- xpathNamespaceMappingsTableModel = new DefaultTableModel() { /** * No cells should be editable */ public boolean isCellEditable(int rowIndex, int columnIndex) { return (false); } }; xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix"); xpathNamespaceMappingsTableModel.addColumn("Namespace URI"); jtXPathNamespaceMappings = new JTable(); jtXPathNamespaceMappings.setModel(xpathNamespaceMappingsTableModel); jtXPathNamespaceMappings.setPreferredScrollableViewportSize(new Dimension(200, 90)); // TODO - next line is to be enabled when Taverna is migrated to Java // 1.6; for now it's fine to run without this // jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure // that when the dedicated area is larger than the table, the latter is // stretched vertically to fill the empty space jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set // relative // sizes of // columns jtXPathNamespaceMappings.getColumnModel().getColumn(1).setPreferredWidth(300); c.gridy++; spXPathNamespaceMappings = new JScrollPane(jtXPathNamespaceMappings); spXPathNamespaceMappings.setVisible(false); jpMainPanel.add(spXPathNamespaceMappings, c); // populate the view with values refreshView(); return jpMainPanel; }
From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java
public SettingsPanel(final Project prj, Color bgColor) { this.prj = prj; this.projectConf = prj.getComponent(AliProjectConfiguration.class); previewAndConnection = new JPanel(new GridBagLayout()); previewAndConnection.setOpaque(false); GridBagConstraints c2 = new GridBagConstraints(); c2.gridx = 0;//from w w w. j a v a2s . co m c2.gridy = 1; c2.gridwidth = 2; c2.weighty = 1; c2.fill = GridBagConstraints.VERTICAL; JPanel filler = new JPanel(); filler.setOpaque(false); previewAndConnection.add(filler, c2); passwordPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); passwordPanel.setBackground(bgColor); JLabel label = new JLabel("Password"); label.setFont(label.getFont().deriveFont(Font.BOLD)); passwordPanel.add(label); final JPasswordField password = new JPasswordField(24); passwordPanel.add(password); JButton connect = new JButton("Login"); passwordPanel.add(connect); final JLabel message = new JLabel(); passwordPanel.add(message); ActionListener connectionAction = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { try { checkConnection(projectConf.getLocation(), projectConf.getDomain(), projectConf.getProject(), projectConf.getUsername(), password.getText()); } catch (AuthenticationFailed e) { message.setText(e.getMessage()); return; } projectConf.ALM_PASSWORD = password.getText(); projectConf.fireChanged(); } }; password.addActionListener(connectionAction); connect.addActionListener(connectionAction); restService = prj.getComponent(RestService.class); restService.addServerTypeListener(this); location = createTextPane(bgColor); domain = createTextPane(bgColor); project = createTextPane(bgColor); username = createTextPane(bgColor); final JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(bgColor); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); final JTextPane textPane = new JTextPane(); textPane.setEditorKit(new HTMLEditorKit()); textPane.setText( "<html><body>HP ALM integration can be configured on <a href=\"ide\">IDE</a> and overridden on <a href=\"project\">project</a> level.</body></html>"); textPane.setEditable(false); textPane.addHyperlinkListener(this); textPane.setBackground(bgColor); textPane.setCaret(new NonAdjustingCaret()); panel.add(textPane, BorderLayout.CENTER); JPanel content = new JPanel(new BorderLayout()); content.setBackground(bgColor); content.add(panel, BorderLayout.NORTH); content.add(previewAndConnection, BorderLayout.WEST); preview = new JPanel(new GridBagLayout()) { public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); // make enough room for the connection status message dim.width = Math.max(dim.width, 300); return dim; } public Dimension getMinimumSize() { return getPreferredSize(); } }; connectedTo(restService.getServerTypeIfAvailable()); preview.setBackground(bgColor); final GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; preview.add(location, c); c.gridwidth = 1; c.gridy++; preview.add(domain, c); c.gridy++; preview.add(project, c); c.gridy++; preview.add(username, c); c.gridx++; c.gridy--; c.gridheight = 2; c.weightx = 0; c.anchor = GridBagConstraints.SOUTHEAST; final LinkLabel reload = new LinkLabel("Reload", IconLoader.getIcon("/actions/sync.png")); reload.setListener(new LinkListener() { public void linkSelected(LinkLabel linkLabel, Object o) { projectConf.fireChanged(); } }, null); preview.add(reload, c); JPanel previewNorth = new JPanel(new BorderLayout()); previewNorth.setBackground(bgColor); previewNorth.add(preview, BorderLayout.NORTH); addToGridBagPanel(0, 0, previewAndConnection, previewNorth); setBackground(bgColor); setLayout(new BorderLayout()); add(content, BorderLayout.CENTER); onChanged(); ApplicationManager.getApplication().getComponent(AliConfiguration.class).addListener(this); projectConf.addListener(this); }
From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java
private Component getNewServerServer(final JList list, final int index, final boolean isSelected) { final JPanel p = createServerPanel(null, list, index, isSelected); final JLabel label = new JLabel("Start a new server", new ImageIcon(getClass().getResource("/images/add.png")), SwingConstants.LEFT); label.setFont(new Font(label.getFont().getName(), Font.PLAIN, 16)); // Border for better horizontal alignment label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 12)); p.add(label);//from w ww. jav a2s. co m return p; }
From source file:org.jdal.swing.form.SimpleBoxFormBuilder.java
/** * Add a component with label, increments cursor by two. * @param name label string// w w w . ja v a 2 s . c om * @param c component. */ public void add(String name, Component c) { JLabel label = new JLabel(name); add(label); Rectangle2D rec = label.getFontMetrics(label.getFont()).getStringBounds(name, container.getGraphics()); setMaxWidth(rec.getBounds().width + 10); add(c); }
From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java
public void init(JsonNode metaData) { JsonNode depArray = metaData.path("dependencies").path("values"); final int nodeNum = depArray.size(); // remove informative label if (nodeNum > 0) { this.remove(lNotInitialized); }/* ww w . ja v a2 s.c om*/ // prepare dependencies checkboxes for (int i = 0; i < nodeNum; i++) { JsonNode gn = depArray.get(i); final String groupName = gn.path("name").asText(); // group label JLabel lGroup = new JLabel(groupName); lGroup.setFont(lGroup.getFont().deriveFont(Font.BOLD, lGroup.getFont().getSize() + 2)); grpLabels.add(lGroup); this.add(lGroup, constraintsForGroupLabel(i == 0)); // starter checkboxes in two columns final JsonNode valArray = gn.path("values"); for (int j = 0; j < valArray.size(); j++) { // first column JsonNode dn = valArray.get(j); this.add(checkBoxForNode(groupName, dn), constraintsForFirstColumnCheckbox()); // second column (optional) if (++j < valArray.size()) { dn = valArray.get(j); this.add(checkBoxForNode(groupName, dn), constraintsForSecondColumnCheckbox()); } } } initialized = true; // force recompute of increments unitIncrement = null; blockIncrement = null; }
From source file:net.sf.jabref.gui.mergeentries.MergeEntries.java
private JLabel boldFontLabel(String text) { JLabel label = new JLabel(text); Font font = label.getFont(); label.setFont(font.deriveFont(font.getStyle() | Font.BOLD)); return label; }
From source file:cz.alej.michalik.totp.client.AddDialog.java
public AddDialog(final Properties prop) { System.out.println("Pridat novy zaznam"); this.setTitle("Pidat"); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setMinimumSize(new Dimension(600, 150)); this.setLocationByPlatform(true); // Panel pro vytvoen okraj JPanel panel = new JPanel(); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); panel.setLayout(new GridBagLayout()); // Vlastnosti pro popisky GridBagConstraints label = new GridBagConstraints(); label.insets = new Insets(2, 2, 2, 2); label.fill = GridBagConstraints.NONE; label.weightx = 1;//from w w w. ja v a2 s . c o m // Vlastnosti pro pole GridBagConstraints field = new GridBagConstraints(); field.insets = new Insets(2, 2, 2, 2); field.fill = GridBagConstraints.HORIZONTAL; field.weightx = 10; this.add(panel); // Nastavm ikonu okna try { String path = "/material-design-icons/content/drawable-xhdpi/ic_create_black_48dp.png"; this.setIconImage(Toolkit.getDefaultToolkit().getImage(App.class.getResource(path))); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pole pro pojmenovn zznamu // Ikona ImageIcon icon = null; try { String path = "/material-design-icons/editor/drawable-xhdpi/ic_format_color_text_black_18dp.png"; icon = new ImageIcon(App.class.getResource(path)); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pidn labelu s ikonou a nastavm velikost psma label.gridy = 0; field.gridy = 0; JLabel nameLabel = new JLabel("Nzev: ", icon, JLabel.CENTER); nameLabel.setFont(nameLabel.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(nameLabel, label); // Pole pro jmno final JTextField name = new JTextField(); name.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50)); name.setFont(name.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(name, field); // Pole pro zadn sdlenho hesla // Ikona icon = null; try { String path = "/material-design-icons/hardware/drawable-xhdpi/ic_security_black_18dp.png"; icon = new ImageIcon(App.class.getResource(path)); } catch (NullPointerException ex) { System.out.println("Icon not found"); } // Pidn labelu s ikonou label.gridy = 1; field.gridy = 1; JLabel secretLabel = new JLabel("Heslo: ", icon, JLabel.CENTER); secretLabel.setFont(secretLabel.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(secretLabel, label); // Pole pro heslo final JTextField secret = new JTextField(); secret.setMaximumSize(new Dimension(Integer.MAX_VALUE, 50)); secret.setFont(secret.getFont().deriveFont(App.FONT_SIZE * 2 / 3)); panel.add(secret, field); this.setVisible(true); // Akce pro odesln formule ActionListener submit = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { submit(prop, name, secret, false); } }; // Pi stisku klvesy Enter odele formul name.addActionListener(submit); secret.addActionListener(submit); // Pi zmn pole pro heslo se vstup okamit zformtuje final Runnable sanitizer = new Runnable() { @Override public void run() { sanitize(secret); } }; secret.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { } @Override public void insertUpdate(DocumentEvent e) { SwingUtilities.invokeLater(sanitizer); } @Override public void changedUpdate(DocumentEvent e) { } }); // Pi zaven okna odele formul this.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { // Ignorovat } @Override public void windowIconified(WindowEvent e) { // Ignorovat } @Override public void windowDeiconified(WindowEvent e) { // Ignorovat } @Override public void windowDeactivated(WindowEvent e) { // Ignorovat } @Override public void windowClosing(WindowEvent e) { // Odeslat submit(prop, name, secret, true); } @Override public void windowClosed(WindowEvent e) { // Ignorovat } @Override public void windowActivated(WindowEvent e) { // Ignorovat } }); }
From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java
private void init() { segmentWindowField = new JTextField(); SegmentWindowDocument segDoc = new SegmentWindowDocument(); segmentWindowField.setDocument(segDoc); segmentWindowField.setText(DEFAULT_SEGMENT_WINDOW + ""); segDoc.addDocumentListener(new SegmentWindowListener()); segmentLabel = new SegmentLabel(); segmentLabel.setSegmentWindow(DEFAULT_SEGMENT_WINDOW); segmentLabel.setCurrentTime(0L);/*from www . j ava 2 s . c o m*/ segmentLabel.lockSegmentStartTime(-1L); modeBox = new JComboBox(SegmentationMode.values()); modeBox.setSelectedItem(SegmentationMode.INSERT_AFTER_CURRENT); JPanel topPanel = new JPanel(); FormLayout topLayout = new FormLayout("right:pref, 3dlu, fill:default:grow, pref", "pref, pref, pref, pref"); topPanel.setLayout(topLayout); CellConstraints cc = new CellConstraints(); topPanel.add(new JLabel("Segment Window"), cc.xy(1, 1)); topPanel.add(segmentWindowField, cc.xy(3, 1)); topPanel.add(new JLabel("ms"), cc.xy(4, 1)); JLabel infoLabel = new JLabel("Set to 0 for unlimited segment time"); infoLabel.setFont(infoLabel.getFont().deriveFont(10.0f)); topPanel.add(infoLabel, cc.xy(3, 2)); topPanel.add(new JLabel("Current Window"), cc.xy(1, 3)); topPanel.add(segmentLabel, cc.xy(3, 3)); topPanel.add(new JLabel("Mode"), cc.xy(1, 4)); topPanel.add(modeBox, cc.xyw(3, 4, 2)); setLayout(new BorderLayout()); add(topPanel, BorderLayout.NORTH); participantPanel = new JPanel(); participantPanel.setBackground(Color.white); participantPanel.setOpaque(true); JScrollPane participantScroller = new JScrollPane(participantPanel); Dimension prefSize = participantScroller.getPreferredSize(); prefSize.height = 150; participantScroller.setPreferredSize(prefSize); Dimension maxSize = participantScroller.getMaximumSize(); maxSize.height = 200; participantScroller.setMaximumSize(maxSize); Dimension minSize = participantScroller.getMinimumSize(); minSize.height = 100; participantScroller.setMinimumSize(minSize); participantScroller.setBorder(BorderFactory.createTitledBorder("Participants")); add(participantScroller, BorderLayout.CENTER); updateParticipantPanel(); setupEditorActions(); }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjAggregatorDlg.java
/** * @param key/*from w ww . ja v a 2s . c o m*/ * @return */ protected JLabel createI18NFormLabelBold(final String key) { JLabel lbl = createI18NFormLabel(key); Font lblFont = lbl.getFont().deriveFont(Font.BOLD); lbl.setFont(lblFont); return lbl; }