Please take time to read the code disclaimer.
/**
* LanguageDialog.java
*
* Created on Nov 21, 2011, 8:14:08 AM
*/
package encodergui;
import broadscope.StaticClass;
import encodequerygenerator.*;
/**
*
* @author Kent
*/
public class LanguageDialog extends javax.swing.JDialog {
private Language language;
/** Creates new form LanguageDialog
* @param parent
* @param modal
* @param language
*/
public LanguageDialog(java.awt.Dialog parent, boolean modal, Language language) {
super(parent, modal);
this.language = language;
initComponents();
myInitComponents();
}
/** 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")
// //GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
dialogLabel = new javax.swing.JLabel();
goBackButton = new javax.swing.JButton();
previewButton = new javax.swing.JButton();
editPanel = new javax.swing.JPanel();
languageNameTextField = new javax.swing.JTextField();
editDialogButton = new javax.swing.JToggleButton();
ignoredCheckBox = new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(windowName());
getContentPane().setLayout(new java.awt.GridBagLayout());
dialogLabel.setText("Series - DVD - Title - Track - Language Name");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
getContentPane().add(dialogLabel, gridBagConstraints);
goBackButton.setText("<- Go Back");
goBackButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
goBackButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
getContentPane().add(goBackButton, gridBagConstraints);
previewButton.setText("Preview");
previewButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
previewButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
getContentPane().add(previewButton, gridBagConstraints);
editPanel.setLayout(new java.awt.GridBagLayout());
languageNameTextField.setText("Language Name");
languageNameTextField.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 80;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
editPanel.add(languageNameTextField, gridBagConstraints);
editDialogButton.setText("Edit Language");
editDialogButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
editDialogButtonActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
editPanel.add(editDialogButton, gridBagConstraints);
ignoredCheckBox.setText("Ignored?");
ignoredCheckBox.setEnabled(false);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
editPanel.add(ignoredCheckBox, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
getContentPane().add(editPanel, gridBagConstraints);
pack();
}// //GEN-END:initComponents
private void goBackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goBackButtonActionPerformed
this.setVisible(false);
this.dispose();
}//GEN-LAST:event_goBackButtonActionPerformed
private void previewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previewButtonActionPerformed
TitleInfoDialog vtid = new TitleInfoDialog(null, true, language.getTitle());
vtid.setSelectedTrack(language.getNumber() - 1);
vtid.setVisible(true);
}//GEN-LAST:event_previewButtonActionPerformed
private void editDialogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editDialogButtonActionPerformed
if (editDialogButton.isSelected()) {
System.out.println("!editCompressed");
editDialogButton.setText("Submit Changes");
languageNameTextField.setEnabled(true);
ignoredCheckBox.setEnabled(true);
} else {
System.out.println("editCompressed");
editDialogButton.setText("Edit Language");
languageNameTextField.setEnabled(false);
ignoredCheckBox.setEnabled(false);
language.setIgnore(ignoredCheckBox.isSelected());
language.setName(languageNameTextField.getText());
}
}//GEN-LAST:event_editDialogButtonActionPerformed
//
/**
* This method initiates the components I want
*/
private void myInitComponents() {
languageNameTextField.setText(language.getName());
ignoredCheckBox.setSelected(language.isIgnore());
Title title = language.getTitle();
DVD dvd = title.getDvd();
Series series = dvd.getSeries();
dialogLabel.setText(series.getName() + " - " + dvd.getName() + " - " + title.getNumber() + " - " + language.getNumber() + " - " + language.getName());
StaticClass.addPartLogo(getContentPane(), getClass(), true, 40, java.awt.GridBagConstraints.SOUTHEAST, true);
StaticClass.centerAndPack(this);
StaticClass.setUnifiedColor(rootPane, java.awt.Color.white);
}
/**
* This method is for the name of the window
* @return "LANGUAGE NAME details"
*/
public String windowName() {
return language.getName() + " details";
}
//
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/** Set the Nimbus look and feel */
//
/** 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(LanguageDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LanguageDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LanguageDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LanguageDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//
/** Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
LanguageDialog dialog = new LanguageDialog(new javax.swing.JDialog(), true, new Language(new Title(new DVD(new Series(new DVDScanner(new EncodeFrame()), "No Series!"), "No DVD!"))));
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel dialogLabel;
private javax.swing.JToggleButton editDialogButton;
private javax.swing.JPanel editPanel;
private javax.swing.JButton goBackButton;
private javax.swing.JCheckBox ignoredCheckBox;
private javax.swing.JTextField languageNameTextField;
private javax.swing.JButton previewButton;
// End of variables declaration//GEN-END:variables
}