您好我想在按钮“购买”
之前将我的文件数据显示在此面板中这是我的代码:
package program;
import java.awt.Container;
import java.awt.FlowLayout;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Button1 extends JApplet {
private static final String EXT_FILE = "Dogss.txt";//"../ApplicationESB/src/applicationesb/pricelist.txt";
private JButton b1 = new JButton("Buy it");
public void init() {
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(b1);
}
public static void main(String[] args) {
run(new Button1(), 500, 600);
}
public static void run(JApplet applet, int width, int height) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(applet);
frame.setSize(width, height);
applet.init();
applet.start();
frame.setVisible(true);
}
}
答案 0 :(得分:1)