import java.awt.Color;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
public class TablesDesign {
static String p,q;
static Boolean caught;
static String sb3;
static StringBuffer SB3=null;
static void Frame()
{
final JFrame Frame = new JFrame("SP- Inputs & Outputs");
Frame.setBounds(300, 200, 500, 270);
Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JPanel LPanel = new JPanel();
final JPanel RPanel = new JPanel();
LPanel.setLayout(null);
RPanel.setLayout(null);
LPanel.setBackground(Color.black);
LPanel.setBounds(0, 0, 290, 200);
RPanel.setBounds(300, 0, 180, 200);
RPanel.setBackground(Color.red);
final JPanel LPanel1 = new JPanel();
final JPanel RPanel1 = new JPanel();
LPanel1.setLayout(null);
RPanel1.setLayout(null);
LPanel1.setBackground(Color.black);
LPanel1.setBounds(0, 0, 290, 200);
RPanel1.setBounds(300, 0, 180, 200);
RPanel1.setBackground(Color.red);
String columnNames[] = { "INPUT DATA TYPE", "VALUE"};
String columnNames2[] = {"OUTPUT RETURN TYPE"};
Object[][] data = new Object[2][2];
Object[][] data2 = new Object[4][2];
DefaultTableModel tableModel = new DefaultTableModel(data,columnNames);
final JTable table = new JTable(data,columnNames);
final JTable table1 = new JTable(data2,columnNames2);
JScrollPane scroll1 = new JScrollPane(table);
scroll1.setBounds(0, 0, 290, 200);
scroll1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
LPanel.add(scroll1);
JScrollPane scroll2 = new JScrollPane(table1);
scroll2.setBounds(0, 0, 180, 200);
scroll2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
RPanel.add(scroll2);
table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(
new JComboBox(new DefaultComboBoxModel(new String[] {
"int",
"String",
"float",
"Char",
"xml",
"json"
}))));
table1.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(
new JComboBox(new DefaultComboBoxModel(new String[] {
"int",
"String",
"float",
"Char",
"Date",
"Varchar"
}))));
final JButton Button1 = new JButton("OK" );
Button1.setBounds(200, 210, 60, 25);
Frame.add(Button1);
Button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
caught = false;
StringBuilder buf = new StringBuilder();
try
{
for (int t=0;t<=1;t++)
{
table.getCellEditor(t,1).stopCellEditing();
table1.getCellEditor(t,0).stopCellEditing();
p = (String) table.getModel().getValueAt(t, 0);
q = (String) table.getModel().getValueAt(t, 1);
for (int t1=0;t1<=3;t1++)
{
table1.getCellEditor(t1,0).stopCellEditing();
p = (String) table1.getModel().getValueAt(t1, 0);
sb3="Output_"+t1+"+"+"\"\\"+"n"+"\"+";
buf.append(sb3);
System.out.println();
}
caught =true;
}
String result = buf.toString();
String Output_B="\"Output Return Values: \"+";
String Output_E="\"\\"+"\\End"+"\"";
StringBuilder Output_F=new StringBuilder();
Output_F.append(Output_B).append(result).append(Output_E);
System.out.println(Output_F);
}
catch (Exception Test)
{
JOptionPane.showMessageDialog(null,"Input type/Output type should not be empty"+Test);
caught = false;
} finally {
if(caught == false){
System.out.println("Not Done");
}
else
{
JOptionPane.showMessageDialog(null,"Done");
}
}
}
}
);
JButton Button2 = new JButton("Cancel" );
Button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ( caught == false)
{
System.out.println("Variables are not created successfully");
}
else
{
System.out.println("Variables are created Successfull....");
// Scanner sc = new Scanner(ClassLoader.class.getResourceAsStream("Drivers\\Test.jar"));
String nn= ClassLoader.class.getName();
System.out.println(nn);
}
}
});
Button2.setBounds(270, 210, 80, 25);
Frame.add(Button1);
Frame.add(Button2);
Frame.add(LPanel);
Frame.add(RPanel);
Frame.setLayout(null);
Frame.setVisible(true);
}
public static void main(String[] args) {
Frame();
}
}