N
nick
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SimpleFrame
extends JFrame {
Image im;
public SimpleFrame() {
super("test");
final JButton button = new JButton("fdsfdffs ");
Container container = getContentPane();
container.setLayout(null);
button.setBounds(50, 100, 100, 100);
container.add(button);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button.setBounds(10, 10, 10, 10);
}
}
);
setSize(500, 500);
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
im = Toolkit.getDefaultToolkit().getImage("scdog3.gif");
int width = 0;
int height = 0;
while (width > 0 && height > 0) {
width = im.getWidth(this);
height = im.getHeight(this);
}
this.setVisible(true);
}
public static void main(String arg[]) {
new SimpleFrame();
}
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
g.drawImage(im, 50, 50, this);
}
}
thanks!
import java.awt.event.*;
import javax.swing.*;
public class SimpleFrame
extends JFrame {
Image im;
public SimpleFrame() {
super("test");
final JButton button = new JButton("fdsfdffs ");
Container container = getContentPane();
container.setLayout(null);
button.setBounds(50, 100, 100, 100);
container.add(button);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button.setBounds(10, 10, 10, 10);
}
}
);
setSize(500, 500);
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
im = Toolkit.getDefaultToolkit().getImage("scdog3.gif");
int width = 0;
int height = 0;
while (width > 0 && height > 0) {
width = im.getWidth(this);
height = im.getHeight(this);
}
this.setVisible(true);
}
public static void main(String arg[]) {
new SimpleFrame();
}
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
g.drawImage(im, 50, 50, this);
}
}
thanks!