大虾们帮我看看这个JPanel为什么显示出来
郁闷呀..运行程序以后Panel显示不出来,大家给我说说怎么改呀....
package com.swtdesigner;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class TestArea {
private JFrame frame;
public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEIGHT = 300;
private JTextArea textArea;
private JScrollPane scrollPane;
private JPanel buttonPanel;
private JButton wrapButton;
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
try {
TestArea window = new TestArea();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the application
*/
public TestArea() {
initialize();
}
/**
* Initialize the contents of the frame
*/
private void initialize() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setTitle( "TextAreaTest ");
frame.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
buttonPanel = new JPanel();
// buttonPanel.setBounds(200,200, 200, 200);
// add button to append text into the text area
JButton insertButton = new JButton( "Insert ");
buttonPanel.add(insertButton);
insertButton.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
textArea.append( "The quick brown fox jumps over the lazy dog. ");
}
});