本文整理了Java中javax.swing.JLabel.setText()
方法的一些代码示例,展示了JLabel.setText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setText()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setText
暂无
代码示例来源:origin: iluwatar/java-design-patterns
private void setup() {
setLayout(new BorderLayout());
JPanel panel = new JPanel();
add(jl, BorderLayout.SOUTH);
add(panel, BorderLayout.CENTER);
panel.setLayout(new GridLayout(6, 2));
panel.add(new JLabel("Name"));
panel.add(jtFields[0]);
panel.add(new JLabel("Contact Number"));
panel.add(jtFields[1]);
panel.add(new JLabel("Address"));
panel.add(jtAreas[0]);
panel.add(new JLabel("Deposit Number"));
Order order = new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2].getText(),
jtAreas[1].getText());
jl.setText(sendRequest(order));
});
代码示例来源:origin: libgdx/libgdx
public void addValue (final Value value) {
JLabel valueNameLabel = new JLabel(value.getName() + ":");
valuesPanel.add(valueNameLabel, new GridBagConstraints(0, -1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
final JLabel valueValueLabel = new JLabel();
valuesPanel.add(valueValueLabel, new GridBagConstraints(1, -1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
valueValueLabel.setOpaque(true);
if (value.getObject() instanceof java.awt.Color)
valueValueLabel.setIcon(getColorIcon((java.awt.Color)value.getObject()));
else
valueValueLabel.setText(value.toString());
valueValueLabel.addMouseListener(new MouseAdapter() {
public void mouseEntered (MouseEvent evt) {
valueValueLabel.setBackground(selectedColor);
}
public void mouseExited (MouseEvent evt) {
valueValueLabel.setBackground(null);
}
public void mouseClicked (MouseEvent evt) {
Object oldObject = value.getObject();
value.showDialog();
if (!value.getObject().equals(oldObject)) {
effect.setValues(values);
updateValues();
updateFont();
}
}
});
}
代码示例来源:origin: stackoverflow.com
private final Date now = new Date();
private final Timer timer = new Timer(1000, this);
private final JLabel text = new JLabel();
public void actionPerformed(ActionEvent e) {
now.setTime(System.currentTimeMillis());
text.setText(String.format("<html><body><font size='50'>%s</font></body></html>",sdf.format(now)));
JFrame f = new JFrame();
setTranslucency( f );
f.setUndecorated( true );
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setBackground(new Color(0f, 0f, 0f, 1f / 3f));
f.add(new Translucent());
f.pack();
f.setVisible(true);
代码示例来源:origin: stanfordnlp/CoreNLP
jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
urlTextField = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
openButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
jLabel2.setText("Type in the internet address of a document or web page.");
jPanel1.add(jLabel2);
jLabel1.setText("Open");
jPanel3.add(jLabel1);
getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame("Testing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(new DropPane());
message = new JLabel();
message.setFont(message.getFont().deriveFont(Font.BOLD, 24));
add(message);
@Override
public void run() {
message.setText("You dropped " + files.size() + " files");
代码示例来源: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);
代码示例来源:origin: stackoverflow.com
final JLabel label = new JLabel();
int timerDelay = 1000;
new Timer(timerDelay , new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (timeLeft > 0) {
label.setText("Closing in " + timeLeft + " seconds");
timeLeft--;
} else {
((Timer)e.getSource()).stop();
Window win = SwingUtilities.getWindowAncestor(label);
win.setVisible(false);
代码示例来源:origin: gocd/gocd
private void displayLaunchingProgress(Process server)
throws InterruptedException, IOException {
final JFrame frame = new JFrame("Go Server");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
server.destroy();
progressPane.progressBar.setVisible(false);
progressPane.label.setText(errormsg + " Please see /var/log/system.log for more info.");
frame.pack();
frame.setSize(frame.getPreferredSize());
代码示例来源:origin: RaiMan/SikuliX2
private void initBox() {
box = new JFrame();
box.setUndecorated(true);
box.setResizable(false);
status.setBackground(Color.white);
status.setFont(new Font(Font.MONOSPACED, Font.PLAIN, statusFontHeight));
status.setText(" , ");
status.setBorder(BorderFactory.createMatteBorder(0, statusLineWidht, statusLineWidht, statusLineWidht, Color.black));
pBox.add(content);
pBox.add(status);
running = true;
new Thread(new EventHandler()).start();
代码示例来源:origin: stackoverflow.com
s.getViewport().add(m_tree);
getContentPane().add(s, BorderLayout.CENTER);
setVisible(true);
(DefaultMutableTreeNode)value;
Object obj = node.getUserObject();
setText(obj.toString());
setText("Retrieving data...");
代码示例来源:origin: stackoverflow.com
final JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JLabel l = new JLabel();
l.setText("Time: " +
System.currentTimeMillis());
f.getContentPane().add(l, BorderLayout.CENTER);
f.getContentPane().add(b, BorderLayout.SOUTH);
f.setLocation(100, 100);
f.pack();
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
JPanel mainPanel = new JPanel(new BorderLayout());
{
JLabel centerLabel = new JLabel();
centerLabel.setText("Hello World");
mainPanel.add(centerLabel, BorderLayout.CENTER);
}
{
JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0,0));
{
JLabel label1 = new JLabel();
label1.setText("Hello");
southPanel.add(label1);
}
{
JLabel label2 = new JLabel();
label2.setText("World");
southPanel.add(label2);
}
mainPanel.add(southPanel, BorderLayout.SOUTH);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
pnlButtons = new javax.swing.JPanel();
sldVolume = new javax.swing.JSlider();
btnRewind = new javax.swing.JButton();
btnFF = new javax.swing.JButton();
btnOpen = new javax.swing.JButton();
pnlBar = new javax.swing.JPanel();
lblTime = new javax.swing.JLabel();
sldBar = new javax.swing.JSlider();
pnlButtons.add(btnOpen);
getContentPane().add(pnlButtons, java.awt.BorderLayout.CENTER);
lblTime.setText("0:00-0:00");
lblTime.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3));
pnlBar.add(lblTime);
pnlBar.add(sldBar);
getContentPane().add(pnlBar, java.awt.BorderLayout.PAGE_START);
代码示例来源:origin: RipMeApp/ripme
if (Utils.getConfigBoolean("history.warn_before_delete", true)) {
JPanel checkChoise = new JPanel();
checkChoise.setLayout(new FlowLayout());
JButton yesButton = new JButton("YES");
checkChoise.add(noButton);
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Are you sure?");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(checkChoise);
frame.setSize(405, 70);
return;
configSaveDirLabel.setText(Utils.shortenPath(chosenPath));
Utils.setConfigString("rips.directory", chosenPath);
});
代码示例来源:origin: libgdx/libgdx
public void addValue (final Value value) {
JLabel valueNameLabel = new JLabel(value.getName() + ":");
valuesPanel.add(valueNameLabel, new GridBagConstraints(0, -1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
final JLabel valueValueLabel = new JLabel();
valuesPanel.add(valueValueLabel, new GridBagConstraints(1, -1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
valueValueLabel.setOpaque(true);
if (value.getObject() instanceof java.awt.Color)
valueValueLabel.setIcon(getColorIcon((java.awt.Color)value.getObject()));
else
valueValueLabel.setText(value.toString());
valueValueLabel.addMouseListener(new MouseAdapter() {
public void mouseEntered (MouseEvent evt) {
valueValueLabel.setBackground(selectedColor);
}
public void mouseExited (MouseEvent evt) {
valueValueLabel.setBackground(null);
}
public void mouseClicked (MouseEvent evt) {
Object oldObject = value.getObject();
value.showDialog();
if (!value.getObject().equals(oldObject)) {
effect.setValues(values);
updateValues();
updateFont();
}
}
});
}
代码示例来源:origin: haraldk/TwelveMonkeys
private static void addImage(Container pParent, ImageReader pReader, int pImageNo, String pName) throws IOException {
final JLabel label = new JLabel();
final BufferedImage image = pReader.read(pImageNo);
label.setIcon(new Icon() {
private static final int SIZE = 110;
public void paintIcon(Component c, Graphics g, int x, int y) {
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.DARK_GRAY);
g.fillRoundRect(x, y, SIZE, SIZE, 10, 10);
g.drawImage(image, (SIZE - image.getWidth()) / 2 + x, (SIZE - image.getHeight()) / 2 + y, null);
}
public int getIconWidth() {
return SIZE;
}
public int getIconHeight() {
return SIZE;
}
});
label.setText("" + image.getWidth() + "x" + image.getHeight() + ": " + pName);
label.setToolTipText(image.toString());
pParent.add(label);
}
代码示例来源:origin: stackoverflow.com
JFrame f = new JFrame("MarqueeTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String s = "Tomorrow, and tomorrow, and tomorrow, "
+ "creeps in this petty pace from day to day, "
+ "sound and fury signifying nothing.";
MarqueePanel mp = new MarqueePanel(s, 32);
f.add(mp);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
mp.start();
private final JLabel label = new JLabel();
private final String s;
private final int n;
this.n = n;
label.setFont(new Font("Serif", Font.ITALIC, 36));
label.setText(sb.toString());
this.add(label);
index = 0;
label.setText(s.substring(index, index + n));
代码示例来源:origin: runelite/runelite
private JPanel makeSkillPanel(HiscoreSkill skill)
{
JLabel label = new JLabel();
label.setFont(FontManager.getRunescapeSmallFont());
label.setText("--");
String skillName = (skill == null ? "combat" : skill.getName().toLowerCase());
String directory = "/skill_icons";
if (skillName.equals("combat") || skillName.equals("overall"))
{
// Cannot use SpriteManager as HiscorePlugin loads before a Client is available
directory += "/";
}
else
{
directory += "_small/";
}
String skillIcon = directory + skillName + ".png";
log.debug("Loading skill icon from {}", skillIcon);
label.setIcon(new ImageIcon(ImageUtil.getResourceStreamFromClass(getClass(), skillIcon)));
boolean totalLabel = skill == HiscoreSkill.OVERALL || skill == null; //overall or combat
label.setIconTextGap(totalLabel ? 10 : 4);
JPanel skillPanel = new JPanel();
skillPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
skillPanel.setBorder(new EmptyBorder(2, 0, 2, 0));
skillLabels.add(label);
skillPanel.add(skillLabels.get(skillLabels.size() - 1));
return skillPanel;
}
代码示例来源:origin: google/google-java-format
panel = new JPanel();
panel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
enable = new JCheckBox();
enable.setText("Enable google-java-format");
panel.add(
enable,
new GridConstraints(
false));
final Spacer spacer1 = new Spacer();
panel.add(
spacer1,
new GridConstraints(
0,
false));
final JLabel label1 = new JLabel();
label1.setText("Code style");
panel.add(
label1,
new GridConstraints(
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame("table adjust example");
frame.add(createUI());
frame.pack();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
JPanel jPanel = new JPanel();
mainTable = new JTable(2, 3);
mainTable.setModel(new AbstractTableModel() {
JLabel parent = (JLabel) defaultRenderer.getTableCellRendererComponent(jTable, o, b, b1, row, column);
if (column == 0) {
parent.setText("name");
} else {
parent.setText("surname");
内容来源于网络,如有侵权,请联系作者删除!