J
Jenny
Hi,
I found an old post under this title. The code had some error so I
change it a little. But when I run it, it has an empty window and I
cannot close it. How can I display the 2 buttons with the scroll
bars?
Why is the exit control button not working?
Thanks a lot.
Here is my code:
import java.awt.*;
import javax.swing.*;
class Scroll {
public static void main(String[] args){
Frame f = new Frame ("Demo");
JScrollPane s = new JScrollPane();
Panel p = new Panel();
Button b1 = new Button("Button 1");
Button b2 = new Button("Button 2");
f.add("Center", s);
s.add(p);
p.add(b1);
p.add(b2);
f.setSize(200,200);
f.setVisible(true);
}}
I found an old post under this title. The code had some error so I
change it a little. But when I run it, it has an empty window and I
cannot close it. How can I display the 2 buttons with the scroll
bars?
Why is the exit control button not working?
Thanks a lot.
Here is my code:
import java.awt.*;
import javax.swing.*;
class Scroll {
public static void main(String[] args){
Frame f = new Frame ("Demo");
JScrollPane s = new JScrollPane();
Panel p = new Panel();
Button b1 = new Button("Button 1");
Button b2 = new Button("Button 2");
f.add("Center", s);
s.add(p);
p.add(b1);
p.add(b2);
f.setSize(200,200);
f.setVisible(true);
}}