List of usage examples for javax.swing JLabel setText
@BeanProperty(preferred = true, visualUpdate = true, description = "Defines the single line of text this component will display.") public void setText(String text)
From source file:com.intel.stl.ui.monitor.view.PSPortsDetailsPanel.java
public void clear() { String na = STLConstants.K0039_NOT_AVAILABLE.getValue(); setTotalNumber(na);//from w w w .j a va 2 s. c om for (JLabel label : typeNumberLabels) { label.setText(na); } for (JLabel label : flowNumberLabels) { label.setText(na); } }
From source file:fr.isen.browser5.Util.UrlLoader.java
public void setTabTitleFavicon() { String title = doc.title();/*from w w w .j a v a2s . c om*/ title = Str.shortenString(title, 12); int tabIndex = tabView.getCurrentTabIndex(); JPanel tabPanel = (JPanel) tabView.getCurrentFrame().getTabPane().getTabComponentAt(tabIndex); JLabel titleLabel = (JLabel) tabPanel.getComponent(0); titleLabel.setText(title); String baseUrl = pageUrl.getProtocol() + "://" + pageUrl.getHost(); Element element = doc.head().select("link[href~=.*\\.(ico|png)]").first(); String favicoUrlStr = ""; if (element != null) { favicoUrlStr = element.attr("abs:href"); } else { element = doc.head().select("meta[itemprop=image]").first(); if (element != null) { favicoUrlStr = baseUrl + element.attr("content"); } } ImageIcon icon = null; try { if (!favicoUrlStr.isEmpty()) { if (favicoUrlStr.endsWith(".ico")) { java.util.List<BufferedImage> imgs = ICODecoder.read(new URL(favicoUrlStr).openStream()); icon = new ImageIcon(imgs.get(0)); } else { icon = new ImageIcon(new URL(favicoUrlStr)); } icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_DEFAULT)); } } catch (IOException e) { e.printStackTrace(); } titleLabel.setIcon(icon); HistoryEntry historyEntry = new HistoryEntry(title, pageUrl.toString(), Instant.now().getEpochSecond(), icon, -1L); globalHistoryDAO.create(historyEntry); }
From source file:SpinnerTest.java
/** * Adds a row to the main panel.// ww w . j a va2 s . co m * @param labelText the label of the spinner * @param spinner the sample spinner */ public void addRow(String labelText, final JSpinner spinner) { mainPanel.add(new JLabel(labelText)); mainPanel.add(spinner); final JLabel valueLabel = new JLabel(); mainPanel.add(valueLabel); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Object value = spinner.getValue(); valueLabel.setText(value.toString()); } }); }
From source file:de.tor.tribes.ui.renderer.TendencyTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); JLabel label = (JLabel) c; Integer val = (Integer) value; String text = ""; if (val == 0) { label.setIcon(yellow);/*from w ww.j av a2 s .c o m*/ } else if (val > 0) { label.setIcon(red); text = "(+ " + val + ")"; } else if (val < 0) { label.setIcon(green); text = "(" + val + ")"; } label.setText(StringUtils.center(text, 9)); return label; }
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);// w w w . jav a 2 s . c o m tags.setText(Utils.implode(new ArrayList<String>(server.getTags()), ", ")); tags.setForeground(foreground); return tags; }
From source file:edu.ku.brc.specify.config.init.DatabasePanel.java
/** * @param label/* w w w . j a v a 2 s . c o m*/ * @param text * @param badKeyArg * @param errKeyArg * @param isPwd * @return */ public static boolean checkForValidText(final JLabel label, final String text, final String badKeyArg, final String errKeyArg, final boolean isPwd) { String errKey = null; if (!isPwd && !text.isEmpty() && !StringUtils.isAlpha(text.substring(0, 1))) { errKey = badKeyArg; } else if (StringUtils.contains(text, ' ') || StringUtils.contains(text, ',')) { errKey = errKeyArg; } if (errKey != null) { label.setForeground(Color.RED); label.setText(getResourceString(errKeyArg)); label.setVisible(true); return false; } return true; }
From source file:Unicode.java
/** * Go to a given page of Unicode. At present the parameter is a code value, * but it should be a page #./* w w w . j a va 2 s . c o m*/ */ private void gotoPage(int startNum) { // System.out.println("startAt(" + startNum + ")"); char chars[] = new char[1]; for (int i = 0; i < ROWS; i++) { JLabel l = rowLabs[i]; // System.out.println("i=" + i + ", JLabel=" + l); l.setText(Integer.toString(startNum + (i * COLUMNS), 16)); // l.validate(); // size may be too big now for (int j = 0; j < COLUMNS; j++) { chars[0] = (char) (startNum + ((j * ROWS) + i)); JLabel b = buttons[i][j]; b.setText(new String(chars)); } } repaint(); }
From source file:sample.fa.ScriptRunnerApplication.java
void createGUI() { Box buttonBox = Box.createHorizontalBox(); JButton loadButton = new JButton("Load"); loadButton.addActionListener(this::loadScript); buttonBox.add(loadButton);/*ww w.java 2 s . c om*/ JButton saveButton = new JButton("Save"); saveButton.addActionListener(this::saveScript); buttonBox.add(saveButton); JButton executeButton = new JButton("Execute"); executeButton.addActionListener(this::executeScript); buttonBox.add(executeButton); languagesModel = new DefaultComboBoxModel(); ScriptEngineManager sem = new ScriptEngineManager(); for (ScriptEngineFactory sef : sem.getEngineFactories()) { languagesModel.addElement(sef.getScriptEngine()); } JComboBox<ScriptEngine> languagesCombo = new JComboBox<>(languagesModel); JLabel languageLabel = new JLabel(); languagesCombo.setRenderer((JList<? extends ScriptEngine> list, ScriptEngine se, int index, boolean isSelected, boolean cellHasFocus) -> { ScriptEngineFactory sef = se.getFactory(); languageLabel.setText(sef.getEngineName() + " - " + sef.getLanguageName() + " (*." + String.join(", *.", sef.getExtensions()) + ")"); return languageLabel; }); buttonBox.add(Box.createHorizontalGlue()); buttonBox.add(languagesCombo); scriptContents = new JTextArea(); scriptContents.setRows(8); scriptContents.setColumns(40); scriptResults = new JTextArea(); scriptResults.setEditable(false); scriptResults.setRows(8); scriptResults.setColumns(40); JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scriptContents, scriptResults); JFrame frame = new JFrame("Script Runner"); frame.add(buttonBox, BorderLayout.NORTH); frame.add(jsp, BorderLayout.CENTER); frame.pack(); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setVisible(true); }
From source file:es.emergya.ui.base.LoginWindow.java
private void initialize() { ventana.getContentPane().removeAll(); ventana.setLayout(new BorderLayout()); ventana.setSize(new Dimension(800, 600)); JPanel panel = new JPanel(new GridBagLayout()); panel.setBackground(Color.WHITE); JPanel logos = new JPanel(new GridLayout(2, 1)); logos.add(new JLabel(LogicConstants.getIcon("login_logo_cliente"))); logos.add(new JLabel(LogicConstants.getIcon("login_logo"))); logos.setBackground(Color.WHITE); JLabel label = new JLabel(); label.setText(i18n.getString("11")); //$NON-NLS-1$ JLabel labelUsuario = new JLabel(); labelUsuario.setText(i18n.getString("12")); //$NON-NLS-1$ JLabel lablep = new JLabel(); lablep.setText(i18n.getString("13")); //$NON-NLS-1$ panel.add(logos, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(error, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(labelUsuario, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(usuario, new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(lablep, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(pass, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(conectando, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); panel.add(login, new GridBagConstraints(1, 6, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0)); panel.setBorder(new EmptyBorder(100, 100, 100, 100)); ventana.add(panel, BorderLayout.CENTER); JPanel abajo = new JPanel(); abajo.setLayout(new FlowLayout(FlowLayout.RIGHT)); abajo.add(version);/*from ww w.j a v a 2 s. c o m*/ abajo.setOpaque(false); ventana.add(abajo, BorderLayout.SOUTH); try { label.setFont(LogicConstants.deriveBoldFont(20.0f)); labelUsuario.setFont(LogicConstants.deriveBoldFont(20.0f)); lablep.setFont(LogicConstants.deriveBoldFont(20.0f)); login.setFont(LogicConstants.deriveBoldFont(20.0f)); error.setFont(LogicConstants.getBoldFont()); } catch (Exception e) { LOG.error("Error al inicializar el login", e); } ventana.setLocationRelativeTo(null); // ventana.pack(); }
From source file:Main.java
@Override public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { JLabel l = (JLabel) renderer.getTreeCellRendererComponent(tree, value, true, expanded, leaf, row, true); if (value instanceof DefaultMutableTreeNode) { Object userObject = ((DefaultMutableTreeNode) value).getUserObject(); if (userObject instanceof CheckBoxNode) { CheckBoxNode node = (CheckBoxNode) userObject; l.setText(node.text); check.setSelected(node.selected); str = node.text;// w w w . j a v a 2 s . com } p.add(l); return p; } return l; }