Java Code Examples for javax.swing.JLabel.setText()

The following are Jave code examples for showing how to use setText() of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AgentWorkbench   File: BaseAgents.java   View Source Code Vote up 6 votes
/**
 * This method initializes this
 * @return void
 */
private void initialize() {
	jLabelAgent = new JLabel();
	jLabelAgent.setText("Agent:");
	jLabelAgent.setFont(new Font("Dialog", Font.BOLD, 12));
	jLabelStart = new JLabel();
	jLabelStart.setText("Starten als:");
	jLabelStart.setFont(new Font("Dialog", Font.BOLD, 12));

	
	this.setOneTouchExpandable(false);
	this.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
	this.setDividerSize(3);
	this.setResizeWeight(0.5);
	this.setSize(new Dimension(1003, 568));
	this.setLeftComponent(this.getJPanelWest());
	this.setRightComponent(this.getJPanelEast());
}
 
Example 2
Project: rapidminer   File: CollectionTreeCellRenderer.java   View Source Code Vote up 6 votes
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf,
		int row, boolean hasFocus) {
	JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
	CollectionTreeElement treeElement = (CollectionTreeElement) value;
	IOObject ioobject = treeElement.getIOObject();
	if (ioobject instanceof ResultObject) {
		ResultObject ro = (ResultObject) ioobject;
		String name = childNames.get(ro);
		if (name == null) {
			name = ro.getName();
		}
		String source = ro.getSource() != null ? " (<small>" + ro.getSource() + "</small>)" : "";
		label.setText("<html>" + name + source + "</html>");
		if (ro instanceof IOObjectCollection) {
			label.setIcon(expanded ? ICON_FOLDER_OPEN : ICON_FOLDER_CLOSED);
		} else {
			Icon resultIcon = ro.getResultIcon();
			label.setIcon(resultIcon);
		}
	} else if (ioobject instanceof IOObject) {
		IOObject ioo = ioobject;
		label.setText(ioo.getClass().getSimpleName());
	}
	return label;
}
 
Example 3
Project: incubator-netbeans   File: UnitTab.java   View Source Code Vote up 6 votes
@Override
public Component getTableCellRendererComponent (
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    JLabel renderComponent = (JLabel)super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
    
    if (value instanceof Image) {
        Unit u = model.getUnitAtRow(table.convertRowIndexToModel(row));
        if (u instanceof Unit.Available) {
            Unit.Available a = (Unit.Available)u;
            renderComponent.setIcon(ImageUtilities.image2Icon(a.getSourceIcon()));
            renderComponent.setText ("");
            renderComponent.setHorizontalAlignment (SwingConstants.CENTER);
        }
        
    }
    Component retval = renderComponent;
    return retval;
}
 
Example 4
Project: geomapapp   File: HyperlinkTableRenderer.java   View Source Code Vote up 6 votes
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {
	JLabel l = (JLabel) renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
	boolean plotable;
	if (value != null && value instanceof String) {
		try {
			int plotColumn = ((XBTable) table).getPlotColumnIndex();
			 plotable = (boolean) table.getValueAt(row, plotColumn);
		} catch(Exception e) {
			plotable = true;
		}
		if (validURL((String)value) && plotable) {
			l.setText("<html><u><font color=\"blue\">" + l.getText() + "</font></u></html>");
		} else {
			l.setForeground(Color.BLACK);
		}
	}
	return l;
}
 
Example 5
Project: cuttlefish   File: MousePanel.java   View Source Code Vote up 5 votes
/**
 * This method initializes this
 * 
 * @return void
 */
private void initialize() {
	
	GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
	gridBagConstraints1.gridx = 1;
	gridBagConstraints1.gridy = 0;
	gridBagConstraints1.anchor = GridBagConstraints.CENTER;
	gridBagConstraints1.fill = GridBagConstraints.VERTICAL;

	jLabel1 = new JLabel();
	jLabel1.setText("Mode");
	jLabel1.setVisible(true);
	this.setLayout(new GridBagLayout());
	this.add(jLabel1, gridBagConstraints1);
}
 
Example 6
Project: freecol   File: ReportTradePanel.java   View Source Code Vote up 5 votes
private JLabel createNumberLabel(int value, boolean alwaysAddSign) {
    JLabel result = new JLabel(String.valueOf(value), JLabel.TRAILING);
    result.setBorder(Utility.CELLBORDER);
    if (value < 0) {
        result.setForeground(Color.RED);
    } else if (alwaysAddSign && value > 0) {
        result.setText("+" + value);
    }
    return result;
}
 
Example 7
Project: brModelo   File: FrameSobre.java   View Source Code Vote up 5 votes
void Inicie(ParteAjuda sel) {
        this.setTitle(sel.getTitulo());
        if (sel.getByteImage() != null || sel.getHtml() != null) {//.isEmpty()) {
            Pan.removeAll();
            int H = 0;
            int W = 0;
            if (!sel.getHtml().isEmpty()) {
                JLabel htmLbl = new JLabel();
                htmLbl.setText(sel.getHtml());
                htmLbl.repaint();
                Dimension d = htmLbl.getPreferredSize();
                int x = (getPreferredSize().width - d.width) / 2;
                if (getPreferredSize().width < d.width) {
                    x = 0;
                }
//                int y = (getPreferredSize().height - d.height - subPan.getPreferredSize().height) / 2;
//                if (getPreferredSize().height - subPan.getPreferredSize().height < d.height) {
//                    y = 0;
//                }
                htmLbl.setBounds(x, 0, d.width, d.height);
                //Pan.setBackground(Color.yellow);
                Pan.add(htmLbl);
                H = d.height + 10;
                W = d.width;
            }
            if (sel.getByteImage() != null) {
                ImageIcon img = new ImageIcon(sel.getByteImage());
                JLabel picLabel = new JLabel(img);
                W = W > img.getIconWidth() ? W : img.getIconWidth();
                picLabel.setBounds(0, H, img.getIconWidth(), img.getIconHeight());
                picLabel.setPreferredSize(new Dimension(img.getIconWidth(), img.getIconHeight()));
                H += img.getIconHeight();
                Pan.setPreferredSize(new Dimension(W, H));
                Pan.add(picLabel);
            }
            Pan.revalidate();
            Pan.repaint();
        }
    }
 
Example 8
Project: freecol   File: ModOptionUI.java   View Source Code Vote up 5 votes
/**
 * {@inheritDoc}
 */
@Override
public void setLabelValues(JLabel label, ModOption value) {
    FreeColModFile modFile = value.getValue();
    if (modFile == null) {
        label.setText(value.toString());
    } else {
        ModOptionUI.labelModFile(label, modFile);
    }
}
 
Example 9
Project: FreeCol   File: ReportTradePanel.java   View Source Code Vote up 5 votes
private JLabel createNumberLabel(int value, boolean alwaysAddSign) {
    JLabel result = new JLabel(String.valueOf(value), JLabel.TRAILING);
    result.setBorder(Utility.CELLBORDER);
    if (value < 0) {
        result.setForeground(Color.RED);
    } else if (alwaysAddSign && value > 0) {
        result.setText("+" + value);
    }
    return result;
}
 
Example 10
Project: SER316-Aachen   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
/**
 * Component used to render tree cells in treetable
 */
private Component getTaskTreeCellRenderer(Task t, boolean selected, boolean hasFocus) {
    JLabel tree_label = new JLabel();       
    tree_label.setText(t.getText());
    // XXX [alexeya] Disabled coz a bug with tooltips in TreeTables:
    //tree_label.setToolTipText(t.getDescription());
    tree_label.setIcon(getStatusIcon(t));
    applyFont(t, tree_label);
    return tree_label;        
}
 
Example 11
Project: incubator-netbeans   File: ConfigFilesUIs.java   View Source Code Vote up 5 votes
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    JLabel component = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    File file = (File)value;
    component.setText(displayName.getDisplayName(file));
    return component;
}
 
Example 12
Project: oxygen-git-plugin   File: WorkingCopySelectionPanel.java   View Source Code Vote up 5 votes
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {

	JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

	if (value != null) {
		comp.setToolTipText((String) value);
		String path = (String) value;
		path = path.replace("\\", "/");
		String rootFolder = path.substring(path.lastIndexOf('/') + 1);
		comp.setText(rootFolder);
	}
	return comp;
}
 
Example 13
Project: Wilmersdorf_SER316   File: TaskTreeTableCellRenderer.java   View Source Code Vote up 5 votes
/**
 * Component used to render tree cells in treetable
 */
private Component getTaskTreeCellRenderer(Task t, boolean selected, boolean hasFocus) {
    JLabel tree_label = new JLabel();       
    tree_label.setText(t.getText());
    // XXX [alexeya] Disabled coz a bug with tooltips in TreeTables:
    //tree_label.setToolTipText(t.getDescription());
    tree_label.setIcon(getStatusIcon(t));
    applyFont(t, tree_label);
    return tree_label;        
}
 
Example 14
Project: Wilmersdorf_SER316   File: NotesList.java   View Source Code Vote up 5 votes
public ListCellRenderer getCellRenderer() {
       return new DefaultListCellRenderer()  {

    public Component getListCellRendererComponent(
      JList list,
      Object value,            // value to display
      int index,               // cell index
      boolean isSelected,      // is the cell selected
      boolean cellHasFocus)    // the list and the cell have the focus
    {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        String s = value.toString();
        label.setText(s);
        //Note currentNote = CurrentProject.getNoteList().getActiveNote();
	 Note currentNote = CurrentNote.get();
        if (currentNote != null) {
           if (getNote(index).getId().equals(currentNote.getId()))
               label.setFont(label.getFont().deriveFont(Font.BOLD));
        }
        if (getNote(index).isMarked())
           label.setIcon(bookmarkIcon);
        //setIcon();
      /*if (isSelected) {
            setBackground(list.getSelectionBackground());
          setForeground(list.getSelectionForeground());
      }
        else {
          setBackground(list.getBackground());
          setForeground(list.getForeground());
      }
      setEnabled(list.isEnabled());
      setFont(list.getFont());
        setOpaque(true);*/
        label.setToolTipText(s);
        return label;
    }
   };

}
 
Example 15
Project: AgentWorkbench   File: UpdateOptions.java   View Source Code Vote up 4 votes
/**
 * This method initializes this
 * @return void
 */
private void initialize() {
	
	GridBagConstraints gbc_jButtonUpdateSiteApply = new GridBagConstraints();
	gbc_jButtonUpdateSiteApply.anchor = GridBagConstraints.WEST;
	gbc_jButtonUpdateSiteApply.insets = new Insets(20, 0, 0, 20);
	gbc_jButtonUpdateSiteApply.gridx = 1;
	gbc_jButtonUpdateSiteApply.gridy = 0;
	
	GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
	gridBagConstraints22.gridx = 0;
	gridBagConstraints22.anchor = GridBagConstraints.WEST;
	gridBagConstraints22.insets = new Insets(5, 20, 0, 5);
	gridBagConstraints22.gridy = 5;
	GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
	gridBagConstraints12.gridx = 0;
	gridBagConstraints12.anchor = GridBagConstraints.WEST;
	gridBagConstraints12.insets = new Insets(10, 20, 0, 5);
	gridBagConstraints12.gridy = 4;
	GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
	gridBagConstraints21.gridx = 0;
	gridBagConstraints21.insets = new Insets(0, 20, 20, 20);
	gridBagConstraints21.fill = GridBagConstraints.BOTH;
	gridBagConstraints21.weightx = 1.0;
	gridBagConstraints21.weighty = 1.0;
	gridBagConstraints21.gridy = 6;
	GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
	gridBagConstraints11.gridx = 0;
	gridBagConstraints11.anchor = GridBagConstraints.WEST;
	gridBagConstraints11.insets = new Insets(20, 20, 0, 10);
	gridBagConstraints11.gridy = 0;
	GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
	gridBagConstraints2.gridwidth = 2;
	gridBagConstraints2.gridx = 0;
	gridBagConstraints2.anchor = GridBagConstraints.WEST;
	gridBagConstraints2.insets = new Insets(5, 20, 0, 20);
	gridBagConstraints2.gridy = 3;
	GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
	gridBagConstraints1.gridwidth = 2;
	gridBagConstraints1.gridx = 0;
	gridBagConstraints1.anchor = GridBagConstraints.WEST;
	gridBagConstraints1.insets = new Insets(5, 20, 0, 20);
	gridBagConstraints1.gridy = 2;
	GridBagConstraints gridBagConstraints = new GridBagConstraints();
	gridBagConstraints.anchor = GridBagConstraints.WEST;
	gridBagConstraints.gridwidth = 2;
	gridBagConstraints.gridx = 0;
	gridBagConstraints.insets = new Insets(5, 20, 0, 20);
	gridBagConstraints.gridy = 1;

	jLabelUpdateDictionary = new JLabel();
	jLabelUpdateDictionary.setFont(new Font("Dialog", Font.BOLD, 12));
	jLabelUpdateDictionary.setText("W├Ârterbuch");
	
	this.setSize(631, 307);
	this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
	GridBagLayout gridBagLayout = new GridBagLayout();
	gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0};
	this.setLayout(gridBagLayout);
	
	this.add(getJButtonUpdateSiteApply(), gbc_jButtonUpdateSiteApply);
	this.add(getJRadioButtonUpdateAutomated(), gridBagConstraints);
	this.add(getJRadioButtonUpdateDownloadAndAsk(), gridBagConstraints1);
	this.add(getJRadioButtonUpdateDisabled(), gridBagConstraints2);
	this.add(getJLabelUpdateTitle(), gridBagConstraints11);
	this.add(getJPanelDummy(), gridBagConstraints21);
	this.add(jLabelUpdateDictionary, gridBagConstraints12);
	this.add(getJCheckBoxUpdateKeepDictionary(), gridBagConstraints22);
	
	ButtonGroup updateAutoConfig = new ButtonGroup();
	updateAutoConfig.add(this.getJRadioButtonUpdateAutomated());
	updateAutoConfig.add(this.getJRadioButtonUpdateDownloadAndAsk());
	updateAutoConfig.add(this.getJRadioButtonUpdateDisabled());
	
}
 
Example 16
Project: Star-Ride--RiverRaid   File: PanelScore.java   View Source Code Vote up 4 votes
/**
 * Inicia los componentes del panel del Score
 */
public void initComponents(){
    int extra = 30;
    //FUENTE
    StarJedi = this.cargarFuente("../Starjedi.ttf");
    
    /**
     * TODO TIEMPO
     */
    iconTiempo = new JLabel("tiempo");               
    iconTiempo.setBounds(40, 10+extra, 200, 50);
    iconTiempo.setForeground(Color.yellow);
    iconTiempo.setFont(StarJedi);
    
    intTiempo = 0;
    tiempo = new JLabel(String.valueOf(intTiempo));
    tiempo.setBounds(82, 80+extra, 100, 30);
    tiempo.setForeground(Color.yellow);
    tiempo.setFont(StarJedi.deriveFont(1, 22f));
    
    /**
     * TODO SCORE
     */
    iconScore = new JLabel("score");               
    iconScore.setBounds(45, 130+extra, 200, 50);
    iconScore.setForeground(Color.yellow);
    iconScore.setFont(StarJedi);
    
    intScore = 0;
    score = new JLabel(String.valueOf(intScore));
    score.setForeground(Color.yellow);
    score.setFont(StarJedi.deriveFont(1, 22f));
    score.setBounds(90, 200+extra, 100, 30);
    
    /**
     * TODO COMBUSTIBLE
     */
    iconFuel = new JLabel();               
    iconFuel.setBounds(10, 250+extra, 200, 50);
    iconFuel.setForeground(Color.yellow);
    iconFuel.setFont(StarJedi.deriveFont(1, 22f));
    iconFuel.setText("Combustible");
    
    fuel = new JProgressBar(0);
    fuel.setBounds(25, 325+extra, 150, 30);  
    fuel.setValue(100);
    fuel.setBackground(Color.BLACK);
    
    /**
     * TODO VIDAS
     */
    iconLives = new JLabel();               
    iconLives.setBounds(43, 380+extra, 200, 50);
    iconLives.setForeground(Color.yellow);
    iconLives.setFont(StarJedi);
    iconLives.setText("vidas");
    
    intLives = 3;
    lives = new JLabel(String.valueOf(intLives));
    lives.setForeground(Color.yellow);
    lives.setFont(StarJedi.deriveFont(1, 22f));
    lives.setBounds(90, 450+extra, 100, 30);
    
    super.add(iconTiempo, 0);
    super.add(tiempo, 0);
    super.add(iconScore, 0);
    super.add(score, 0);
    super.add(iconFuel, 0);
    super.add(fuel, 0);
    super.add(iconLives, 0);
    super.add(lives, 0);
}
 
Example 17
Project: Yass   File: TestPanel1.java   View Source Code Vote up 4 votes
private JPanel getContentPanel() {
    
    JPanel contentPanel1 = new JPanel();
    JPanel jPanel1 = new JPanel();
    
    welcomeTitle = new JLabel();
    blankSpace = new JLabel();
    jLabel1 = new JLabel();
    jLabel2 = new JLabel();
    jLabel3 = new JLabel();
    jLabel4 = new JLabel();
    jLabel5 = new JLabel();
    jLabel7 = new JLabel();
    jLabel6 = new JLabel();
    jLabel8 = new JLabel();
    jLabel9 = new JLabel();

    contentPanel1.setLayout(new java.awt.BorderLayout());

    welcomeTitle.setFont(new java.awt.Font("MS Sans Serif", Font.BOLD, 11));
    welcomeTitle.setText("Welcome to the Wizard Dialog!");
    contentPanel1.add(welcomeTitle, java.awt.BorderLayout.NORTH);

    jPanel1.setLayout(new java.awt.GridLayout(0, 1));

    jPanel1.add(blankSpace);
    jLabel1.setText("This is an example of a wizard dialog, which allows a user to traverse");
    jPanel1.add(jLabel1);
    jLabel2.setText("a number of panels (while entering data) until the wizard has enough ");
    jPanel1.add(jLabel2);
    jLabel3.setText("information to perform whatever end function is necessary. Note that");
    jPanel1.add(jLabel3);
    jLabel4.setText("panels are not necessarily ordered in a linear fashion, but instead in");
    jPanel1.add(jLabel4);
    jLabel5.setText("a tree-like manner (e.g., there may be more than one panel with a");
    jPanel1.add(jLabel5);
    jLabel7.setText("'Finish' button, and it depends on the user's entries as to how they ");
    jPanel1.add(jLabel7);
    jLabel6.setText("traverse the path). That's not the case with this example, however.");
    jPanel1.add(jLabel6);
    jPanel1.add(jLabel8);
    jLabel9.setText("Press the 'Next' button to continue....");
    jPanel1.add(jLabel9);

    contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER);

    return contentPanel1;
    
}
 
Example 18
Project: my-diploma-work   File: SearchFrame.java   View Source Code Vote up 4 votes
public void addDataToJLabel(JLabel jLabel, String data) {
    jLabel.setText(data);
}
 
Example 19
Project: incubator-netbeans   File: SwingAppLibDownloader.java   View Source Code Vote up 4 votes
private static JPanel problemPanel(String header, String message) {
    JPanel panel = new JPanel();
    JLabel jLabel1 = new javax.swing.JLabel();
    JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
    JTextArea jTextArea1 = new javax.swing.JTextArea();

    jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD));
    jLabel1.setText(header);

    jTextArea1.setColumns(20);
    jTextArea1.setEditable(false);
    jTextArea1.setLineWrap(true);
    jTextArea1.setWrapStyleWord(true);
    jTextArea1.setRows(5);
    jTextArea1.setText(message);
    jTextArea1.setOpaque(false);
    jScrollPane1.setViewportView(jTextArea1);

    javax.swing.GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jLabel1)
                    .addGap(107, 107, 107)))
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
            .addGap(82, 82, 82))
    );
    return panel;
}
 
Example 20
Project: FreeCol   File: AbstractUnitOptionUI.java   View Source Code Vote up 4 votes
@Override
public void setLabelValues(JLabel label, AbstractUnitOption value) {
    label.setText(Messages.message(value.getValue().getLabel()));
}