Hi all

The below code is failed.
The problem is happened on the table value failed to be passed by actionPerformed.

If anyone can check for me??


import java.awt.BorderLayout;
import java.awt.Container;
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.JTable;
import javax.swing.table.DefaultTableModel;

public class Test implements ActionListener {
JTable output;
DefaultTableModel model;
JScrollPane scrollPane;
JButton showButton;

String[] columnNames = {"NAME", "AGE"};
Object[][] data = {{"Nancy","8"},{"PAUL","10"}, {"Jack","5"}};

public Container createContentPane() {

//Create Button
showButton = new JButton("Show All Information");
showButton.setActionCommand("Show All Information");

//Create funcPane
JPanel funcPane = new JPanel();
funcPane.add(showButton, BorderLayout.PAGE_END);

//Create the content-pane-to-be.
JPanel contentPane = new JPanel(new BorderLayout());

//Create a scrolled table.
model = new DefaultTableModel();
output = new JTable(model);
scrollPane = new JScrollPane(output);

//Add the text area to the content pane.
contentPane.add(funcPane, BorderLayout.CENTER);
contentPane.add(scrollPane, BorderLayout.PAGE_END);

return contentPane;

private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("Data Dictionary Maintainance");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);

//Create and set up the content pane.
Test t = new Test();

//Display the window.
frame.setSize(1200, 750);

public void actionPerformed(ActionEvent e) {

String source = e.getActionCommand();

if(source == "Show All Information"){
model = new DefaultTableModel(data, columnNames);
}//End of "Show All Information"


public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {