private void populateTable() {

    DefaultTableModel tableModel = (DefaultTableModel) tblAccounts.getModel();
    tableModel.getDataVector().removeAllElements();

    if (lines.size() > 0) {
      int i = 0;
      for (; i < lines.size(); i++) {
        AccountsLine l = lines.get(i);
        tableModel.insertRow(
            i,
            new Object[] {
              l.getDate(),
              l.getDocType(),
              l.getLine_desc(),
              l.getDebit_amount(),
              l.getCredit_amount(),
              l.getLine_balance()
            });
      }
    } else {
      tableModel.insertRow(0, new Object[] {"", "", "", "", "", ""});
    }
    populateSummery(report);
  }
  private void jButtonMoveUpActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonMoveUpActionPerformed

    if (jTable1.getSelectedRow() > 0) {
      DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
      int[] indices = jTable1.getSelectedRows();
      for (int i = indices.length - 1; i >= 0; --i) {
        if (indices[i] == 0) continue;

        Object val = jTable1.getValueAt(indices[i], 0);
        dtm.removeRow(indices[i]);
        dtm.insertRow(indices[i] - 1, new Object[5]);
        setRowValues((MeterInterval) val, indices[i] - 1);
        indices[i]--;
      }

      DefaultListSelectionModel dlsm = (DefaultListSelectionModel) jTable1.getSelectionModel();
      dlsm.setValueIsAdjusting(true);
      dlsm.clearSelection();
      for (int i = 0; i < indices.length; ++i) {
        dlsm.addSelectionInterval(indices[i], indices[i]);
      }
      dlsm.setValueIsAdjusting(false);
    }
  } // GEN-LAST:event_jButtonMoveUpActionPerformed
 private void preencherTabela(Vector linhas) {
   DefaultTableModel modelo = (DefaultTableModel) this.tbCargos.getModel();
   int numLinhas = linhas.size();
   for (int i = 0; i < numLinhas; i++) {
     modelo.insertRow(modelo.getRowCount(), (Vector) linhas.get(i));
   }
 }
  /**
   * Sets the row data.
   *
   * @param list the list data to convert to row data
   */
  public void setRowData(List<TopicUserCluster> list) {
    removeAllRow();
    for (int row = 0; row < list.size(); row++) {
      TopicUserCluster topicUser = (TopicUserCluster) list.get(row);
      Vector<Object> rowData = new Vector<Object>();

      // user profile image
      ImageIcon profileImage = null;
      try {
        profileImage = new ImageIcon(new URL(topicUser.getUserProfileImage()));
        System.out.println("profile image == " + profileImage.getDescription());
      } catch (Exception ex) {
        ex.printStackTrace();
      }

      rowData.add(row + 1);
      rowData.add(topicUser.getWebsiteId());
      rowData.add(topicUser.getTopicId());
      rowData.add(topicUser.getUserId());
      rowData.add(topicUser.getUserName());
      if (profileImage == null) rowData.add("");
      else rowData.add(profileImage);
      rowData.add(topicUser.getUserUrl());
      rowData.add(topicUser.isTopicUser());
      rowData.add(topicUser.getCluster());
      rowData.add(convertScale(topicUser.getAuthority(), 2));
      rowData.add(convertScale(topicUser.getTopicScore(), 2));
      rowData.add(convertScale(topicUser.getAuthorityTopicScore(), 2));
      tableModel.insertRow(row, rowData);
    }
  }
Beispiel #5
0
 private void all() {
   try {
     for (Rooms rooms : RoomsController.roomsController.all()) {
       model.insertRow(0, rooms.toArray());
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
 private void addRow() {
   if (table.getSelectedRow() != -1) {
     // inserts row below the selected one else bottom
     int numRow = table.getRowCount();
     dtm.insertRow(numRow + 1, ",".split(","));
   } else {
     dtm.addRow(",".split(","));
   }
 }
Beispiel #7
0
 private void ponerAvion(int row, Avion av) {
   Vector<Object> filaData = new Vector<>();
   filaData.add(av);
   filaData.add(av.getModelo());
   filaData.add(av.getCapacidad());
   DefaultTableModel dtm = (DefaultTableModel) getModel();
   dtm.removeRow(row);
   dtm.insertRow(row, filaData);
 }
Beispiel #8
0
  void PacketInfoAddItem(String[] str) {
    // throw new UnsupportedOperationException("Not yet implemented");
    //  PacketInfoTable.setValueAt(string, PacketInfoTable.getRowCount()+0, 0);
    //        PacketInfoTable.setValueAt("ji", PacketInfoTable.getRowCount()+0, 1);

    DefaultTableModel dtm = (DefaultTableModel) PacketInfoTable.getModel();

    dtm.insertRow(PacketInfoTable.getRowCount(), str);
  }
  private void btnubahActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnubahActionPerformed
    try {
      Class.forName("com.mysql.jdbc.Driver");

      // MENYIAPKAN KONEKSI DAN PARAMETERNYA
      String urldb = "jdbc:mysql://localhost:3306/hotel";
      String user = "******";
      String password = "";
      Connection koneksi = DriverManager.getConnection(urldb, user, password);
      // Query SQL dan Eksekuusinya

      Statement st = koneksi.createStatement();

      String jnsKelamin;
      if (rbtnlaki.isSelected()) {
        jnsKelamin = "laki-laki";
      } else {
        jnsKelamin = "perempuan";
      }

      String strSQL =
          "update master_costumer set id_ktp='"
              + txtid.getText()
              + "',nama='"
              + txtnama.getText()
              + "', alamat='"
              + txtalamat.getText()
              + "', jenis_kelamin='"
              + jnsKelamin
              + "' where id_ktp='"
              + txtid.getText()
              + "'";
      st.executeUpdate(strSQL);

      data[0] = txtid.getText();
      data[1] = txtnama.getText();
      data[2] = txtalamat.getText();
      data[3] = jnsKelamin;
      tblModel.removeRow(row);
      tblModel.insertRow(row, data);

      txtid.setText("");
      txtnama.setText("");
      txtalamat.setText("");

      st.close();
      koneksi.close();
    } catch (ClassNotFoundException cnfe) {
      System.out.println("KESALAHAN SAAT" + "ME-LOAD DRIVER JDBC \n" + cnfe.getMessage());
    } catch (SQLException sqle) {
      System.out.println(
          "KESALAHAN SAAT KONEKSI ATAU " + "KESALAHAN QUERY SQL \n" + sqle.getMessage());
    }
  } // GEN-LAST:event_btnubahActionPerformed
Beispiel #10
0
 private void preencherTabela() {
   Vector linhas;
   linhas =
       controladora.obterLinhas(
           "" + this.tfPesquisar.getText(), cbSatus.getSelectedItem().toString());
   DefaultTableModel modelo = (DefaultTableModel) this.tbCargos.getModel();
   int numLinhas = linhas.size();
   for (int i = 0; i < numLinhas; i++) {
     modelo.insertRow(modelo.getRowCount(), (Vector) linhas.get(i));
   }
 }
  private void loadTable() {
    model = (DefaultTableModel) jTable1.getModel();
    model.setRowCount(0);

    try {
      global.ActivityType = global.con.createStatement();
      global.ActivityTypeRS =
          global.ActivityType.executeQuery("SELECT * FROM activitytypes ORDER BY ActivityTypeName");
      while (global.ActivityTypeRS.next()) {
        if (global.ActivityTypeRS.getInt("active") == 1) {
          model.insertRow(
              global.ActivityTypeRS.getRow() - 1,
              new Object[] {
                global.ActivityTypeRS.getInt("ActivityTypeID"),
                global.ActivityTypeRS.getString("ActivityTypeName"),
                "Yes"
              });
        } else {
          model.insertRow(
              global.ActivityTypeRS.getRow() - 1,
              new Object[] {
                global.ActivityTypeRS.getInt("ActivityTypeID"),
                global.ActivityTypeRS.getString("ActivityTypeName"),
                "No"
              });
        }
      }
    } catch (SQLException ex) {
      StringWriter error = new StringWriter();
      ex.printStackTrace(new PrintWriter(error));
      SystemCrashDialog crash =
          new SystemCrashDialog(
              global.root,
              true,
              global,
              global.root.getHeaderRootPanel1().getClientComboBox().getSelectedItem().toString(),
              global.root.getHeaderRootPanel1().getMatterComboBox().getSelectedItem().toString(),
              "Err0008",
              error.toString());
    }
  }
Beispiel #12
0
 void move(int direction) {
   if (direction < 0 && editIndex == 0) return;
   Array<ParticleEmitter> emitters = editor.effect.getEmitters();
   if (direction > 0 && editIndex == emitters.size - 1) return;
   int insertIndex = editIndex + direction;
   Object name = emitterTableModel.getValueAt(editIndex, 0);
   emitterTableModel.removeRow(editIndex);
   ParticleEmitter emitter = emitters.removeIndex(editIndex);
   emitterTableModel.insertRow(insertIndex, new Object[] {name});
   emitters.insert(insertIndex, emitter);
   editIndex = insertIndex;
   emitterTable.getSelectionModel().setSelectionInterval(editIndex, editIndex);
 }
Beispiel #13
0
  private void populaTabela() {

    int counter = 0;
    if (this.isConsultaPorResponsavel) {
      try {
        ligacoes =
            BusinessFactory.getInstance()
                .getNumeroTelefonico()
                .getLigacoesPorUsuario(usuarioSelecionado.getEmail());

      } catch (BusinessException ex) {
        Logger.getLogger(JPConsultarLigacao.class.getName()).log(Level.SEVERE, null, ex);
      }
    } else {
      try {
        ligacoes =
            BusinessFactory.getInstance()
                .getNumeroTelefonico()
                .getLigacoes(new NumeroTelefonicoVO(jTextField5.getText()));

      } catch (BusinessException ex) {
        Logger.getLogger(JPConsultarLigacao.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
    DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
    model.setRowCount(0);
    for (UsuarioNumeroTelefonicoVO ligacao : ligacoes) {
      DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
      String recorrencia = "";

      ResourceBundle bundle = ResourceBundle.getBundle("I18n/Bundle");

      if (ligacao.getRecorrencia() == 1) {
        recorrencia = bundle.getString("JPConsultarNumeroTelefonico.CellText.Recorrente");
      } else if (ligacao.getRecorrencia() == 0) {
        recorrencia = bundle.getString("JPConsultarNumeroTelefonico.CellText.NaoRecorrente");
      }

      model.insertRow(
          counter,
          new Object[] {
            ligacao.getNumero().getNumero(),
            ligacao.getUsuario().getNome(),
            df.format(ligacao.getDataHora().getTime()),
            recorrencia
          });

      counter++;
    }
    jTable1.changeSelection(0, 0, false, false);
  }
  /** Fills the table with all the User's rentals. */
  public void fillTable() {

    // query to send to the database
    String bank = "select * from Has_Rented where " + "renter_phone=" + main.curr.getPhone() + ";";

    // get the movies to display and store them as
    // a string array
    StringBuilder new_releases = getMovies(bank);
    String temp = new_releases.toString();
    String[] rel_arr = temp.split("~");

    // create some other arrays for filling in the table
    long[] late_arr = new long[rel_arr.length / 4];
    int[] movie_arr = new int[rel_arr.length / 4];
    String[] movie_title = new String[rel_arr.length / 4];

    // get the movie ids of the rented movies
    int row = 0;
    bank = new String("select movie_name from " + "Movie where movie_id=");
    for (int i = 0; i < rel_arr.length - 3; i += 4) {
      movie_arr[row] = Integer.parseInt(rel_arr[i + 1]);
      row++;
    }

    // get all the movie names from the movie ids
    row = 0;
    for (int i = 0; i < movie_arr.length; i++) {
      movie_title[i] = getMovieName(bank, movie_arr[i]);
    }

    for (int i = 0; i < rel_arr.length - 3; i += 4) {

      long due_day = 0, curr_day = 0, days_late = 0;

      Date due = Date.valueOf(rel_arr[i + 3]);
      due_day = due.getTime();

      curr_day = System.currentTimeMillis();
      // calculate each movie's late days
      days_late = curr_day - due_day;

      if (days_late > 0) late_arr[row] = days_late / 86400000;
      else late_arr[row] = 0;

      // insert each movie into the table
      model.insertRow(
          row, new Object[] {movie_title[row], rel_arr[i + 2], rel_arr[i + 3], late_arr[row]});
      row++;
    }
  }
  public void loadTemplates(int userID) {
    Vector templates = null;
    try {
      templates = (Vector) reportPanel.getRemoteTask().getUserJob(userID);
      for (int i = 0; i < templates.size(); i++) {
        UserJob userjobs = (UserJob) templates.get(i);
        tablemodel.insertRow(i, new Object[] {userjobs.getId(), userjobs.getTreeNodeName()});
      }

    } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Beispiel #16
0
 private void populateTblCustomer() {
   List<Customer> list = customers;
   DefaultTableModel tableModel = (DefaultTableModel) tblCustomer.getModel();
   tableModel.getDataVector().removeAllElements();
   // tblCustomer.repaint();
   if (list.size() > 0) {
     for (int i = 0; i < list.size(); i++) {
       Customer customer = list.get(i);
       tableModel.insertRow(
           i,
           new Object[] {
             i + 1,
             customer.getSurName(),
             customer.getForeName(),
             customer.getAddLine1(),
             customer.getPostCode(),
             customer.getTelNo(),
             customer.getEmail()
           });
     }
   } else {
     tableModel.insertRow(0, new Object[] {});
   }
 }
 public void pesquisar() {
   limparTabela();
   for (ITripulante tri : controller.buscarTripulantes(txtNome.getText().trim())) {
     modelo.insertRow(
         modelo.getRowCount(),
         new Object[] {
           tri.getNome(),
           tri.getSexo(),
           tri.getNaturalidade(),
           tri.getNascimento().toString(),
           tri.getProfissao(),
           tri.getId()
         });
   }
 }
 public void saveTemplate(String templateName, int userID) {
   if (!commonUTIL.isEmpty(templateName)) {
     job = new UserJob();
     job.setId(0);
     job.setTabid(0);
     job.setUserID(user.getId());
     job.setType(getReportType().toUpperCase());
     job.setTreeNodeName(templateName);
     setTemplateFrame(templateName);
     try {
       job = (UserJob) reportPanel.getRemoteTask().saveUserJob(job);
       tablemodel.insertRow(
           tablemodel.getRowCount(), new Object[] {job.getId(), job.getTreeNodeName()});
     } catch (RemoteException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }
  public void tabloDoldur3() {

    try {
      Statement st = lwn.dbOpen();
      res =
          st.executeQuery(
              "SELECT S.*, B.kitap_no, B.kitap_ad  FROM student S, out_book OB , book B WHERE OB.ogrenci_no = S.ogrenci_no AND OB.kitapno=B.kitap_no");
      while (res.next()) {
        model3.insertRow(
            model3.getRowCount(),
            new Object[] {
              res.getInt("ogrenci_no"),
              res.getString("ogrenci_ad"),
              res.getString("ogrenci_soyad"),
              res.getString("ogrenci_sinif"),
              res.getInt("kitap_no"),
              res.getString("kitap_ad")
            });
      }
      lwn.dbClose();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, e.getMessage());
    }
  }
Beispiel #20
0
  // Load all users
  public void loadUsers(javax.swing.JTable tblUsers, javax.swing.table.DefaultTableModel tbmUsers) {
    logManager.logInfo(
        "Entering 'loadUsers(javax.swing.JTable tblUsers, javax.swing.table.DefaultTableModel tbmUsers)' method");
    String firstName = "";
    String lastName = "";
    String middleName = "";
    String userRole = "";
    String organisation = "";
    String language = "";
    int userNumber = 0;
    int userIndex = 0;
    int userId = 0;
    boolean isActive = false;

    try {
      sqlString = queryBuilder.sqlSelectUsers();
      resultset = executeQuery.executeSelect(sqlString);
      // Add columns to model
      insertColumnsToModel(
          tblUsers,
          tbmUsers,
          "Number",
          "First Name",
          "Last Name",
          "Middle Name",
          "User Role",
          "Organisation",
          "Language",
          "Active");
      // Set row count to 0
      tbmUsers.setRowCount(0);

      if (resultset.next()) {
        while (!resultset.isAfterLast()) {
          firstName = resultset.getString("fname"); // index 1
          lastName = resultset.getString("lname"); // index 2
          middleName = resultset.getString("mname"); // index 3
          userRole = resultset.getString("rname"); // index 4
          organisation = resultset.getString("org"); // index 5
          language = resultset.getString("langname"); // index 6
          isActive = resultset.getInt("active") != 0 ? true : false; // index 7
          userId = resultset.getInt("user_id"); // index 0
          // Insert row
          tbmUsers.insertRow(userIndex, new Object[] {null});
          // Populate rows
          tblUsers.setValueAt(userId, userIndex, 0);
          tblUsers.setValueAt(firstName, userIndex, 1);
          tblUsers.setValueAt(lastName, userIndex, 2);
          tblUsers.setValueAt(middleName, userIndex, 3);
          tblUsers.setValueAt(userRole, userIndex, 4);
          tblUsers.setValueAt(organisation, userIndex, 5);
          tblUsers.setValueAt(language, userIndex, 6);
          tblUsers.setValueAt(new JCheckBox("", isActive), userIndex, 7);
          resultset.next();
        }
      }
    } catch (Exception exception) {
      logManager.logError(
          "Exception was thrown and caught in 'loadUsers(javax.swing.JTable tblUsers, javax.swing.table.DefaultTableModel tbmUsers)' method");
    }
    logManager.logInfo(
        "Exiting 'loadUsers(javax.swing.JTable tblUsers, javax.swing.table.DefaultTableModel tbmUsers)' method");
  }
Beispiel #21
0
 @Override
 public void roleadd(EventAll<Rooms> event) {
   model.insertRow(0, event.getSource().toArray());
 }
Beispiel #22
0
  stafforgan(
      ArrayList<EmploeePO> empolist, final ObjectOutputStream oos, final ObjectInputStream ois)
      throws IOException {
    new ImageGet();
    Image bgp = ImageGet.getImageByState("stafforgan");
    background = new ImageIcon(bgp);

    //		setTitle("人员机构调度");
    setBounds(500, 300, 800, 500);
    setResizable(false);
    setLayout(null);

    JPanel back =
        new JPanel() {
          public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(background.getImage(), 0, 0, null);
          }
        };
    back.setBounds(0, 0, 800, 500);
    back.setLayout(null);
    back.setOpaque(false);

    setUndecorated(true);
    setResizable(false);

    JButton b3 = new JButton();
    b3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    String[] columnnames = {"员工ID", "员工姓名", "职位"};
    Object[][] data = {};
    DefaultTableModel model = new DefaultTableModel(data, columnnames);
    final JTable table =
        new JTable(model) {
          public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component c = super.prepareRenderer(renderer, row, column);
            if (c instanceof JComponent) {
              ((JComponent) c).setOpaque(false);
            }
            return c;
          }
        };

    for (int i = 0; i < empolist.size(); i++) {
      Object[] add = {
        empolist.get(i).getEmpID(), empolist.get(i).getName(), empolist.get(i).getPosition()
      };
      DefaultTableModel newmodel = (DefaultTableModel) table.getModel();
      model.insertRow(newmodel.getRowCount(), add);
    }
    table.getTableHeader().setFont(new Font("幼圆", Font.BOLD, 20));
    table.setForeground(Color.white);

    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
    table.setDefaultRenderer(Object.class, renderer);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.getColumnModel().getColumn(0).setPreferredWidth(151);
    table.getColumnModel().getColumn(1).setPreferredWidth(152);
    table.getColumnModel().getColumn(2).setPreferredWidth(152);

    table.setOpaque(false);

    JScrollPane jp = new JScrollPane(table);
    jp.setOpaque(false);
    jp.getViewport().setOpaque(false);

    setLayout(null);

    JButton b4 = new JButton();
    b4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            staffchange sfc = null;
            DefaultTableModel model = (DefaultTableModel) table.getModel();
            int row = table.getSelectedRow();
            String id = (String) table.getValueAt(row, 0);
            EmploeeBl embl = new EmploeeBl(oos, ois);
            EmploeePO empo = embl.IDGetEmp(id);
            try {
              sfc = new staffchange(empo, oos, ois);
            } catch (IOException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
            sfc.setVisible(true);
          }
        });

    add(b3);
    add(b4);
    add(jp);
    add(back);

    b3.setContentAreaFilled(false);
    b3.setBorder(BorderFactory.createEmptyBorder());
    b3.setBounds(763, 0, 37, 31);

    b4.setContentAreaFilled(false);
    b4.setBorder(BorderFactory.createEmptyBorder());
    b4.setBounds(617, 410, 134, 50);

    jp.setBounds(197, 119, 459, 270);

    addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            isDraging = true;
            xx = e.getX();
            yy = e.getY();
          }

          public void mouseReleased(MouseEvent e) {
            isDraging = false;
          }
        });
    addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            if (isDraging) {
              int left = getLocation().x;
              int top = getLocation().y;
              setLocation(left + e.getX() - xx, top + e.getY() - yy);
            }
          }
        });
  }
Beispiel #23
0
 /**
  * Adds row to table.
  *
  * @param word toTranslate part of the word
  * @param translation translation of the word
  */
 public void addRow(String word, String translation) {
   tableModel.insertRow(table.getRowCount(), new Object[] {word, translation});
 }
 @Override
 public void insertRow(int row, Object[] rowData) {
   super.insertRow(row, rowData);
 }
 @Override
 public void insertRow(int row, Vector rowData) {
   super.insertRow(row, rowData);
 }