随风之幻
发贴: 3
积分: 0
|
于 2006-05-25 18:18
import java.awt.*; import javax.swing.*;
public class TestPanels extends JFrame { //Default constructor public TestPanels() { Container container=getContentPane();
// container.setLayout(new BorderLayout());
JPanel p1=new JPanel(); p1.setLayout(new GridLayout(4,3));
for(int i=1;i<=9;i++) { p1.add(new JButton(" "+i)); }
p1.add(new JButton(" "+0)); p1.add(new JButton("Start")); p1.add(new JButton("Stop"));
JPanel p2=new JPanel(); p2.setLayout(new BorderLayout()); p2.add(new JTextField("Time to be displayed here"),BorderLayout.NORTH); p2.add(p1,BorderLayout.CENTER); }
public static void main(String[] args) { TestPanels frame=new TestPanels(); frame.setTitle("The Front view of a Microwave OVen"); frame.setSize(400,250); frame.setVisible(true); } } this is a program in a book.but the result is not what I look forward to. why I can't see nothing except a blank frame? please tell me what's wrong with this program. thank you~
|