public SendDialog(Frame parent, Node dest, String src, RpcDispatcher disp) { super(parent, "Send message to " + dest.lbl + " at " + dest.addr, true); Panel p1=new Panel(), p2=new Panel(); Button send=new Button("Send"), send_all=new Button("Send to all"); Button cancel=new Button("Cancel"); this.disp=disp; this.dest=dest; sender=src; send.setFont(default_font); send_all.setFont(default_font); cancel.setFont(default_font); msg.setFont(default_font); p1.setLayout(new BorderLayout()); p1.add(msg); p2.setLayout(new FlowLayout()); send.addActionListener(this); send_all.addActionListener(this); cancel.addActionListener(this); p2.add(send); p2.add(send_all); p2.add(cancel); add("Center", p1); add("South", p2); setSize(300, 150); Point my_loc=parent.getLocation(); my_loc.x+=50; my_loc.y+=150; setLocation(my_loc); setVisible(true); }
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(); graphics.setColor(default_color); panel.setBackground(Color.white); clear_button.setForeground(Color.blue); leave_button.setForeground(Color.blue);
public UserInfoDialog(Frame parent) { super(parent, "Input", true); setLayout(null); l.setFont(default_font); l.setSize(50, 30); l.setLocation(30, 50); name.setFont(default_font); name.setSize(150, 30); name.setLocation(90, 50); //name.selectAll(); ok.setFont(default_font); ok.setSize(50, 30); ok.setLocation(30, 90); add(l); add(name); add(ok); ok.addActionListener(this); setSize(300, 150); Point my_loc=parent.getLocation(); my_loc.x+=50; my_loc.y+=150; setLocation(my_loc); show(); }
import java.awt.*; import java.applet.Applet; public class buttonDir extends Applet { public void init() { setLayout(new BorderLayout()); add(new Button("North"), BorderLayout.NORTH); add(new Button("South"), BorderLayout.SOUTH); add(new Button("East"), BorderLayout.EAST); add(new Button("West"), BorderLayout.WEST); add(new Button("Center"), BorderLayout.CENTER); } }
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); }
mainFrame.setSize(400,400); mainFrame.setLayout(new GridLayout(3, 1)); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent){ System.exit(0); headerLabel = new Label(); headerLabel.setAlignment(Label.CENTER); statusLabel = new Label(); statusLabel.setAlignment(Label.CENTER); statusLabel.setSize(350,100); controlPanel = new Panel(); controlPanel.setLayout(new FlowLayout()); mainFrame.add(headerLabel); mainFrame.add(controlPanel); mainFrame.add(statusLabel); mainFrame.setVisible(true); Label namelabel= new Label("User ID: ", Label.CENTER); final TextField userText = new TextField(16); userText.setText("name"); Button displayButton = new Button("Display"); displayButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String data = "Username: " + userText.getText();
import java.awt.*; import java.awt.event.*; import java.applet.*; public class ButtonDemo extends Applet implements ActionListener { public void init() { setLayout(null) Button yes= new Button("Yes"); yes.setBounds(0,30,30,60); add(yes); yes.addActionListener(this); } public void actionPerformed (ActionEvent ae) { } }
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(); }
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);
start.addActionListener(e -> startSender()); stop.addActionListener(e -> { try { TotOrderRequest req=new TotOrderRequest(TotOrderRequest.STOP, 0, 0, 0); clear.addActionListener(e -> canvas.clear()); get_state.addActionListener(e -> { try { channel.getState(null, 3000); quit.addActionListener(e -> { channel.close(); System.exit(0); setMenuBar(menubar); setLayout(new BorderLayout()); canvas=new MyCanvas(num_fields, field_size, x_offset, y_offset); button_panel.setLayout(new FlowLayout()); button_panel.setFont(def_font2); button_panel.add(start); button_panel.add(stop); button_panel.add(clear);
button = new Button("Close"); button.addActionListener(new ActionListener() setLayout(new FlowLayout()); add(button); setBounds(0,0,screenSize.width, screenSize.height); new fullscreen().setVisible(true);
setLayout(new BorderLayout(0,0)); final Label label = new Label(" "+message); label.setFont(font); Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.CENTER,10,10)); panel.add(label); add("North",panel); final Button button = new Button(" OK "); button.setFont(font); button.addActionListener(this); button.addKeyListener(this); panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.CENTER,0,0)); panel.add(button); add("Center",panel); panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.CENTER,0,5)); add("South",panel);
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 }
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); installField.setFont(f); ok.setFont(f); cancel.setFont(f); browse.setFont(f); Panel field = new Panel(new BorderLayout()); field.add(top, BorderLayout.NORTH); field.add(installField, BorderLayout.CENTER); grid.add(cancel); Panel choice = new Panel(new FlowLayout(FlowLayout.CENTER, 4, 0)); choice.add(grid);
FComponent(SelectFileEditor editor) { this.editor = editor; this.text = new TextField(); this.select = new Button("Select"); select.setActionCommand("select"); select.addActionListener(this); setLayout( new BorderLayout()); add(text,"Center"); add(select,"East"); } }
if(!modified) return true; final Dialog d = new Dialog(this,true); d.setLayout(new GridLayout(4,1)); d.setTitle("Abandon"); d.add(new Label("You have unsaved")); d.add(new Label("changes, do you really")); d.add(new Label("want to abandon them?")); Panel p = new Panel(); d.add(p); p.setLayout(new GridLayout(1,2)); final boolean[] b = new boolean[1]; b[0] = false; Button yes = new Button("Yes"),no = new Button("No"); yes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { b[0] = true; no.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { b[0] = false;
import java.awt.*; import java.awt.event.*; class AEvent extends Frame implements ActionListener{ TextField tf; AEvent(){ tf=new TextField(); tf.setBounds(60,50,170,20); Button b=new Button("click me"); b.setBounds(100,120,80,30); b.addActionListener(this); add(b);add(tf); setSize(300,300); setLayout(null); setVisible(true); } public void actionPerformed(ActionEvent e){ tf.setText("Welcome"); } public static void main(String args[]){ new AEvent(); } }
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);
frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Panel p = new Panel(); p.setLayout(new GridLayout()); Button button = new Button("Change"); final JLabel label = new JLabel(Long.toString(Long.MAX_VALUE)); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { p.add(button); p.add(label); frame.add(p, BorderLayout.NORTH); frame.pack();
import java.awt.*; import java.applet.Applet; class Example extends Applet implements ActionListener { TextField txt = new TextField(10); Button goButton = new Button("Go"); String data = new String (); public void init () { add(txt); add(goButton); goButton.addActionListener(this); } public void actionPerformed (ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("Go")) { // preserve data data = txt.getText(); repaint(); } } }