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:be.ac.ua.comp.scarletnebula.gui.windows.ServerPropertiesWindow.java
private Component getSingleStatisticsCommandComponent(final Server server) { return new ChangeableLabel(getStatisticsCommandRep(server), new Executable<JLabel>() { @Override//from w ww .j a v a 2s . c o m public void run(final JLabel text) { new EditStatisticsCommandWindow(ServerPropertiesWindow.this, server); text.setText(getStatisticsCommandRep(server)); } }); }
From source file:com.qspin.qtaste.ui.config.EngineTestConfigPanel.java
public void genUI() { scriptPanel = new JPanel(); reportingPanel = new JPanel(); JLabel reportingFormatLabel = new JLabel(); reportingFormatLabelComboBox = new JComboBox(); JLabel reportingDirLabel = new javax.swing.JLabel(); reportingDirLabelTextField = new javax.swing.JTextField(); reportingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Reporting")); reportingFormatLabel.setText("Format"); reportingFormatLabelComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "HTML", "XML" })); reportingDirLabel.setText("Directory:"); reportingDirLabelTextField.setText("jTextField3"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(reportingPanel); reportingPanel.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(reportingFormatLabel) .addGap(18, 18, 18).addComponent(reportingFormatLabelComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(reportingDirLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(reportingDirLabelTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(78, Short.MAX_VALUE))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(reportingFormatLabel).addComponent(reportingFormatLabelComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18)//from w w w . j av a 2s . c o m .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(reportingDirLabel).addComponent(reportingDirLabelTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(89, Short.MAX_VALUE))); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(reportingPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(scriptPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(scriptPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(reportingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); }
From source file:net.nosleep.superanalyzer.analysis.views.SummaryView.java
private void addStatTriple(JPanel panel, StringTriple triple) { JLabel wordLabel = new JLabel(triple.Name + ": "); wordLabel.setOpaque(false);/*from w w w .j a va2s .c om*/ wordLabel.setFont(Theme.getFont(12)); wordLabel.setHorizontalAlignment(JLabel.RIGHT); panel.add(wordLabel); JLabel wordField = new JLabel(); wordField.setOpaque(false); wordField.setFont(Theme.getBoldFont(12)); wordField.setBorder(new javax.swing.border.EmptyBorder(1, 1, 1, 1)); wordField.setForeground(Theme.getColorSet()[0]); panel.add(wordField); wordField.setText(triple.Value); wordField.setToolTipText(Misc.getTooltip(triple.Info)); }
From source file:AlignLabels.java
public AlignLabels() { JLabel label; setLayout(new GridLayout(3, 3)); label = createLabel("NW alignment"); setNWalignment(label);//w w w . j av a2 s . c o m label.setEnabled(false); labels[0] = label; label = createLabel("N alignment"); setNalignment(label); labels[1] = label; label = createLabel("NE alignment"); setNEalignment(label); labels[2] = label; label = createLabel("W alignment"); label.setText("<html><i>html based<br></i><font color=blue>W alignment</font>"); setWalignment(label); labels[3] = label; label = createLabel("C alignment"); setCalignment(label); label.setEnabled(false); labels[4] = label; label = createLabel("E alignment"); setEalignment(label); labels[5] = label; label = createLabel("SW alignment"); setSWalignment(label); labels[6] = label; label = createLabel("S alignment"); setSalignment(label); labels[7] = label; label = createLabel("SE alignment"); setSEalignment(label); label.setEnabled(false); labels[8] = label; }
From source file:com.opendoorlogistics.studio.tables.grid.HeaderCellRenderer.java
/** * @param value/*from ww w . ja v a 2 s. c om*/ * @param isSelected */ protected void prepareLabel(Object value, boolean isSelected, boolean italics, JLabel label) { StringBuilder builder = new StringBuilder(); if (value != null) { builder.append("<html><strong>"); if (italics) { builder.append("<em>"); } builder.append(StringEscapeUtils.escapeHtml4(value.toString())); if (italics) { builder.append("</em>"); } builder.append("</strong></html>"); } label.setText(builder.toString()); if (isSelected) { label.setBackground(selectedColour); } else { label.setBackground(disabledColour); } }
From source file:charts.Chart.java
public static void GraficoSeries() { //System.out.println("After initComponents"); JFrame janela = new JFrame("Example of the series graphic"); janela.getContentPane().setLayout(null); javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); jLabel1.setText(""); janela.getContentPane().add(jLabel1); y_of_x = new double[n_points]; x = new double[n_points]; XYSeries series1 = new XYSeries("Cos(x) versus x"); XYSeries series2 = new XYSeries("Cos^2(x) versus x"); for (int i = 0; i < n_points; i++) {//calculate the data to be plotted y_of_x[i] = Math.cos(i * Math.PI / 180); series1.add((double) i, y_of_x[i]);//add values to the series series2.add((double) i, Math.pow(y_of_x[i], 2)); }//from w ww .j a v a2 s .c om XYDataset dataset1 = new XYSeriesCollection(series1); XYDataset dataset2 = new XYSeriesCollection(series2); CombinedDomainXYPlot parent = new CombinedDomainXYPlot(new NumberAxis("x-angle argument")); XYItemRenderer renderer1 = new StandardXYItemRenderer(); XYPlot subplot1 = new XYPlot(dataset1, null, new NumberAxis("Cos(x)"), renderer1); NumberAxis axis1 = (NumberAxis) subplot1.getRangeAxis(); axis1.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 10)); axis1.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); axis1.setAutoRangeIncludesZero(false); parent.add(subplot1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); XYPlot subplot2 = new XYPlot(dataset2, null, new NumberAxis("Cos^2(x)"), renderer2); NumberAxis axis2 = (NumberAxis) subplot2.getRangeAxis(); axis2.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 10)); axis2.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); axis2.setAutoRangeIncludesZero(false); parent.add(subplot2, 1); JFreeChart chart = new JFreeChart("Cos(x) versus x", parent); ChartPanel myChart = new ChartPanel(chart); janela.setSize(500, 600); janela.setContentPane(myChart); janela.setVisible(true); }
From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java
private void updateParticipantPanel() { participantPanel.removeAll();/* www. ja v a 2s .co m*/ // setup layout String colLayout = "fill:default"; String rowLayout = "pref, 5px"; for (int i = 0; i <= getEditor().getSession().getParticipantCount(); i++) { rowLayout += ", pref, 5px"; } FormLayout layout = new FormLayout(colLayout, rowLayout); participantPanel.setLayout(layout); CellConstraints cc = new CellConstraints(); int currentRow = 1; String ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + "0"; PhonUIAction noPartSegmentAct = new PhonUIAction(this, "performSegmentation", null); noPartSegmentAct.putValue(Action.NAME, ksStr + " speaker undefined"); // setup labels to be used like buttons String segMsg = "Click name to create a new record:"; JLabel segLbl = new JLabel(segMsg); participantPanel.add(segLbl, cc.xy(1, currentRow)); currentRow += 2; JLabel noPartLbl = new JLabel(); String noPartMsg = ksStr + " <no speaker>"; noPartLbl.setText(noPartMsg); noPartLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); noPartLbl.addMouseListener(new SegmentLabelMouseHandler()); noPartLbl.setOpaque(false); participantPanel.add(noPartLbl, cc.xy(1, currentRow)); currentRow += 2; final Session session = getEditor().getSession(); int pIdx = 1; for (Participant p : session.getParticipants()) { ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + pIdx; final NewSegmentAction segmentAction = new NewSegmentAction(getEditor(), this, p); segmentAction.putValue(Action.NAME, ksStr + " " + p.toString()); JLabel participantLbl = new JLabel(); String participantStr = ksStr + " " + (p.getName() != null ? p.getName() : p.getId()); participantLbl.setText(participantStr); participantLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); participantLbl.addMouseListener(new SegmentLabelMouseHandler(p)); participantLbl.setOpaque(false); participantPanel.add(participantLbl, cc.xy(1, currentRow)); currentRow += 2; pIdx++; } }
From source file:com.sec.ose.osi.ui.dialog.setting.JPanReportProperty.java
/** * This method initializes jPanelValue * /* w w w . j av a 2s . c om*/ * @return javax.swing.JPanel */ private JPanel getJPanelValue() { if (jPanelValue == null) { jPanelValue = new JPanel(); jPanelValue.setLayout(new GridBagLayout()); jPanelValue.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanelValue.setPreferredSize(new Dimension(400, 200)); // Default Report Location jLabelDefaultReportLocation = new JLabel(); jLabelDefaultReportLocation.setText("Default Report Location:"); jLabelDefaultReportLocation.setHorizontalAlignment(SwingConstants.RIGHT); GridBagConstraints gridBagConstraintsjLabelDefaultReportLocation = new GridBagConstraints(); gridBagConstraintsjLabelDefaultReportLocation.gridx = 0; gridBagConstraintsjLabelDefaultReportLocation.fill = GridBagConstraints.HORIZONTAL; gridBagConstraintsjLabelDefaultReportLocation.insets = new Insets(5, 0, 0, 0); gridBagConstraintsjLabelDefaultReportLocation.gridy = 1; GridBagConstraints gridBagConstraintsjpanelDefaultReportLocation = new GridBagConstraints(); gridBagConstraintsjpanelDefaultReportLocation.fill = GridBagConstraints.BOTH; gridBagConstraintsjpanelDefaultReportLocation.gridy = 1; gridBagConstraintsjpanelDefaultReportLocation.weightx = 1.0; gridBagConstraintsjpanelDefaultReportLocation.insets = new Insets(10, 5, 5, 15); gridBagConstraintsjpanelDefaultReportLocation.gridx = 1; // reciprocal license jLabelReciprocalLicense = new JLabel(); jLabelReciprocalLicense.setText("Reciprocal License (RED):"); jLabelReciprocalLicense.setHorizontalAlignment(SwingConstants.RIGHT); GridBagConstraints gridBagConstraintsjLabelReciprocalLicense = new GridBagConstraints(); gridBagConstraintsjLabelReciprocalLicense.gridx = 0; gridBagConstraintsjLabelReciprocalLicense.insets = new Insets(0, 15, 0, 0); gridBagConstraintsjLabelReciprocalLicense.fill = GridBagConstraints.HORIZONTAL; gridBagConstraintsjLabelReciprocalLicense.gridy = 2; jPanelValue.add(jLabelDefaultReportLocation, gridBagConstraintsjLabelDefaultReportLocation); jPanelValue.add(getJPanelDefaultReportLocation(), gridBagConstraintsjpanelDefaultReportLocation); jPanelValue.add(jLabelReciprocalLicense, gridBagConstraintsjLabelReciprocalLicense); GridBagConstraints gridBagConstraintsgetJTextFieldReciprocalLicense = new GridBagConstraints(); gridBagConstraintsgetJTextFieldReciprocalLicense.gridx = 1; gridBagConstraintsgetJTextFieldReciprocalLicense.weightx = 1.0; gridBagConstraintsgetJTextFieldReciprocalLicense.fill = GridBagConstraints.BOTH; gridBagConstraintsgetJTextFieldReciprocalLicense.insets = new Insets(5, 5, 5, 15); gridBagConstraintsgetJTextFieldReciprocalLicense.gridy = 2; jPanelValue.add(getJTextFieldReciprocalLicense(), gridBagConstraintsgetJTextFieldReciprocalLicense); // major license jLabelMajorLicense = new JLabel(); jLabelMajorLicense.setText("Major License (ORANGE):"); jLabelMajorLicense.setHorizontalAlignment(SwingConstants.RIGHT); GridBagConstraints gridBagConstraintsjLabelMajorLicense = new GridBagConstraints(); gridBagConstraintsjLabelMajorLicense.gridx = 0; gridBagConstraintsjLabelMajorLicense.insets = new Insets(0, 15, 0, 0); gridBagConstraintsjLabelMajorLicense.fill = GridBagConstraints.HORIZONTAL; gridBagConstraintsjLabelMajorLicense.gridy = 3; jPanelValue.add(jLabelMajorLicense, gridBagConstraintsjLabelMajorLicense); GridBagConstraints gridBagConstraintsgetJTextFieldMajorLicense = new GridBagConstraints(); gridBagConstraintsgetJTextFieldMajorLicense.gridx = 1; gridBagConstraintsgetJTextFieldMajorLicense.weightx = 1.0; gridBagConstraintsgetJTextFieldMajorLicense.fill = GridBagConstraints.BOTH; gridBagConstraintsgetJTextFieldMajorLicense.insets = new Insets(5, 5, 5, 15); gridBagConstraintsgetJTextFieldMajorLicense.gridy = 3; jPanelValue.add(getJTextFieldMajorLicense(), gridBagConstraintsgetJTextFieldMajorLicense); GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridx = 1; gridBagConstraints3.weighty = 1.0; gridBagConstraints3.weightx = 0.0; gridBagConstraints3.gridy = 4; JLabel jLabelEmpty = new JLabel(); jLabelEmpty.setText(""); jPanelValue.add(jLabelEmpty, gridBagConstraints3); } return jPanelValue; }
From source file:mergedoc.ui.PreferencePanel.java
/** * ??????// ww w . j a va 2 s . c om * @return ?? * @throws MergeDocException ???????? */ private JComponent createUpperPanel() throws MergeDocException { // JLabel docLabel = docField.getLabel(); JLabel srcLabel = srcField.getLabel(); JLabel outLabel = outField.getLabel(); docLabel.setText("API "); srcLabel.setText(""); outLabel.setText(""); JLabel[] labels = { docLabel, srcLabel, outLabel }; ComponentFactory.ensureMaxFontWidth(labels); // JComboBox docCombo = docField.getComboBox(); JComboBox srcCombo = srcField.getComboBox(); JComboBox outCombo = outField.getComboBox(); docCombo.addItem(FileChooserField.ENCODING_AUTO); srcCombo.addItem(FileChooserField.ENCODING_AUTO); docCombo.setSelectedItem("UTF-8"); srcCombo.setSelectedItem(FileChooserField.ENCODING_DEFAULT); outCombo.setSelectedItem(FileChooserField.ENCODING_DEFAULT); JComboBox[] combos = { docCombo, srcCombo, outCombo }; ComponentFactory.ensureMaxFontWidth(combos); // ?? docField.setSelectionMode(FileChooserField.DIRECTORIES); srcField.setSelectionMode(FileChooserField.ZIP_TGZ_FILES); outField.setSelectionMode(FileChooserField.ZIP_FILES); docField.setChooseListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { resolveArchivePath(docField.getFile()); } }); // ?? JPanel panel = new TitledPanel(""); panel.add(docField); panel.add(srcField); panel.add(outField); // ?? final String OPTION_KEY = "target.directory"; String targetStr = System.getProperty(OPTION_KEY); if (targetStr != null) { File targetDir = new File(targetStr); if (!targetDir.exists() || targetDir.isFile()) { throw new MergeDocException(" " + OPTION_KEY + " ??? " + targetStr + " ?\n?????????"); } File docDir = searchDocDirectory(targetDir); if (docDir != null) { docField.setFile(docDir); } srcField.setFile(new File("")); outField.setFile(new File("")); resolveArchivePath(targetDir); } // ?? loadPersister(docField, Persister.DOC_DIR, Persister.DOC_ENC); loadPersister(srcField, Persister.IN_FILE, Persister.IN_ENC); loadPersister(outField, Persister.OUT_FILE, Persister.OUT_ENC); // ? String docPath = docField.getFile().getPath(); if (docPath.equals("")) { File home = new File(System.getProperty("java.home")); if (home.getName().equals("jre")) { home = home.getParentFile(); } File docDir = new File(home, "docs/ja/api"); if (docDir.exists()) { docField.setFile(docDir); resolveArchivePath(home); } } return panel; }
From source file:Installer.java
public static JLabel linkify(final String text, String URL, String toolTip) { URI temp = null;/*from www . j a v a2s . co m*/ try { temp = new URI(URL); } catch (Exception e) { e.printStackTrace(); } final URI uri = temp; final JLabel link = new JLabel(); link.setText("<HTML><FONT color=\"#000099\">" + text + "</FONT></HTML>"); if (!toolTip.equals("")) link.setToolTipText(toolTip); link.setCursor(new Cursor(Cursor.HAND_CURSOR)); link.addMouseListener(new MouseListener() { public void mouseExited(MouseEvent arg0) { link.setText("<HTML><FONT color=\"#000099\">" + text + "</FONT></HTML>"); } public void mouseEntered(MouseEvent arg0) { link.setText("<HTML><FONT color=\"#000099\"><U>" + text + "</U></FONT></HTML>"); } public void mouseClicked(MouseEvent arg0) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(uri); } catch (Exception e) { e.printStackTrace(); } } else { JOptionPane pane = new JOptionPane("Could not open link."); JDialog dialog = pane.createDialog(new JFrame(), ""); dialog.setVisible(true); } } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); return link; }