i hav read other posts regarding the same prob as tht of mine, but i really didnt understand whts wrong in my code. pls help me.. thnk u.. :(sweat):
Code:import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
import java.sql.*;
class mainframe extends db
{
JFrame mframe=new JFrame("Current Inventory");
int row_cnt=0;
Object data[][];
void create_mframe() throws Exception
{
JDialog p=new JDialog();
p.setUndecorated(true);
p.setResizable(false);
p.setSize(200,100);
p.setLocationRelativeTo(null);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
p.add(dbl1);
p.setVisible(true);
con=DriverManager.getConnection("jdbc:odbc:Mangesh");
p.setVisible(false);
p.add(dbl2);
p.setVisible(true);
st=con.createStatement();
p.setVisible(false);
p.add(dbl3);
p.setVisible(true);
p.dispose();
mframe.setSize(pasframe.xSize/2,pasframe.ySize/2);
mframe.setLocationRelativeTo(null);
mframe.setExtendedState(JFrame.MAXIMIZED_BOTH);
Image img=pasframe.tk.getImage("SamratPlast_logo.jpg");
mframe.setIconImage(img);
JMenuBar mbar=new JMenuBar();
JMenu menu=new JMenu("Menu");
JMenu option=new JMenu("Option");
JMenu help=new JMenu("Help");
JMenu arrange=new JMenu(" Arrange");
JMenuItem item1=new JMenuItem(" Add new..",new ImageIcon("add.png"));
item1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
new mydialog2("Add Item",mframe);
}
});
JMenuItem item2=new JMenuItem(" Delete",new ImageIcon("delete.png"));
JMenuItem item3=new JMenuItem(" Exit",new ImageIcon("exit.png"));
item3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.exit(0);
}
});
item3.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent ke)
{
int key=ke.getKeyCode();
if(key==KeyEvent.VK_ENTER)
System.exit(0);
}
});
JMenuItem item5=new JMenuItem(" Search..",new ImageIcon("zoom.png"));
JMenuItem item6=new JMenuItem(" About..",new ImageIcon("about.png"));
item6.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
JLabel ta=new JLabel();
ta.setText("<html><b><font size='7' face='Goudy Old Style'><strong> Inventory Management System</strong></font></b><br> Version 1.0<br> � Mangesh Ghotage , Disha Takalkar<br><br><hr><br> This product is made only for <u>academic purposes</u>.</html>");
JDialog dialog=new JDialog(mframe,"Information",true);
dialog.add(new JScrollPane(ta));
dialog.setSize(500,180);
//dialog.setLayout(null);
dialog.setLocationRelativeTo(null);
dialog.setResizable(false);
dialog.setVisible(true);
}
});
item6.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent ke)
{
int key=ke.getKeyCode();
if(key==KeyEvent.VK_ENTER)
{
JLabel ta=new JLabel();
ta.setText("<html><b><font size='7' face='Goudy Old Style'><strong> Inventory Management System</strong></font></b><br> Version 1.0<br> � Mangesh Ghotage , Disha Takalkar<br><br><hr><br> This product is made only for <u>academic purposes</u>.</html>");
JDialog dialog=new JDialog(mframe,"Information",true);
dialog.add(new JScrollPane(ta));
dialog.setSize(500,180);
//dialog.setLayout(null);
dialog.setLocationRelativeTo(null);
dialog.setResizable(false);
dialog.setVisible(true);
}
}
});
JMenuItem item7=new JMenuItem(" Reports",new ImageIcon("report.png"));
JMenuItem item8=new JMenuItem(" Clear selection..",new ImageIcon("clear.png"));
JMenuItem item9=new JMenuItem(" Change password",new ImageIcon("change.png"));
item9.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
new change_password();
}
});
item3.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent ke)
{
int key=ke.getKeyCode();
if(key==KeyEvent.VK_ENTER)
new change_password();
}
});
ButtonGroup grp=new ButtonGroup();
JRadioButtonMenuItem aitem1=new JRadioButtonMenuItem(" By Name",new ImageIcon("name.png"));
JRadioButtonMenuItem aitem2=new JRadioButtonMenuItem(" By Date",new ImageIcon("date.png"));
aitem2.setSelected(true);
grp.add(aitem1);
grp.add(aitem2);
arrange.add(aitem1);
arrange.add(aitem2);
menu.add(item1);
menu.add(item2);
menu.add(item8);
menu.add(item3);
option.add(item5);
option.add(arrange);
option.add(item9);
help.add(item6);
help.add(item7);
mbar.add(menu);
mbar.add(option);
mbar.add(help);
mframe.setJMenuBar(mbar);
mframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String title[]={/*"checkbox",*/"Item ID",/*"Update status",*/"Name","Price","Stock"};
rs=st.executeQuery("select * from item");
while(rs.next()){row_cnt++;}
System.out.println(row_cnt);
System.out.println(con);
System.out.println(st);
System.out.println(rs);
while(rs.next())
{
for(int i=0;i<row_cnt;i++)
{
data[i][0]=rs.getInt(1);
data[i][1]=rs.getString(2);
data[i][2]=rs.getInt(3);
data[i][3]=rs.getInt(4);
}
}
//DefaultTableModel model=new DefaultTableModel(temp,title);
JTable table=new JTable(data,title);
table.setShowVerticalLines(false);
JScrollPane scrollpane=new JScrollPane(table);
//table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setRowHeight(20);
table.getTableHeader().setFont(new Font("",Font.BOLD,15));
mframe.add(scrollpane);
mframe.setVisible(true);
System.out.println("sdas");
}
}
{
static Statement st;
static Connection con;
static ResultSet rs;
static ResultSetMetaData rsmd;
JLabel dbl1=new JLabel("driver loaded.");
JLabel dbl2=new JLabel("connection created.");
JLabel dbl3=new JLabel("statement created.");
}
class execute
{
public static void main(String a[])throws Exception
{
new mainframe().create_mframe();
}
}
