?
_.-=
Hi!
I have a simple little program here using AWT for which I'm not using any
layout managers, but instead am setting the position of the components
manually.
Now, the problem is - I can't move the button away from the left edge of the
frame. I tried using setBounds: "button1.setBounds(43,170,35,20);"
Which should mean that the button should be painted at coordinates (43,170)
and extend to (43+35,170+20). On running the code, the button is still at
the left edge of the frame!!!!
import java.io.*;
import java.awt.*;
import java.awt.event.*;
class BettEdit extends Frame{
Frame window1 = new Frame("window1");
Label label1 = new Label("BettEdit");
Button button1 = new Button("Save");
TextArea text1 = new TextArea();
public static void main (String args[]) {
ParWindow win1 = new ParWindow();
}
BettEdit() {
//label1.setBounds(10,50,150,20);
button1.addActionListener(new ActionHandler1());
button1.setBounds(43,170,35,20);
text1.setBounds(3,90,250,150);
window1.addWindowListener(new WindowHandler());
window1.pack();
window1.setSize(600,400);
window1.show();
//window1.add(label1);
window1.add(button1);
window1.add(text1);
}
class WindowHandler extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
class ActionHandler1 implements ActionListener {
public void actionPerformed(ActionEvent e) {
label1.setText(text1.getText());
}
}
}
I have a simple little program here using AWT for which I'm not using any
layout managers, but instead am setting the position of the components
manually.
Now, the problem is - I can't move the button away from the left edge of the
frame. I tried using setBounds: "button1.setBounds(43,170,35,20);"
Which should mean that the button should be painted at coordinates (43,170)
and extend to (43+35,170+20). On running the code, the button is still at
the left edge of the frame!!!!
import java.io.*;
import java.awt.*;
import java.awt.event.*;
class BettEdit extends Frame{
Frame window1 = new Frame("window1");
Label label1 = new Label("BettEdit");
Button button1 = new Button("Save");
TextArea text1 = new TextArea();
public static void main (String args[]) {
ParWindow win1 = new ParWindow();
}
BettEdit() {
//label1.setBounds(10,50,150,20);
button1.addActionListener(new ActionHandler1());
button1.setBounds(43,170,35,20);
text1.setBounds(3,90,250,150);
window1.addWindowListener(new WindowHandler());
window1.pack();
window1.setSize(600,400);
window1.show();
//window1.add(label1);
window1.add(button1);
window1.add(text1);
}
class WindowHandler extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
class ActionHandler1 implements ActionListener {
public void actionPerformed(ActionEvent e) {
label1.setText(text1.getText());
}
}
}