package JDBC;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class SearchPanel extends JPanel{
public SearchPanel(String keyWord) throws SQLException {
super(new GridLayout(1,0));
JTable table = new JTable(new RegionsTableModel(keyWord));
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this panel.
add(scrollPane);
}
public static void main(String args[]) throws SQLException{
JDialog dialog= new JDialog( new JFrame(),true );
dialog.addWindowListener( new WindowAdapter(){
@Override
public void windowClosing( WindowEvent e ){
System.exit( 0 );
}
});
SearchPanel searchPanel = new SearchPanel("Asia");
dialog.add(searchPanel);
dialog.setSize( 450, 250 );
dialog.setVisible(true);
}
}
Tidak ada komentar:
Posting Komentar