本文整理了Java中java.awt.Label
类的一些代码示例,展示了Label
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label
类的具体详情如下:
包路径:java.awt.Label
类名称:Label
暂无
代码示例来源:origin: wildfly/wildfly
public void init() {
setLayout(new BorderLayout());
panel = new GraphPanel(this);
panel.setBackground(Color.white);
add("Center", panel);
Panel p = new Panel();
leave_button = new Button("Exit");
leave_button.setFont(default_font);
leave_button.addActionListener(this);
mbr_label = new Label("1 mbr(s)");
mbr_label.setFont(default_font);
p.add("South", leave_button);
p.add("South", mbr_label);
add("South", p);
代码示例来源:origin: wildfly/wildfly
public void go() {
try {
panel=new Panel();
sub_panel=new Panel();
resize(200, 200);
add("Center", panel);
clear_button=new Button("Clear");
clear_button.setFont(default_font);
clear_button.addActionListener(this);
leave_button=new Button("Exit");
leave_button.setFont(default_font);
leave_button.addActionListener(this);
mbr_label=new Label("0 mbr(s)");
mbr_label.setFont(default_font);
sub_panel.add("South", clear_button);
sub_panel.add("South", leave_button);
sub_panel.add("South", mbr_label);
panel.addMouseMotionListener(this);
setVisible(true);
mbr_label.setText(member_size + " mbrs");
graphics=panel.getGraphics();
selectColor();
代码示例来源:origin: wildfly/wildfly
setFont(default_font);
stock.setBounds(new Rectangle(10, 30, 60, 30));
value.setBounds(new Rectangle(10, 60, 60, 30));
stock_field.setBounds(new Rectangle(100, 30, 100, 30));
value_field.setBounds(new Rectangle(100, 60, 100, 30));
listbox.setBounds(210, 30, 150, 160);
err_msg.setBounds(new Rectangle(10, 200, 350, 30));
err_msg.setFont(new Font("Helvetica", Font.ITALIC, 12));
err_msg.setForeground(Color.red);
err_msg.setVisible(false);
get.setBounds(new Rectangle(10, 250, 80, 30));
set.setBounds(new Rectangle(100, 250, 80, 30));
quit.setBounds(new Rectangle(190, 250, 80, 30));
get_all.setBounds(new Rectangle(280, 250, 80, 30));
代码示例来源:origin: wildfly/wildfly
private void showMsg(String msg) {
err_msg.setText(msg);
err_msg.setVisible(true);
}
代码示例来源:origin: log4j/log4j
protected void wrapStringOnPanel(String message,
Container container) {
GridBagConstraints c = getDefaultConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
// Insets() args are top, left, bottom, right
c.insets = new Insets(0, 0, 0, 0);
GridBagLayout gbLayout = (GridBagLayout) container.getLayout();
while (message.length() > 0) {
int newLineIndex = message.indexOf('\n');
String line;
if (newLineIndex >= 0) {
line = message.substring(0, newLineIndex);
message = message.substring(newLineIndex + 1);
} else {
line = message;
message = "";
}
Label label = new Label(line);
label.setFont(DISPLAY_FONT);
gbLayout.setConstraints(label, c);
container.add(label);
}
}
代码示例来源:origin: org.w3c.jigsaw/jigsaw
public StepIntegerAttributeEditor() {
StepListener sl = new StepListener();
widget = new Panel(new BorderLayout());
l = new Label();
l.setAlignment(Label.CENTER);
widget.add("Center", l);
p = new Button("+");
p.addActionListener(sl);
widget.add("East", p);
m = new Button("-");
m.addActionListener(sl);
widget.add("West", m);
}
代码示例来源:origin: org.w3c.jigsaw/jigsaw
protected void initAddPanel(Properties config) {
if(addPanel == null) {
Panel tfp;
addPanel = new Panel(new BorderLayout());
String af = config.getProperty(
"org.w3c.jigadm.editors.resource.indexers");
StringTokenizer st = new StringTokenizer(af, "|");
ScrollPane fsp = new ScrollPane();
GridBagLayout fgbl = new GridBagLayout();
GridBagConstraints fgbc = new GridBagConstraints();
Panel fspp = new Panel (fgbl);
fsp.add(fspp);
while(st.hasMoreTokens())
combo.add(st.nextToken().trim());
fspp.add(combo);
addPanel.add("Center", fsp);
Button newb = new Button("Add Indexer");
newb.addActionListener(new AddIndexerListener());
addPanel.add("South", newb);
tfp = new Panel(new GridLayout(1, 2));
tf = new TextField();
tfp.add(new Label("identifier"));
tfp.add(tf);
addPanel.add("North", tfp);
代码示例来源:origin: stackoverflow.com
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
f.setLayout(new GridBagLayout());
Panel p = new Panel();
p.add(new Label("Test", Label.RIGHT));
p.add(new TextField("Test", 10));
f.add(p);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
代码示例来源:origin: org.jvnet.hudson/netx
new ImageIcon(getClass().getClassLoader().getResource("netx/jnlp/resources/install.png"));
setLayout(new BorderLayout());
setBackground(Color.white);
installField.setText((new File(home)).toString());
ok.addActionListener(this);
cancel.addActionListener(this);
browse.addActionListener(this);
Font f = new Font("SansSerif", Font.BOLD, 14);
Panel top = new Panel(new GridLayout(2, 1, 0, 10));
Label l1 = new Label(R("CChooseCacheInfo"));
Label l2 = new Label(R("CChooseCacheDir")+":");
l1.setFont(f);
l2.setFont(f);
top.add(l1);
top.add(l2);
Panel field = new Panel(new BorderLayout());
field.add(top, BorderLayout.NORTH);
field.add(installField, BorderLayout.CENTER);
代码示例来源:origin: stackoverflow.com
import java.awt.*;
import javax.swing.*;
public class GridPrb {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cp = frame.getContentPane();
cp.setLayout(new GridLayout(5, 5));
for(int y = 0; y < 5; y++) {
for(int x = 0; x < 5; x++) {
Label l = new Label("x=" + x + ",y=" + y);
cp.add(l);
}
}
frame.pack();
frame.setVisible(true);
}
}
代码示例来源:origin: org.jacorb/jacorb
/**
* Return the Label21 property value.
* @return java.awt.Label
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private java.awt.Label getMaxLabel() {
if (ivjMaxLabel == null) {
try {
ivjMaxLabel = new java.awt.Label();
ivjMaxLabel.setName("MaxLabel");
ivjMaxLabel.setText("");
ivjMaxLabel.setBackground(java.awt.SystemColor.control);
ivjMaxLabel.setFont(new java.awt.Font("dialog", 0, 10));
ivjMaxLabel.setBounds(23, 7, 25, 10);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
};
return ivjMaxLabel;
}
/**
代码示例来源:origin: sc.fiji/VIB-lib
public void setup() {
Panel buttons = new Panel();
buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
list = new Button("List");
list.addActionListener(this);
buttons.add(list);
copy = new Button("Copy");
copy.addActionListener(this);
buttons.add(copy);
log = new Button("Log");
log.addActionListener(this);
buttons.add(log);
Panel valueAndCount = new Panel();
valueAndCount.setLayout(new GridLayout(2, 1));
value = new Label(" "); //21
value.setFont(new Font("Monospaced", Font.PLAIN, 12));
valueAndCount.add(value);
count = new Label(" ");
count.setFont(new Font("Monospaced", Font.PLAIN, 12));
valueAndCount.add(count);
buttons.add(valueAndCount);
add(buttons);
pack();
}
代码示例来源:origin: org.w3c.jigsaw/jigsaw
protected void initAddPanel() {
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
AddUserListener aul = new AddUserListener();
Panel p = new Panel(gbl);
Label l;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 0;
gbc.weighty = 0;
tf = new TextField(15);
tf.addActionListener(aul);
l = new Label("User name", Label.RIGHT);
gbc.gridwidth = 1;
gbl.setConstraints(l, gbc);
p.add(l);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(tf, gbc);
p.add(tf);
widget.add("Center", p);
Button newb = new Button("Add User");
newb.addActionListener(aul);
widget.add("South", newb);
}
代码示例来源:origin: stackoverflow.com
Label label;
public Demo() {
setLayout(new FlowLayout());
btn = new Button("OK");
label= new Label("Number of rightclicks: "+counter);
btn.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent e) {
if (e.getModifiers() == MouseEvent.BUTTON3_MASK) {
counter++;
label.setText("Number of rightclicks: " +counter.toString());} }
});
add(btn);
add(label);
setSize(300,300);
setVisible(true);
代码示例来源:origin: com.stevesoft.pat/pat
void message(String[] lines) {
final Dialog d = new Dialog(this,"Message",true);
d.setLayout(new GridLayout(lines.length+1,1));
for(int i=0;i<lines.length;i++)
d.add(new Label(lines[i],Label.LEFT));
Button b = new Button("OK");
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
d.dispose();
}
});
d.add(b);
d.pack();
d.show();
}
代码示例来源:origin: org.apfloat/apfloat-samples
/**
* Initialize the "threads" section GUI elements.
* Elements should be added for the remainder of the width of the <code>container</code>.
*
* @param container The container where the elements are to be added.
* @param constraints The constraints with which the elements are to be added to the <code>container</code>.
*/
protected void initThreads(Container container, GridBagConstraints constraints)
{
constraints.gridwidth = GridBagConstraints.REMAINDER;
container.add(new Label(), constraints);
}
代码示例来源:origin: stackoverflow.com
pnlFromRadioButton.add(new Label("From Panel"));
pnlToRadioButton.add(new Label("To Panel"));
pnlButton.add(new Label("Buttons Panel"));
add(pnlButton, BorderLayout.SOUTH);
setVisible(true);
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
代码示例来源:origin: IanDarwin/javasrc
BordLayPanel() {
super("BordLayPanel");
Panel p;
setLayout(new BorderLayout());
add(BorderLayout.NORTH, p = new Panel());
p.setLayout(new FlowLayout());
p.add(new Label("FileName:"));
p.add(fileName = new TextField(40));
p.add(new Button("Load"));
// now you need to add an action listener to the button
add(BorderLayout.CENTER, main = new TextArea(24,80));
add(BorderLayout.SOUTH, status = new Label(""));
pack();
// Don't forget to add a window listener so the quit control works
}
代码示例来源:origin: com.h2database/h2
frame.setBackground(SystemColor.control);
GridBagLayout layout = new GridBagLayout();
frame.setLayout(layout);
Panel mainPanel = new Panel(layout);
constraintsLabel.gridy = 0;
Label label = new Label("H2 Console URL:", Label.LEFT);
label.setFont(font);
mainPanel.add(label, constraintsLabel);
urlText = new TextField();
urlText.setEditable(false);
urlText.setFont(font);
urlText.setText(web.getURL());
if (isWindows) {
urlText.setFocusable(false);
mainPanel.add(urlText, constraintsTextField);
startBrowser = new Button("Start Browser");
startBrowser.setFocusable(false);
startBrowser.setActionCommand("console");
startBrowser.addActionListener(this);
startBrowser.setFont(font);
代码示例来源:origin: mikera/tyrant
private Panel createSourceStatus() {
sourceStatusBar = new Panel(new BorderLayout());
sourceStatusLabel = new Label("Bob", Label.CENTER);
sourceStatusBar.add(sourceStatusLabel, BorderLayout.CENTER);
sourceStatusBar.setVisible(false);
return sourceStatusBar;
}
内容来源于网络,如有侵权,请联系作者删除!