/**
* Copyright 2011 Kevin J. Jones (http://www.kevinjjones.co.uk)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package uk.co.kevinjjones;
import java.awt.Container;
import javax.swing.JDialog;
/**
* Show settings dialog
*/
public class OptionsDialog extends javax.swing.JPanel {
/**
* Creates new form OptionsDialog
*/
public OptionsDialog() {
initComponents();
}
/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
buttonGroup3 = new javax.swing.ButtonGroup();
buttonGroup4 = new javax.swing.ButtonGroup();
jPanel3 = new javax.swing.JPanel();
KPH = new javax.swing.JRadioButton();
this.KPH.setSelected(RunManager.getInstance().getKPH()==1);
NotSet = new javax.swing.JRadioButton();
this.NotSet.setSelected(RunManager.getInstance().getKPH()==0);
MPH = new javax.swing.JRadioButton();
this.MPH.setSelected(RunManager.getInstance().getKPH()==2);
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Speed"));
jPanel3.setPreferredSize(new java.awt.Dimension(199, 49));
jPanel3.setRequestFocusEnabled(false);
buttonGroup3.add(KPH);
KPH.setText("KPH");
KPH.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
KPHActionPerformed(evt);
}
});
buttonGroup3.add(NotSet);
NotSet.setText("Not Set");
NotSet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NotSetActionPerformed(evt);
}
});
buttonGroup3.add(MPH);
MPH.setText("MPH");
MPH.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MPHActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(KPH)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(MPH)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(NotSet)
.addGap(55, 55, 55))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(KPH)
.addComponent(NotSet)
.addComponent(MPH))
);
jLabel1.setText("Please select units of speed used in logfile ");
jButton1.setText("OK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton1)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(8, 8, 8)))
.addContainerGap(20, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
Container p = this;
while (p != null) {
if (p instanceof JDialog) {
p.setVisible(false);
}
p = p.getParent();
}
}//GEN-LAST:event_jButton1ActionPerformed
private void KPHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_KPHActionPerformed
RunManager.getInstance().setKPH(true);
}//GEN-LAST:event_KPHActionPerformed
private void NotSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NotSetActionPerformed
RunManager.getInstance().unsetKPH();
}//GEN-LAST:event_NotSetActionPerformed
private void MPHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MPHActionPerformed
RunManager.getInstance().setKPH(false);
}//GEN-LAST:event_MPHActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton KPH;
private javax.swing.JRadioButton MPH;
private javax.swing.JRadioButton NotSet;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.ButtonGroup buttonGroup3;
private javax.swing.ButtonGroup buttonGroup4;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel3;
// End of variables declaration//GEN-END:variables
}