/* A basic implementation of the JDialog class. */ package SesameGUI; import java.awt.*; import javax.swing.*; public class JDialogManualWindow extends javax.swing.JDialog { private double WIN_LENGTH=20; private double OVERLAP=1; public JDialogManualWindow(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("Manual Window Selection"); getContentPane().setLayout(null); setSize(451,281); setVisible(false); JButtonOK.setText("OK"); JButtonOK.setActionCommand("OK"); getContentPane().add(JButtonOK); JButtonOK.setBounds(48,228,96,24); JButtonCancel.setText("Cancel"); JButtonCancel.setActionCommand("Cancel"); getContentPane().add(JButtonCancel); JButtonCancel.setBounds(312,228,96,24); JEditWindowLength.setText("20.0"); getContentPane().add(JEditWindowLength); JEditWindowLength.setBounds(192,60,60,24); JEditOverlap.setText("1.0"); getContentPane().add(JEditOverlap); JEditOverlap.setBounds(348,144,60,24); JLabel1.setText("Window Length (sec)"); getContentPane().add(JLabel1); JLabel1.setBounds(60,60,132,24); JLabel2.setText("Space between Windows (negative for overlaping) (sec)"); getContentPane().add(JLabel2); JLabel2.setBounds(24,144,324,24); //}} //{{REGISTER_LISTENERS SymAction lSymAction = new SymAction(); JButtonOK.addActionListener(lSymAction); JButtonCancel.addActionListener(lSymAction); //}} setInitValues(); } public JDialogManualWindow() { this((Frame)null); } public JDialogManualWindow(Frame frame,boolean modal) { this(frame); this.setModal(true); } public JDialogManualWindow(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 JDialogManualWindow()).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 JButtonOK = new javax.swing.JButton(); javax.swing.JButton JButtonCancel = new javax.swing.JButton(); javax.swing.JTextField JEditWindowLength = new javax.swing.JTextField(); javax.swing.JTextField JEditOverlap = new javax.swing.JTextField(); javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); //}} 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 setVisible(false); WIN_LENGTH = (new Double( JEditWindowLength.getText() )).doubleValue(); OVERLAP = (new Double( JEditOverlap.getText() ) ).doubleValue(); } public void setInitValues() { JEditWindowLength.setText(""+WIN_LENGTH); JEditOverlap.setText(""+OVERLAP); } void JButtonCancel_actionPerformed(java.awt.event.ActionEvent event) { // Cancel setVisible(false); setInitValues(); } public double getWindowLength() { return WIN_LENGTH; } public double getOverlap() { return OVERLAP; } public void setWindowLength(double val) { WIN_LENGTH = val; } public void setOverlap(double val) { OVERLAP = val; } }