Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in th
- @Override
- public int getRowCount() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- @Override
- public int getColumnCount() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- @Override
- public String getColumnName(int i) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- @Override
- public Class<?> getColumnClass(int i) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- @Override
- public boolean isCellEditable(int i, int i1) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- @Override
- public Object getValueAt(int i, int i1) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- @Override
- public void setValueAt(Object o, int i, int i1) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- @Override
- public void addTableModelListener(TableModelListener tl) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- @Override
- public void removeTableModelListener(TableModelListener tl) {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- } editor.
- */
- package guitest;
- import java.awt.BorderLayout;
- import java.sql.SQLException;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JScrollPane;
- import javax.swing.JTable;
- import javax.swing.event.TableModelEvent;
- import javax.swing.event.TableModelListener;
- import javax.swing.table.AbstractTableModel;
- import javax.swing.table.DefaultTableModel;
- /**
- *
- * @author Malmo
- */
- public class SauGUI extends javax.swing.JFrame {
- /**
- * Creates new form SauGUI
- */
- private SauDatabase db = new SauDatabase();
- private DefaultTableModel tableTest = new DefaultTableModel(db.tablePrintOfDatabase(), db.getTableColumnNames());
- public SauGUI() throws SQLException {
- initComponents();
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- inputSQL = new javax.swing.JTextField();
- btnUpdateSQL = new javax.swing.JButton();
- outputInput = new javax.swing.JLabel();
- btnTest = new javax.swing.JButton();
- jScrollPane2 = new javax.swing.JScrollPane();
- tableViewer = new javax.swing.JTable();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setTitle("frame");
- setBackground(new java.awt.Color(51, 102, 255));
- inputSQL.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- inputSQLActionPerformed(evt);
- }
- });
- btnUpdateSQL.setText("Send query");
- btnUpdateSQL.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnUpdateSQLActionPerformed(evt);
- }
- });
- outputInput.setText("jLabel1");
- btnTest.setText("jButton1");
- btnTest.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnTestActionPerformed(evt);
- }
- });
- tableViewer.setModel(tableTest
- );
- jScrollPane2.setViewportView(tableViewer);
- org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(38, 38, 38)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
- .add(inputSQL)
- .add(btnUpdateSQL))
- .add(layout.createSequentialGroup()
- .add(27, 27, 27)
- .add(outputInput))
- .add(btnTest))
- .add(33, 33, 33)
- .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(81, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(36, 36, 36)
- .add(inputSQL, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(btnUpdateSQL)
- .add(18, 18, 18)
- .add(outputInput)
- .add(36, 36, 36)
- .add(btnTest))
- .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(110, Short.MAX_VALUE))
- );
- layout.linkSize(new java.awt.Component[] {btnUpdateSQL, inputSQL}, org.jdesktop.layout.GroupLayout.VERTICAL);
- pack();
- }// </editor-fold>
- private void btnUpdateSQLActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- // TODO add your handling code here:
- db.executeQuery(inputSQL.getText());
- outputInput.setText(Integer.toString(db.getRows()));
- // tableViewer.setModel(new javax.swing.table.DefaultTableModel(db.tablePrintOfDatabase(),db.getTableColumnNames()));
- // db.table();
- } catch (SQLException ex) {
- Logger.getLogger(SauGUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- private void inputSQLActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- }
- //TEST KNAPP
- private void btnTestActionPerformed(java.awt.event.ActionEvent evt) {
- /*
- try {
- // TODO add your handling code here:
- // db.table();
- // db.getTableColumnNames();
- } catch (SQLException ex) {
- Logger.getLogger(SauGUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- */
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(SauGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(SauGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(SauGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(SauGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- new SauGUI().setVisible(true);
- } catch (SQLException ex) {
- Logger.getLogger(SauGUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton btnTest;
- private javax.swing.JButton btnUpdateSQL;
- private javax.swing.JTextField inputSQL;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JLabel outputInput;
- private javax.swing.JTable tableViewer;
- // End of variables declaration
- private javax.swing.table.DefaultTableModel dfTableModel;
- }
Advertisement
Add Comment
Please, Sign In to add comment