📄 operationframe.java
字号:
}); fileJMenu.add(openFileJMenuItem); mainJMenuBar.add(fileJMenu); editorJMenu.setText("编辑"); lookJMenuItem.setText("查看"); lookJMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lookJMenuItemActionPerformed(evt); } }); editorJMenu.add(lookJMenuItem); newJMenuItem.setText("新增"); newJMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { newJMenuItemActionPerformed(evt); } }); editorJMenu.add(newJMenuItem); changeJMenuItem.setText("修改与删除"); changeJMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { changeJMenuItemActionPerformed(evt); } }); editorJMenu.add(changeJMenuItem); changPasswordJMenuItem.setText("修改密码"); changPasswordJMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { changPasswordJMenuItemActionPerformed(evt); } }); editorJMenu.add(changPasswordJMenuItem); setOrderJMenuItem.setText("排序"); setOrderJMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { setOrderJMenuItemActionPerformed(evt); } }); editorJMenu.add(setOrderJMenuItem); mainJMenuBar.add(editorJMenu); helpJMenu.setText("帮助"); authorJMenuItem.setText("关于作者"); authorJMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { authorJMenuItemActionPerformed(evt); } }); helpJMenu.add(authorJMenuItem); versionJMenuItem.setText("版本"); versionJMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { versionJMenuItemActionPerformed(evt); } }); helpJMenu.add(versionJMenuItem); jMenuItem1.setText("说明"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); helpJMenu.add(jMenuItem1); mainJMenuBar.add(helpJMenu); setJMenuBar(mainJMenuBar); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(examinationJPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(newJPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(changeJPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(20, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(examinationJPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(newJPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(changeJPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private File selectedFile; private ArrayList photoArrayList=new ArrayList(); private PrintWriter input; private BufferedReader output; private int position=0; private Photo newPhoto; private int okNumber=0; private void numberJRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_numberJRadioButtonActionPerformed // TODO add your handling code here: if(numberJRadioButton.isSelected()){ number1JTextField.setEditable(true); } else{ number1JTextField.setEditable(false); } }//GEN-LAST:event_numberJRadioButtonActionPerformed private void nameJRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameJRadioButtonActionPerformed // TODO add your handling code here: if(nameJRadioButton.isSelected()){ name1JTextField.setEditable(true); } else{ name1JTextField.setEditable(false); } }//GEN-LAST:event_nameJRadioButtonActionPerformed private void dateJRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dateJRadioButtonActionPerformed // TODO add your handling code here: if(dateJRadioButton.isSelected()){ date1JTextField.setEditable(true); } else{ date1JTextField.setEditable(false); } }//GEN-LAST:event_dateJRadioButtonActionPerformed private void authorJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authorJMenuItemActionPerformed // TODO add your handling code here: AuthorFrame author=new AuthorFrame(); author.setVisible(true); author.setLocationRelativeTo(null);}//GEN-LAST:event_authorJMenuItemActionPerformed private void versionJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_versionJMenuItemActionPerformed // TODO add your handling code here: VersionFrame version=new VersionFrame(); version.setVisible(true); version.setLocationRelativeTo(null);}//GEN-LAST:event_versionJMenuItemActionPerformed private void changPasswordJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changPasswordJMenuItemActionPerformed // TODO add your handling code here: ChangePasswordFrame password=new ChangePasswordFrame(); password.setVisible(true); password.setLocationRelativeTo(null);}//GEN-LAST:event_changPasswordJMenuItemActionPerformed private void openFileJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openFileJMenuItemActionPerformed // TODO add your handling code here: JFileChooser fileChooser=new JFileChooser(); fileChooser.setDialogTitle("Open the photo file!"); int result=fileChooser.showOpenDialog(this); if(result==JFileChooser.CANCEL_OPTION){ return; } selectedFile=fileChooser.getSelectedFile(); okNumber=1;}//GEN-LAST:event_openFileJMenuItemActionPerformed private void lookJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lookJMenuItemActionPerformed // TODO add your handling code here: if(okNumber==1){ numberJRadioButton.setEnabled(true); nameJRadioButton.setEnabled(true); dateJRadioButton.setEnabled(true); placeJRadioButton.setEnabled(true); allJRadioButton.setEnabled(true); seeJButton.setEnabled(true); } else{ JOptionPane.showMessageDialog(null,"请先打开相片文件","Miss Source File!",JOptionPane.WARNING_MESSAGE); } }//GEN-LAST:event_lookJMenuItemActionPerformed private void newJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newJMenuItemActionPerformed // TODO add your handling code here: if(okNumber==1){ number2JTextField.setEditable(true); name2JTextField.setEditable(true); date2JTextField.setEditable(true); place2JTextField.setEditable(true); twoJTextArea.setEditable(true); ok2JButton.setEnabled(true); } else{ JOptionPane.showMessageDialog(null,"请先打开相片文件","Miss Source File!",JOptionPane.WARNING_MESSAGE); } }//GEN-LAST:event_newJMenuItemActionPerformed private void changeJMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeJMenuItemActionPerformed // TODO add your handling code here: if(okNumber==1){ number3JTextField.setEditable(true); showJButton.setEnabled(true); } else{ JOptionPane.showMessageDialog(null,"请先打开相片文件","Miss Source File!",JOptionPane.WARNING_MESSAGE); } }//GEN-LAST:event_changeJMenuItemActionPerformed private void ok2JButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok2JButtonActionPerformed // TODO add your handling code here: boolean checkPoint=checkContents(0,number2JTextField); if(checkPoint==false){ if(!number2JTextField.getText().equals("")&& !name2JTextField.getText().equals("")&& !date2JTextField.getText().equals("")&& !place2JTextField.getText().equals("")&& !twoJTextArea.getText().equals("")) { FileWriter inputFile=null; try {//GEN-LAST:event_ok2JButtonActionPerformed inputFile = new FileWriter(selectedFile, true); input=new PrintWriter(inputFile); } catch (IOException ex) { JOptionPane.showMessageDialog( this, "Cannot open the file " + selectedFile.getName() + ".", "Error", JOptionPane.ERROR_MESSAGE ); } input.println(number2JTextField.getText()); input.println(name2JTextField.getText()); input.println(date2JTextField.getText()); input.println(place2JTextField.getText()); input.println(twoJTextArea.getText()); input.close(); } else{ JOptionPane.showMessageDialog(null,"请在每个选项内填入内容!","Miss Imformation",JOptionPane.ERROR_MESSAGE); } number2JTextField.setText(""); name2JTextField.setText(""); date2JTextField.setText(""); place2JTextField.setText(""); twoJTextArea.setText(""); }else{ JOptionPane.showMessageDialog(null,"ID重复!请重新输入!","Wrong PhotoID!",JOptionPane.ERROR_MESSAGE); number2JTextField.setText(""); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -