本文整理了Java中javax.swing.JLabel.getText()
方法的一些代码示例,展示了JLabel.getText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.getText()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:getText
暂无
代码示例来源:origin: deathmarine/Luyten
private void setLinkLabel(JLabel label, String text) {
String current = label.getText();
if (text == null && current != null)
if (current.startsWith("Navigating:") || current.startsWith("Cannot navigate:"))
return;
label.setText(text != null ? text : "Complete");
}
代码示例来源:origin: skylot/jadx
private Component makeCell(JNode node, int column) {
if (column == 0) {
JLabel label = new JLabel(node.makeLongString() + " ", node.getIcon(), SwingConstants.LEFT);
label.setFont(font);
label.setOpaque(true);
label.setToolTipText(label.getText());
return label;
}
if (!node.hasDescString()) {
return emptyLabel;
}
RSyntaxTextArea textArea = CodeArea.getDefaultArea(mainWindow);
textArea.setLayout(new GridLayout(1, 1));
textArea.setEditable(false);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setText(" " + node.makeDescString());
textArea.setRows(1);
textArea.setColumns(textArea.getText().length() + 1);
if (highlightText != null) {
SearchContext searchContext = new SearchContext(highlightText);
searchContext.setMatchCase(!highlightTextCaseInsensitive);
searchContext.setMarkAll(true);
SearchEngine.markAll(textArea, searchContext);
}
return textArea;
}
代码示例来源:origin: stackoverflow.com
contentPane.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel label = new JLabel(LABEL_TEXT);
contentPane.add(label);
label = new JLabel(A_VALID_LINK);
contentPane.add(label);
if (isBrowsingSupported()) {
makeLinkable(label, new LinkMouseListener());
c.setText(htmlIfy(linkIfy(c.getText())));
c.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
c.addMouseListener(ml);
JLabel l = (JLabel) evt.getSource();
try {
URI uri = new java.net.URI(JLabelLink.getPlainLink(l.getText()));
(new LinkRunner(uri)).execute();
} catch (URISyntaxException use) {
throw new AssertionError(use + ": " + l.getText()); //NOI18N
代码示例来源:origin: stackoverflow.com
import javax.swing.JLabel;
class Test1 {
private final static JLabel l = new JLabel("Old text");
public static void main(String[] args) {
System.err.println(l.getText());
l.setText("New Text");
System.err.println(l.getText());
}
}
代码示例来源:origin: stackoverflow.com
s.getViewport().add(m_tree);
getContentPane().add(s, BorderLayout.CENTER);
(DefaultMutableTreeNode)value;
Object obj = node.getUserObject();
setText(obj.toString());
setText("Retrieving data...");
if(icon != null && getText() != null)
offset = (icon.getIconWidth() + getIconTextGap());
g.fillRect(offset, 0, getWidth() - 1 - offset,
代码示例来源:origin: stackoverflow.com
p.add(f);
frame.add(p);
suggestionsPanel.add(suggestionLabel);
String suggestedWord = getText();
String text = textField.getText();
String typedWord = autoSuggestor.getCurrentlyTypedWord();
代码示例来源:origin: zzz40500/GsonFormat
@Override
public void mouseClicked(MouseEvent mouseEvent) {
super.mouseClicked(mouseEvent);
cardLayout.next(generateClassP);
if (generateClassLB.getText().equals(currentClass) && !TextUtils.isEmpty(Config.getInstant().getEntityPackName()) && !Config.getInstant().getEntityPackName().equals("null")) {
generateClassLB.setText(Config.getInstant().getEntityPackName());
generateClassTF.setText(Config.getInstant().getEntityPackName());
}
generateClassTF.requestFocus(true);
}
代码示例来源:origin: RipMeApp/ripme
gbc.gridx = 0; ripPanel.add(new JLabel("URL:", JLabel.RIGHT), gbc);
gbc.weightx = 1;
gbc.weighty = 1;
gbc.weightx = 1;
statusLabel = new JLabel(rb.getString("inactive"));
statusLabel.setHorizontalAlignment(JLabel.CENTER);
openButton = new JButton();
configUpdateLabel = new JLabel( rb.getString("current.version") + ": " + UpdateUtils.getThisJarVersion(), JLabel.RIGHT);
configThreadsLabel = new JLabel(rb.getString("max.download.threads") + ":", JLabel.RIGHT);
configTimeoutLabel = new JLabel(rb.getString("timeout.mill"), JLabel.RIGHT);
try {
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
configSaveDirLabel.setText(workingDir);
configSaveDirLabel.setForeground(Color.BLUE);
configSaveDirLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
} catch (Exception e) { }
configSaveDirLabel.setToolTipText(configSaveDirLabel.getText());
configSaveDirLabel.setHorizontalAlignment(JLabel.RIGHT);
configSaveDirButton = new JButton(rb.getString("select.save.dir") + "...");
代码示例来源:origin: geotools/geotools
case -LABEL:
value = description.getText();
return;
description.setText((String) value);
return;
BorderFactory.createEmptyBorder(0, HMARGIN, VMARGIN, HMARGIN));
namedArea.add(
new JLabel(getString(VocabularyKeys.WARNING)), BorderLayout.NORTH);
namedArea.add(scroll, BorderLayout.CENTER);
content.add(namedArea, BorderLayout.CENTER);
代码示例来源:origin: stackoverflow.com
import javax.swing.JLabel;
class Test1 {
public static void main(String[] args) {
final JLabel l;
String s = getArbitaryString(); // Assume this method returns a string
l = new JLabel(s);
System.err.println(l.getText());
}
}
代码示例来源:origin: stackoverflow.com
addRandom();
frame.add(tableaux, BorderLayout.CENTER);
JButton add = new JButton("Add");
add.addActionListener(this);
frame.add(add, BorderLayout.SOUTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WIDTH, HEIGHT);
Letter letter = new Letter(Character.toString((char) ('a' + random.nextInt(26))));
letter.setBounds(random.nextInt(WIDTH), random.nextInt(HEIGHT), 16, 16);
tableaux.add(letter);
setFont(font2);
Rectangle bounds = getBounds();
Rectangle2D stringBounds = font2.getStringBounds(getText(), fontRenderContext2);
bounds.width = (int) stringBounds.getWidth();
bounds.height = (int) stringBounds.getHeight();
setFont(font1);
Rectangle bounds = getBounds();
Rectangle2D stringBounds = font1.getStringBounds(getText(), fontRenderContext1);
bounds.width = (int) stringBounds.getWidth();
bounds.height = (int) stringBounds.getHeight();
代码示例来源:origin: dcevm/dcevm
l.setText(inst.getPath().toAbsolutePath().toString());
break;
case 1:
l.setText(inst.getVersion());
break;
case 2:
l.setText(inst.isJDK() ? "JDK" : "JRE");
if (inst.is64Bit()) {
l.setText(l.getText() + " (64 Bit)");
代码示例来源:origin: stackoverflow.com
DragPanel p1 = new DragPanel();
p1.setBorder(BorderFactory.createLineBorder(Color.BLACK));
p1.add(new JLabel(UIManager.getIcon("OptionPane.warningIcon")));
p1.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
p1.add(new JLabel("Label1"));
p1.add(new JLabel("Label2"));
MouseListener handler = new Handler();
DragPanel p = (DragPanel)c;
JLabel l = p.draggingLabel;
String text = l.getText();
DragPanel p = (DragPanel)c;
label.setIcon(p.draggingLabel.getIcon());
label.setText(p.draggingLabel.getText());
window.pack();
Point pt = p.draggingLabel.getLocation();
JLabel l = new JLabel();
l.setIcon(src.draggingLabel.getIcon());
l.setText(src.draggingLabel.getText());
target.add(l);
target.revalidate();
代码示例来源:origin: stackoverflow.com
JLabel counter = new JLabel("Hello World");
String ret;
if(counter.getText().equals("Hello World")){
ret = counter.getText();
counter.setText("0");
}
代码示例来源:origin: magefree/mage
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// get table text cell settings
DefaultTableCellRenderer baseRenderer = (DefaultTableCellRenderer) table.getDefaultRenderer(String.class);
JLabel baseComp = (JLabel) baseRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String skillCode = baseComp.getText();
// apply settings to render panel from parent
renderPanel.setOpaque(baseComp.isOpaque());
renderPanel.setForeground(CardRendererUtils.copyColor(baseComp.getForeground()));
renderPanel.setBackground(CardRendererUtils.copyColor(baseComp.getBackground()));
renderPanel.setBorder(baseComp.getBorder());
// create each skill symbol as child label
renderPanel.removeAll();
renderPanel.setLayout(new BoxLayout(renderPanel, BoxLayout.X_AXIS));
for (char skillSymbol : skillCode.toCharArray()) {
JLabel symbolLabel = new JLabel();
symbolLabel.setBorder(new EmptyBorder(0, 3, 0, 0));
symbolLabel.setIcon(skillIcon);
renderPanel.add(symbolLabel);
}
return renderPanel;
}
};
代码示例来源:origin: winder/Universal-G-Code-Sender
private void setAllCaps(JLabel... labels) {
Arrays.stream(labels).forEach(l -> l.setText(l.getText().toUpperCase()));
}
代码示例来源:origin: stackoverflow.com
import javax.swing.JLabel;
import javax.swing.JPanel;
public class ReactionPanel extends JPanel {
private JLabel label;
public ReactionPanel() {
label = new JLabel("PING");
this.add(label);
}
public void react() {
if(label.getText().equals("PING")) {
label.setText("PONG");
} else {
label.setText("PING");
}
}
}
代码示例来源:origin: stackoverflow.com
JLabel myLabel = new JLabel();
myLabel.setText("abc");
myLabel.setText(myLabel.getText() + "def");
System.out.println(myLabel.getText()); // "abcdef"
代码示例来源:origin: violetumleditor/violetumleditor
/**
* @return label
* @see JLabel
*/
private JLabel getLabel()
{
if (null == label || null == label.getText())
{
label = new JLabel("");
}
return label;
}
代码示例来源:origin: winder/Universal-G-Code-Sender
@Override
public void fileStreamComplete(String filename, boolean success) {
remainingTimeValueLabel.setText(Utils.formattedMillis(0));
remainingRowsValueLabel.setText("" + backend.getNumRemainingRows());
final String durationLabelCopy = this.durationValueLabel.getText();
if (success) {
java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() {
JOptionPane.showMessageDialog(new JFrame(),
Localization.getString("mainWindow.ui.jobComplete") + " " + Utils.formattedMillis(backend.getSendDuration()),
Localization.getString("success"), JOptionPane.INFORMATION_MESSAGE);
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {}
// Stop the timer after a delay to make sure it is updated.
timer.stop();
}});
} else {
displayErrorDialog(Localization.getString("mainWindow.error.jobComplete"));
}
}
内容来源于网络,如有侵权,请联系作者删除!