JSP and Swing
HI,
In JSP if i want to import a class file(java application) the i use
<%@ page language="java" import="DrawTable" %>
<jsp:useBean id="select" class="DrawTable" scope="request" />
</jsp:useBean>
<% select.displayTable();%> where displayTable will be my method of class DrawTable.
Now if i have a class which extends JFrame wherein i am displaying a table then how do i call the class in my jsp and how will the frame be displayed on the browser.
The below code works fine from the DOS prompt ,the same code how do i modify and call in my jsp.
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JComboBox;
import javax.swing.DefaultCellEditor;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.table.TableColumn;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.*;
public class DrawTable extends JFrame
{
private boolean DEBUG = true;
public DrawTable()
{
super("NBOL");
Object[][] data =
{
{"01500234", "AED",
"Current", new Integer(5),"1000"},
{"0150222", "AED",
"Savings", new Integer(3),"1234.55"},
{"0155768", "AED",
"Loan", new Integer(2), "123"},
{"01729987", "USD",
"Current", new Integer(20), "456"},
{"01506746", "AED",
"Call", new Integer(4), "2454"}
};
String[] columnNames = {"Credit Acct",
"Currency",
"Title",
"Currency",
"Transfer Amt"};
final JTable table = new JTable(data, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(640, 460));
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
TableColumn sportColumn = table.getColumnModel().getColumn(2);
JComboBox comboBox = new JComboBox(columnNames);
comboBox.setVisible(true);
comboBox.setEditable(true);
comboBox.show(true);
sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Add the scroll pane to this window.
setContentPane(scrollPane);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
} //end of constructor
public static void main(String[] args)
{
DrawTable frame = new DrawTable();
frame.pack();
frame.setVisible(true);
}
}//end of class DrawTable
PLease help.

