/* A basic implementation of the JDialog class. */ package SesameGUI; import java.awt.*; import javax.swing.*; import com.symantec.itools.javax.swing.JButtonGroupPanel; public class JDialogFilter extends javax.swing.JDialog { private double HIGH=0.5; private double LOW=25.0; private double BAND1=0.5; private double BAND2=25.0; boolean SETLow=false; boolean SETHigh=true; boolean SETBand=false; public JDialogFilter(Frame parent) { super(parent); // This code is automatically generated by Visual Cafe when you add // components to the visual environment. It instantiates and initializes // the components. To modify the code, only use code syntax that matches // what Visual Cafe can generate, or Visual Cafe may be unable to back // parse your Java file into its visual environment. //{{INIT_CONTROLS setTitle("Filter Options"); getContentPane().setLayout(null); setSize(405,193); setVisible(false); JButtonCancel.setText("Cancel"); JButtonCancel.setActionCommand("Cancel"); getContentPane().add(JButtonCancel); JButtonCancel.setBounds(48,144,84,24); JButtonOK.setText("OK"); JButtonOK.setActionCommand("OK"); getContentPane().add(JButtonOK); JButtonOK.setBounds(276,144,84,24); JTextFieldHigh.setText("0.5"); getContentPane().add(JTextFieldHigh); JTextFieldHigh.setBounds(204,24,48,24); JTextFieldLow.setText("25"); getContentPane().add(JTextFieldLow); JTextFieldLow.setBounds(204,60,48,24); JTextFieldBand1.setText("0.5"); getContentPane().add(JTextFieldBand1); JTextFieldBand1.setBounds(204,96,48,24); JTextFieldBand2.setText("25"); getContentPane().add(JTextFieldBand2); JTextFieldBand2.setBounds(276,96,48,24); JRadioButtonHigh.setText("High Pass"); JRadioButtonHigh.setActionCommand("High Pass"); JRadioButtonHigh.setSelected(true); getContentPane().add(JRadioButtonHigh); JRadioButtonHigh.setBounds(60,24,108,24); JRadioButtonLow.setText("Low Pass"); JRadioButtonLow.setActionCommand("Low Pass"); getContentPane().add(JRadioButtonLow); JRadioButtonLow.setBounds(60,60,120,24); JRadioButtonBand.setText("Band Pass"); JRadioButtonBand.setActionCommand("Band Pass"); getContentPane().add(JRadioButtonBand); JRadioButtonBand.setBounds(60,96,132,24); //}} //{{REGISTER_LISTENERS SymAction lSymAction = new SymAction(); JButtonOK.addActionListener(lSymAction); SymItem lSymItem = new SymItem(); JRadioButtonHigh.addItemListener(lSymItem); JRadioButtonLow.addItemListener(lSymItem); JRadioButtonBand.addItemListener(lSymItem); JButtonCancel.addActionListener(lSymAction); //}} setInitValues(); } public JDialogFilter() { this((Frame)null); } public JDialogFilter(String sTitle) { this(); setTitle(sTitle); } public void setVisible(boolean b) { if (b) setLocation(50, 50); super.setVisible(b); } static public void main(String args[]) { (new JDialogFilter()).setVisible(true); } public void addNotify() { // Record the size of the window prior to calling parents addNotify. Dimension size = getSize(); super.addNotify(); if (frameSizeAdjusted) return; frameSizeAdjusted = true; // Adjust size of frame according to the insets Insets insets = getInsets(); setSize(insets.left + insets.right + size.width, insets.top + insets.bottom + size.height); } // Used by addNotify boolean frameSizeAdjusted = false; //{{DECLARE_CONTROLS javax.swing.JButton JButtonCancel = new javax.swing.JButton(); javax.swing.JButton JButtonOK = new javax.swing.JButton(); javax.swing.JTextField JTextFieldHigh = new javax.swing.JTextField(); javax.swing.JTextField JTextFieldLow = new javax.swing.JTextField(); javax.swing.JTextField JTextFieldBand1 = new javax.swing.JTextField(); javax.swing.JTextField JTextFieldBand2 = new javax.swing.JTextField(); javax.swing.JRadioButton JRadioButtonHigh = new javax.swing.JRadioButton(); javax.swing.JRadioButton JRadioButtonLow = new javax.swing.JRadioButton(); javax.swing.JRadioButton JRadioButtonBand = new javax.swing.JRadioButton(); //}} public double getHIGH() { return HIGH; } public double getLOW() { return LOW; } public double getBAND1() { return BAND1; } public double getBAND2() { return BAND2; } public int getRadioLow() { if(SETLow) return 1; return 0; } public int getRadioHigh() { if(SETHigh) return 1; return 0; } public int getRadioBand() { if(SETBand) return 1; return 0; } public void setLOW(double val) { LOW = val; } public void setHIGH(double val) { HIGH = val; } public void setBAND1(double val) { BAND1 = val; } public void setBAND2(double val) { BAND2 = val; } public void setRadioLow(int set) { if( set==1 ) SETLow = true; else SETLow = false; } public void setRadioHigh(int set) { if( set==1 ) SETHigh = true; else SETHigh = false; } public void setRadioBand(int set) { if( set==1 ) SETBand = true; else SETBand = false; } class SymAction implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent event) { Object object = event.getSource(); if (object == JButtonOK) JButtonOK_actionPerformed(event); else if (object == JButtonCancel) JButtonCancel_actionPerformed(event); } } void JButtonOK_actionPerformed(java.awt.event.ActionEvent event) { // OK this.setVisible(false); HIGH = (new Double(this.JTextFieldHigh.getText())).doubleValue(); LOW = (new Double(this.JTextFieldLow.getText())).doubleValue(); BAND1 = (new Double(this.JTextFieldBand1.getText())).doubleValue(); BAND2 = (new Double(this.JTextFieldBand2.getText())).doubleValue(); SETLow = JRadioButtonLow.isSelected(); SETHigh = JRadioButtonHigh.isSelected(); SETBand = JRadioButtonBand.isSelected(); } public void setInitValues() { JTextFieldHigh.setText(""+HIGH); JTextFieldLow.setText(""+LOW); JTextFieldBand1.setText(""+BAND1); JTextFieldBand2.setText(""+BAND2); JRadioButtonLow.setSelected(SETLow); JRadioButtonHigh.setSelected(SETHigh); JRadioButtonBand.setSelected(SETBand); } class SymItem implements java.awt.event.ItemListener { public void itemStateChanged(java.awt.event.ItemEvent event) { Object object = event.getSource(); if (object == JRadioButtonHigh) JRadioButtonHigh_itemStateChanged(event); else if (object == JRadioButtonLow) JRadioButtonLow_itemStateChanged(event); else if (object == JRadioButtonBand) JRadioButtonBand_itemStateChanged(event); } } void JRadioButtonHigh_itemStateChanged(java.awt.event.ItemEvent event) { // unselect rest if( JRadioButtonHigh.isSelected() ) { JRadioButtonLow.setSelected(false); JRadioButtonBand.setSelected(false); } } void JRadioButtonLow_itemStateChanged(java.awt.event.ItemEvent event) { // unselect rest if( JRadioButtonLow.isSelected() ) { JRadioButtonHigh.setSelected(false); JRadioButtonBand.setSelected(false); } } void JRadioButtonBand_itemStateChanged(java.awt.event.ItemEvent event) { // unselect rest if( JRadioButtonBand.isSelected() ) { JRadioButtonLow.setSelected(false); JRadioButtonHigh.setSelected(false); } } void JButtonCancel_actionPerformed(java.awt.event.ActionEvent event) { // Cancel this.setVisible(false); setInitValues(); } }