Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NewJFrame extends javax.swing.JFrame {
- public NewJFrame() {
- initComponents();
- setTitle("Found Items");
- try {
- String myDriver = "com.mysql.cj.jdbc.Driver";
- String myUrl = "jdbc:mysql://localhost:3306/lostfound";
- Class.forName(myDriver);
- Connection c = DriverManager.getConnection(myUrl, "root", "");
- String sql = "SELECT * FROM found";
- Statement st = c.createStatement();
- // execute the query, and get a java resultset
- ResultSet rs =st.executeQuery(sql);
- int row =0;
- while(rs.next())
- {
- private static final int BOOLEAN_COLUMN = 4;
- String name = rs.getString("name");
- String description = rs.getString("description");
- String location = rs.getString("location");
- meza.getModel().setValueAt(name, row, 0);
- meza.getModel().setValueAt(description, row, 1);
- meza.getModel().setValueAt(location, row, 2);
- row++;
- }
- }
- catch (SQLException e)
- {
- System.out.println( e.getMessage() );
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
- }
- meza.show();
- claim.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- for(int i =0; i<meza.getRowCount(); i++)
- {
- Boolean checked = Boolean.valueOf(meza.getValueAt(i,3).toString());
- String col = meza.getValueAt(i, 1).toString();
- //DISPLAY POP UP
- if(checked)
- {
- JOptionPane.showMessageDialog(null,col);
- }
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement