src/main/java/org/sanmarcux/view/JFrameInit.java
package org.sanmarcux.view;
import org.sanmarcux.util.FormSupport;
import org.sanmarcux.util.ResourceBundleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.swing.*;
/**
* @author Cesardl
*/
@Component
public class JFrameInit extends javax.swing.JFrame {
private static final long serialVersionUID = -8892078424897840083L;
@Autowired
private transient ResourceBundleHelper bundle;
// Variables declaration - do not modify//GEN-BEGIN:variables
@Autowired
private org.sanmarcux.view.JPanelStudent panelStudent;
@Autowired
private org.sanmarcux.view.JPanelTeacher panelTeacher;
@Autowired
private JDialogAbout dialogAbout;
private javax.swing.JTabbedPane tabbedPane;
/**
* 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@PostConstruct
private void initComponents() {
javax.swing.JPanel panel = new javax.swing.JPanel();
tabbedPane = new javax.swing.JTabbedPane();
javax.swing.JMenuBar menuBar = new javax.swing.JMenuBar();
javax.swing.JMenu menuActions = new javax.swing.JMenu();
javax.swing.JMenu menuStudent = new javax.swing.JMenu();
javax.swing.JMenuItem menuItemInsertStudent = new javax.swing.JMenuItem();
javax.swing.JMenuItem menuItemUpdateStudent = new javax.swing.JMenuItem();
javax.swing.JMenuItem menuItemDeleteStudent = new javax.swing.JMenuItem();
javax.swing.JMenu menuTeacher = new javax.swing.JMenu();
javax.swing.JMenuItem menuItemInsertTeacher = new javax.swing.JMenuItem();
javax.swing.JMenuItem menuItemUpdateTeacher = new javax.swing.JMenuItem();
javax.swing.JMenuItem menuItemDeleteTeacher = new javax.swing.JMenuItem();
javax.swing.JPopupMenu.Separator separator = new javax.swing.JPopupMenu.Separator();
javax.swing.JMenuItem menuItemExit = new javax.swing.JMenuItem();
javax.swing.JMenu menuHelp = new javax.swing.JMenu();
javax.swing.JMenuItem menuItemAbout = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(bundle.getString("app.title")); // NOI18N
panel.setBackground(new java.awt.Color(255, 255, 255));
tabbedPane.addTab(bundle.getString("dictionary.student"), panelStudent); // NOI18N
tabbedPane.addTab(bundle.getString("dictionary.teacher"), panelTeacher); // NOI18N
javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel);
panel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(
panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 905, Short.MAX_VALUE)
.addContainerGap())
);
panelLayout.setVerticalGroup(
panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
.addContainerGap())
);
menuBar.setBackground(new java.awt.Color(255, 255, 255));
menuActions.setText(bundle.getString("dictionary.actions")); // NOI18N
menuStudent.setText(bundle.getString("dictionary.student")); // NOI18N
menuItemInsertStudent.setText(bundle.getString("dictionary.new")); // NOI18N
menuItemInsertStudent.addActionListener(e -> menuItemInsertStudentActionPerformed());
menuStudent.add(menuItemInsertStudent);
menuItemUpdateStudent.setText(bundle.getString("dictionary.edit")); // NOI18N
menuItemUpdateStudent.addActionListener(e -> menuItemUpdateStudentActionPerformed());
menuStudent.add(menuItemUpdateStudent);
menuItemDeleteStudent.setText(bundle.getString("dictionary.delete")); // NOI18N
menuItemDeleteStudent.addActionListener(e -> menuItemDeleteStudentActionPerformed());
menuStudent.add(menuItemDeleteStudent);
menuActions.add(menuStudent);
menuTeacher.setText(bundle.getString("dictionary.teacher")); // NOI18N
menuItemInsertTeacher.setText(bundle.getString("dictionary.new")); // NOI18N
menuItemInsertTeacher.addActionListener(e -> menuItemInsertTeacherActionPerformed());
menuTeacher.add(menuItemInsertTeacher);
menuItemUpdateTeacher.setText(bundle.getString("dictionary.edit")); // NOI18N
menuItemUpdateTeacher.addActionListener(e -> menuItemUpdateTeacherActionPerformed());
menuTeacher.add(menuItemUpdateTeacher);
menuItemDeleteTeacher.setText(bundle.getString("dictionary.delete")); // NOI18N
menuItemDeleteTeacher.addActionListener(e -> menuItemDeleteTeacherActionPerformed());
menuTeacher.add(menuItemDeleteTeacher);
menuActions.add(menuTeacher);
menuActions.add(separator);
menuItemExit.setText(bundle.getString("dictionary.exit")); // NOI18N
menuItemExit.addActionListener(e -> menuItemExitActionPerformed());
menuActions.add(menuItemExit);
menuBar.add(menuActions);
menuHelp.setText(bundle.getString("dictionary.help")); // NOI18N
menuItemAbout.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
menuItemAbout.setText(bundle.getString("dictionary.about")); // NOI18N
menuItemAbout.addActionListener(e -> menuItemAboutActionPerformed());
menuHelp.add(menuItemAbout);
menuBar.add(menuHelp);
setJMenuBar(menuBar);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void menuItemInsertStudentActionPerformed() {//GEN-FIRST:event_menuItemInsertStudentActionPerformed
panelStudent.showDialog();
}//GEN-LAST:event_menuItemInsertStudentActionPerformed
private void menuItemUpdateStudentActionPerformed() {//GEN-FIRST:event_menuItemUpdateStudentActionPerformed
JTable target = panelStudent.getTable();
int row = target.getSelectedRow();
if (row == FormSupport.BAD_ROW) {
JOptionPane.showMessageDialog(this, bundle.getString("app.warning.student.table"), this.getTitle(), JOptionPane.WARNING_MESSAGE);
} else {
String code = String.valueOf(target.getValueAt(row, 0));
tabbedPane.setSelectedIndex(0);
panelStudent.showDialog(row, code);
}
}//GEN-LAST:event_menuItemUpdateStudentActionPerformed
private void menuItemDeleteStudentActionPerformed() {//GEN-FIRST:event_menuItemDeleteStudentActionPerformed
JTable target = panelStudent.getTable();
int row = target.getSelectedRow();
if (row == FormSupport.BAD_ROW) {
JOptionPane.showMessageDialog(this, bundle.getString("app.warning.student.table"), this.getTitle(), JOptionPane.WARNING_MESSAGE);
} else {
String code = String.valueOf(target.getValueAt(row, 0));
panelStudent.deleteRow(row, code);
}
}//GEN-LAST:event_menuItemDeleteStudentActionPerformed
private void menuItemInsertTeacherActionPerformed() {//GEN-FIRST:event_menuItemInsertTeacherActionPerformed
panelTeacher.showDialog();
}//GEN-LAST:event_menuItemInsertTeacherActionPerformed
private void menuItemUpdateTeacherActionPerformed() {//GEN-FIRST:event_menuItemUpdateTeacherActionPerformed
JTable target = panelTeacher.getTable();
int row = target.getSelectedRow();
if (row == FormSupport.BAD_ROW) {
JOptionPane.showMessageDialog(this, bundle.getString("app.warning.teacher.table"), this.getTitle(), JOptionPane.WARNING_MESSAGE);
} else {
String code = String.valueOf(target.getValueAt(row, 0));
tabbedPane.setSelectedIndex(1);
panelTeacher.showDialog(row, code);
}
}//GEN-LAST:event_menuItemUpdateTeacherActionPerformed
private void menuItemDeleteTeacherActionPerformed() {//GEN-FIRST:event_menuItemDeleteTeacherActionPerformed
JTable target = panelTeacher.getTable();
int row = target.getSelectedRow();
if (row == FormSupport.BAD_ROW) {
JOptionPane.showMessageDialog(this, bundle.getString("app.warning.teacher.table"), this.getTitle(), JOptionPane.WARNING_MESSAGE);
} else {
String code = String.valueOf(target.getValueAt(row, 0));
panelTeacher.deleteRow(row, code);
}
}//GEN-LAST:event_menuItemDeleteTeacherActionPerformed
private void menuItemExitActionPerformed() {//GEN-FIRST:event_menuItemExitActionPerformed
int i = JOptionPane.showConfirmDialog(this, bundle.getString("app.warning.exit"),
this.getTitle(), JOptionPane.YES_NO_OPTION);
if (i == JOptionPane.YES_OPTION) {
System.exit(0);
}
}//GEN-LAST:event_menuItemExitActionPerformed
private void menuItemAboutActionPerformed() {//GEN-FIRST:event_menuItemAboutActionPerformed
dialogAbout.setVisible(true);
}//GEN-LAST:event_menuItemAboutActionPerformed
// End of variables declaration//GEN-END:variables
}