📄 vehiclemanagerjpanel.java
字号:
newButton.setName("newButton"); // NOI18N deleteButton.setAction(actionMap.get("deleteRecord")); // NOI18N deleteButton.setFont(resourceMap.getFont("typeLabel.font")); // NOI18N deleteButton.setName("deleteButton"); // NOI18N saveButton.setAction(actionMap.get("save")); // NOI18N saveButton.setFont(resourceMap.getFont("typeLabel.font")); // NOI18N saveButton.setText(resourceMap.getString("saveButton.text")); // NOI18N saveButton.setName("saveButton"); // NOI18N route_idLabel.setFont(resourceMap.getFont("route_idLabel.font")); // NOI18N route_idLabel.setText(resourceMap.getString("route_idLabel.text")); // NOI18N route_idLabel.setName("route_idLabel"); // NOI18N route_idField.setFont(resourceMap.getFont("route_idField.font")); // NOI18N route_idField.setName("route_idField"); // NOI18N javax.swing.GroupLayout vehicleManagerPanelLayout = new javax.swing.GroupLayout(vehicleManagerPanel); vehicleManagerPanel.setLayout(vehicleManagerPanelLayout); vehicleManagerPanelLayout.setHorizontalGroup( vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(vehicleManagerPanelLayout.createSequentialGroup() .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(vehicleManagerPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(idLabel) .addComponent(route_idLabel))) .addGroup(vehicleManagerPanelLayout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(fareQuotietyLabel)) .addGroup(vehicleManagerPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(typeLabel))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(idField, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE) .addComponent(route_idField, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE) .addComponent(typeField, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE) .addComponent(fareQuotietyField, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE)) .addContainerGap()) .addGroup(vehicleManagerPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vehicleManagerPanelLayout.createSequentialGroup() .addContainerGap(347, Short.MAX_VALUE) .addComponent(newButton) .addGap(18, 18, 18) .addComponent(deleteButton) .addGap(18, 18, 18) .addComponent(updateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10)) ); vehicleManagerPanelLayout.setVerticalGroup( vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vehicleManagerPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE) .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(idLabel) .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(route_idLabel) .addComponent(route_idField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(11, 11, 11) .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(typeLabel) .addComponent(typeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(fareQuotietyLabel) .addComponent(fareQuotietyField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(vehicleManagerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(newButton) .addComponent(deleteButton) .addComponent(updateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); vehicleManagerPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {fareQuotietyField, idField, route_idField, typeField}); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(vehicleManagerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(vehicleManagerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); this.returnInitState(); }// </editor-fold>//GEN-END:initComponents private void masterTableFocusGained(java.awt.event.FocusEvent evt) { // TODO add your handling code here: this.newButton.setEnabled(true); this.deleteButton.setEnabled(true); this.updateButton.setEnabled(true); this.saveButton.setEnabled(false); this.idField.setEnabled(false); this.route_idField.setEnabled(true); this.typeField.setEnabled(true); this.fareQuotietyField.setEnabled(true); int i = this.masterTable.getSelectedRow(); this.idField.setText(this.masterTable.getModel().getValueAt(i, 0) .toString()); this.route_idField.setText(this.masterTable.getModel().getValueAt(i, 1) .toString()); this.typeField.setText(this.masterTable.getModel().getValueAt(i, 2) .toString()); this.fareQuotietyField.setText(this.masterTable.getModel().getValueAt( i, 3).toString()); } private void returnInitState() { this.newButton.setEnabled(true); this.deleteButton.setEnabled(false); this.updateButton.setEnabled(false); this.saveButton.setEnabled(false); this.idField.setText(""); this.idField.setEnabled(false); this.route_idField.setText(""); this.route_idField.setEnabled(false); this.typeField.setText(""); this.typeField.setEnabled(false); this.fareQuotietyField.setText("1.0"); this.fareQuotietyField.setEnabled(false); // 更新视图 String sql = "select * from vehicle"; ManagerPanelService.initFromDatabase(this.masterTable, sql); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton deleteButton; private javax.swing.JTextField fareQuotietyField; private javax.swing.JLabel fareQuotietyLabel; private javax.swing.JTextField idField; private javax.swing.JLabel idLabel; private javax.swing.JScrollPane masterScrollPane; private javax.swing.JTable masterTable; private javax.swing.JButton newButton; private javax.swing.JTextField route_idField; private javax.swing.JLabel route_idLabel; private javax.swing.JButton saveButton; private javax.swing.JTextField typeField; private javax.swing.JLabel typeLabel; private javax.swing.JButton updateButton; private javax.swing.JPanel vehicleManagerPanel; // End of variables declaration//GEN-END:variables Connection conn = Database.getConn(); Statement stmt = Database.createStmt(conn);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -