本文整理汇总了Java中javax.swing.JLabel.setText方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setText方法的具体用法?Java JLabel.setText怎么用?Java JLabel.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* 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());
}
示例2: getTreeCellRendererComponent
import javax.swing.JLabel; //导入方法依赖的package包/类
@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;
}
示例3: getTableCellRendererComponent
import javax.swing.JLabel; //导入方法依赖的package包/类
@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;
}
示例4: getTableCellRendererComponent
import javax.swing.JLabel; //导入方法依赖的package包/类
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;
}
示例5: initialize
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* 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);
}
示例6: createNumberLabel
import javax.swing.JLabel; //导入方法依赖的package包/类
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;
}
示例7: Inicie
import javax.swing.JLabel; //导入方法依赖的package包/类
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();
}
}
示例8: setLabelValues
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* {@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);
}
}
示例9: getTaskTreeCellRenderer
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* 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;
}
示例10: getListCellRendererComponent
import javax.swing.JLabel; //导入方法依赖的package包/类
@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;
}
示例11: getListCellRendererComponent
import javax.swing.JLabel; //导入方法依赖的package包/类
@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;
}
示例12: getCellRenderer
import javax.swing.JLabel; //导入方法依赖的package包/类
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;
}
};
}
示例13: initialize
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* 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());
}
示例14: initComponents
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* 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);
}
示例15: getContentPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
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;
}