示例#1
0
 private void addEnterTwoValues(Panel p, String one, String two) {
   p.add(new Label("Enter value for Dimension " + one));
   TextField dim1 = new TextField(8);
   p.add(dim1);
   p.add(new Label("Enter value for Dimension " + two));
   TextField dim2 = new TextField(8);
   p.add(dim2);
 }
  /** Method declaration */
  private void initGUI() {

    Panel pQuery = new Panel();
    Panel pCommand = new Panel();

    pResult = new Panel();

    pQuery.setLayout(new BorderLayout());
    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());

    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new TextArea(5, 40);

    txtCommand.addKeyListener(this);

    txtResult = new TextArea(20, 40);

    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));

    butExecute = new Button("Execute");
    butClear = new Button("Clear");

    butExecute.addActionListener(this);
    butClear.addActionListener(this);
    pCommand.add("East", butExecute);
    pCommand.add("West", butClear);
    pCommand.add("Center", txtCommand);

    gResult = new Grid();

    setLayout(new BorderLayout());
    pResult.add("Center", gResult);
    pQuery.add("North", pCommand);
    pQuery.add("Center", pResult);
    fMain.add("Center", pQuery);

    tTree = new Tree();

    // (ulrivo): screen with less than 640 width
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

    if (d.width >= 640) {
      tTree.setMinimumSize(new Dimension(200, 100));
    } else {
      tTree.setMinimumSize(new Dimension(80, 100));
    }

    gResult.setMinimumSize(new Dimension(200, 300));
    fMain.add("West", tTree);
    doLayout();
    fMain.pack();
  }
  /**
   * Method declaration
   *
   * @param s
   * @param help
   */
  void showHelp(String help[]) {

    txtCommand.setText(help[0]);
    txtResult.setText(help[1]);

    bHelp = true;

    pResult.removeAll();
    pResult.add("Center", txtResult);
    pResult.doLayout();
    txtCommand.requestFocus();
    txtCommand.setCaretPosition(help[0].length());
  }
  /** Method declaration */
  void updateResult() {

    if (iResult == 0) {

      // in case 'help' has removed the grid
      if (bHelp) {
        pResult.removeAll();
        pResult.add("Center", gResult);
        pResult.doLayout();

        bHelp = false;
      }

      gResult.update();
      gResult.repaint();
    } else {
      showResultInText();
    }

    txtCommand.selectAll();
    txtCommand.requestFocus();
  }
示例#5
0
  public NslWrong(NslFrame parent) {

    super(parent, "Error", true);
    frame = parent;

    setLayout(new GridLayout(2, 1));

    Panel panel = new Panel();
    panel.add(new Label("Error: Invalid value for variable entered!"));

    add(panel);

    Button b;

    Panel okbutton = new Panel();
    okbutton.add(b = new Button("Ok"));
    b.addActionListener(this);

    add(okbutton);
    setSize(300, 85);
    setVisible(true);
  }
  /**
   * Method declaration
   *
   * @param ev
   */
  public void actionPerformed(ActionEvent ev) {

    String s = ev.getActionCommand();

    if (s == null) {
      if (ev.getSource() instanceof MenuItem) {
        MenuItem i;

        s = ((MenuItem) ev.getSource()).getLabel();
      }
    }

    if (s.equals("Execute")) {
      execute();
    } else if (s.equals("Exit")) {
      windowClosing(null);
    } else if (s.equals("Transfer")) {
      Transfer.work(null);
    } else if (s.equals("Dump")) {
      Transfer.work(new String[] {"-d"});

      /* NB - 26052002 Restore is not implemented yet in the transfer tool */
      /*
              } else if (s.equals("Restore")) {
                  Transfer.work(new String[]{"-r"});
      */
    } else if (s.equals("Logging on")) {
      jdbcSystem.setLogToSystem(true);
    } else if (s.equals("Logging off")) {
      jdbcSystem.setLogToSystem(false);
    } else if (s.equals("Refresh Tree")) {
      refreshTree();
    } else if (s.startsWith("#")) {
      int i = Integer.parseInt(s.substring(1));

      txtCommand.setText(sRecent[i]);
    } else if (s.equals("Connect...")) {
      connect(ConnectionDialog.createConnection(fMain, "Connect"));
      refreshTree();
    } else if (s.equals("Results in Grid")) {
      iResult = 0;

      pResult.removeAll();
      pResult.add("Center", gResult);
      pResult.doLayout();
    } else if (s.equals("Open Script...")) {
      FileDialog f = new FileDialog(fMain, "Open Script", FileDialog.LOAD);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        txtCommand.setText(DatabaseManagerCommon.readFile(f.getDirectory() + file));
      }
    } else if (s.equals("Save Script...")) {
      FileDialog f = new FileDialog(fMain, "Save Script", FileDialog.SAVE);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtCommand.getText());
      }
    } else if (s.equals("Save Result...")) {
      FileDialog f = new FileDialog(fMain, "Save Result", FileDialog.SAVE);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        showResultInText();
        DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtResult.getText());
      }
    } else if (s.equals("Results in Text")) {
      iResult = 1;

      pResult.removeAll();
      pResult.add("Center", txtResult);
      pResult.doLayout();
      showResultInText();
    } else if (s.equals("AutoCommit on")) {
      try {
        cConn.setAutoCommit(true);
      } catch (SQLException e) {
      }
    } else if (s.equals("AutoCommit off")) {
      try {
        cConn.setAutoCommit(false);
      } catch (SQLException e) {
      }
    } else if (s.equals("Enlarge Tree")) {
      Dimension d = tTree.getMinimumSize();

      d.width += 20;

      tTree.setMinimumSize(d);
      fMain.pack();
    } else if (s.equals("Shrink Tree")) {
      Dimension d = tTree.getMinimumSize();

      d.width -= 20;

      if (d.width >= 0) {
        tTree.setMinimumSize(d);
      }

      fMain.pack();
    } else if (s.equals("Enlarge Command")) {
      txtCommand.setRows(txtCommand.getRows() + 1);
      fMain.pack();
    } else if (s.equals("Shrink Command")) {
      int i = txtCommand.getRows() - 1;

      txtCommand.setRows(i < 1 ? 1 : i);
      fMain.pack();
    } else if (s.equals("Commit")) {
      try {
        cConn.commit();
      } catch (SQLException e) {
      }
    } else if (s.equals("Insert test data")) {
      insertTestData();
    } else if (s.equals("Rollback")) {
      try {
        cConn.rollback();
      } catch (SQLException e) {
      }
    } else if (s.equals("Disable MaxRows")) {
      try {
        sStatement.setMaxRows(0);
      } catch (SQLException e) {
      }
    } else if (s.equals("Set MaxRows to 100")) {
      try {
        sStatement.setMaxRows(100);
      } catch (SQLException e) {
      }
    } else if (s.equals("SELECT")) {
      showHelp(DatabaseManagerCommon.selectHelp);
    } else if (s.equals("INSERT")) {
      showHelp(DatabaseManagerCommon.insertHelp);
    } else if (s.equals("UPDATE")) {
      showHelp(DatabaseManagerCommon.updateHelp);
    } else if (s.equals("DELETE")) {
      showHelp(DatabaseManagerCommon.deleteHelp);
    } else if (s.equals("CREATE TABLE")) {
      showHelp(DatabaseManagerCommon.createTableHelp);
    } else if (s.equals("DROP TABLE")) {
      showHelp(DatabaseManagerCommon.dropTableHelp);
    } else if (s.equals("CREATE INDEX")) {
      showHelp(DatabaseManagerCommon.createIndexHelp);
    } else if (s.equals("DROP INDEX")) {
      showHelp(DatabaseManagerCommon.dropIndexHelp);
    } else if (s.equals("CHECKPOINT")) {
      showHelp(DatabaseManagerCommon.checkpointHelp);
    } else if (s.equals("SCRIPT")) {
      showHelp(DatabaseManagerCommon.scriptHelp);
    } else if (s.equals("SHUTDOWN")) {
      showHelp(DatabaseManagerCommon.shutdownHelp);
    } else if (s.equals("SET")) {
      showHelp(DatabaseManagerCommon.setHelp);
    } else if (s.equals("Test Script")) {
      showHelp(DatabaseManagerCommon.testHelp);
    }
  }
示例#7
0
  /**
   * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is
   * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ.
   */
  public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    if ((mode & DEBUG) != 0) IJ.setDebugMode(true);
    mode = mode & 255;
    if (IJ.debugMode) IJ.log("ImageJ starting in debug mode: " + mode);
    embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW);
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    setBackground(backgroundColor);
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new BorderLayout());

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add("Center", toolbar);

    // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new JLabel();
    statusLine.setFont(new Font("SansSerif", Font.PLAIN, 13));
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    add("South", statusBar);

    IJ.init(this, applet);
    addKeyListener(this);
    addWindowListener(this);
    setFocusTraversalKeysEnabled(false);
    m.installStartupMacroSet(); // add custom tools
    runStartupMacro();

    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (mode != NO_SHOW) {
      if (IJ.isWindows())
        try {
          setIcon();
        } catch (Exception e) {
        }
      setLocation(loc.x, loc.y);
      setResizable(!IJ.isMacOSX());
      pack();
      setVisible(true);
    }
    if (err1 != null) IJ.error(err1);
    if (err2 != null) {
      IJ.error(err2);
      IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    if (IJ.isMacintosh() && applet == null) {
      Object qh = null;
      qh = IJ.runPlugIn("MacAdapter", "");
      if (qh == null) IJ.runPlugIn("QuitHandler", "");
    }
    if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    String str = m.getMacroCount() == 1 ? " macro" : " macros";
    IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str);
    configureProxy();
    if (applet == null) loadCursors();
  }
示例#8
0
 private void addEnterOneValue(Panel p, String one) {
   p.add(new Label("Enter value for Dimension " + one));
   TextField dim1 = new TextField(8);
   p.add(dim1);
 }
示例#9
0
  public NslDimValue(
      NslFrame nsl_display_frame,
      String var_sel_full_name,
      NslVariableInfo var_sel_info,
      String plot_type_name,
      boolean replace_canvas) {
    super(nsl_display_frame, "Enter Values", true);

    /* these variables are needed in the action method */
    this.nsl_display_frame = nsl_display_frame;
    this.var_sel_full_name = var_sel_full_name;
    this.var_sel_info = var_sel_info;
    this.plot_type_name = plot_type_name;
    this.replace_canvas = replace_canvas;

    num_dims = (var_sel_info.getCountDimensions());

    if ((num_dims == 0) || (num_dims == 1) || (num_dims == 2) || (num_dims >= 4)) {
      System.err.println("Error: NslDimValue: should not have gotten here in the code.");
      return;
    }

    Panel p = new Panel();
    if (num_dims == 3) {
      if (NslDimInput.dim_choice.equals("HI")) {
        addEnterOneValue(p, "J");
      } else if (NslDimInput.dim_choice.equals("HJ")) {
        addEnterOneValue(p, "I");
      } else if (NslDimInput.dim_choice.equals("IJ")) {
        addEnterOneValue(p, "H");
      } else {
        System.err.println("Error: NslDimVal: bad input choice.");
        dispose();
        return;
      }
    } // end if (num_dims==3)
    else if (num_dims == 4) {
      if (NslDimInput.dim_choice.equals("GH")) {
        addEnterTwoValues(p, "I", "J");
      } else if (NslDimInput.dim_choice.equals("GI")) {
        addEnterTwoValues(p, "H", "J");
      } else if (NslDimInput.dim_choice.equals("GJ")) {
        addEnterTwoValues(p, "H", "I");
      } else if (NslDimInput.dim_choice.equals("HI")) {
        addEnterTwoValues(p, "G", "J");
      } else if (NslDimInput.dim_choice.equals("HJ")) {
        addEnterTwoValues(p, "G", "I");
      } else if (NslDimInput.dim_choice.equals("IJ")) {
        addEnterTwoValues(p, "G", "H");
      } else {
        System.err.println("Error: NslDimVal:bad input choice");
        dispose();
        return;
      }
    } // end if (num_dims==4)

    add("Center", p);

    Button b;
    Panel p4 = new Panel();
    p4.setLayout(new GridLayout(1, 5));
    p4.add(b = new Button("<Back"));
    b.addActionListener(this);
    p4.add(new Label(""));
    p4.add(b = new Button("Cancel"));
    b.addActionListener(this);
    p4.add(new Label(""));
    p4.add(b = new Button("Next>"));
    b.addActionListener(this);
    add("South", p4);
    setSize(450, 180);
  } // end constructor
示例#10
0
  /**
   * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is
   * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ.
   */
  public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW);
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    if (IJ.isLinux()) {
      backgroundColor = new Color(240, 240, 240);
      setBackground(backgroundColor);
    }
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new GridLayout(2, 1));

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add(toolbar);

    // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new Label();
    statusLine.setFont(SansSerif12);
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    statusBar.setSize(toolbar.getPreferredSize());
    add(statusBar);

    IJ.init(this, applet);
    addKeyListener(this);
    addWindowListener(this);
    setFocusTraversalKeysEnabled(false);

    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    int ijWidth = tbSize.width + 10;
    int ijHeight = 100;
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (mode != NO_SHOW) {
      if (IJ.isWindows())
        try {
          setIcon();
        } catch (Exception e) {
        }
      setBounds(loc.x, loc.y, ijWidth, ijHeight); // needed for pack to work
      setLocation(loc.x, loc.y);
      pack();
      setResizable(!(IJ.isMacintosh() || IJ.isWindows())); // make resizable on Linux
      show();
    }
    if (err1 != null) IJ.error(err1);
    if (err2 != null) {
      IJ.error(err2);
      IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    m.installStartupMacroSet();
    if (IJ.isMacintosh() && applet == null) {
      Object qh = null;
      qh = IJ.runPlugIn("MacAdapter", "");
      if (qh == null) IJ.runPlugIn("QuitHandler", "");
    }
    if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    String str = m.getMacroCount() == 1 ? " macro" : " macros";
    IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str);
    // if (applet==null && !embedded && Prefs.runSocketListener)
    //	new SocketListener();
    configureProxy();
    if (applet == null) loadCursors();
  }
示例#11
0
    public BandAdjuster() {

      super("Threshold Colour");
      if (instance != null) {
        instance.toFront();
        return;
      }
      imp = WindowManager.getCurrentImage();
      if (imp == null) {
        IJ.beep();
        IJ.showStatus("No image");
        return;
      }
      IJ.run("Select None");
      thread = new Thread(this, "BandAdjuster");
      WindowManager.addWindow(this);
      instance = this;
      IJ.register(PasteController.class);

      ij = IJ.getInstance();
      Font font = new Font("SansSerif", Font.PLAIN, 10);
      GridBagLayout gridbag = new GridBagLayout();
      GridBagConstraints c = new GridBagConstraints();
      setLayout(gridbag);

      int y = 0;
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      labelh = new Label("Hue", Label.CENTER);
      add(labelh, c);

      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(7, 0, 0, 0);
      labelf = new Label("Filter type", Label.RIGHT);
      add(labelf, c);

      // plot
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(plot, c);

      // checkboxes
      panelh = new Panel();
      filterTypeH = new CheckboxGroup();
      bandPassH = new Checkbox("Pass");
      bandPassH.setCheckboxGroup(filterTypeH);
      bandPassH.addItemListener(this);
      panelh.add(bandPassH);
      bandStopH = new Checkbox("Stop");
      bandStopH.setCheckboxGroup(filterTypeH);
      bandStopH.addItemListener(this);
      panelh.add(bandStopH);
      bandPassH.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panelh, c);

      // minHue slider
      minSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);

      add(minSlider, c);
      minSlider.addAdjustmentListener(this);
      minSlider.setUnitIncrement(1);

      // minHue slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label1 = new Label("       ", Label.LEFT);
      label1.setFont(font);
      add(label1, c);

      // maxHue sliderHue
      maxSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider, c);
      maxSlider.addAdjustmentListener(this);
      maxSlider.setUnitIncrement(1);

      // maxHue slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.gridy = y++;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label2 = new Label("       ", Label.LEFT);
      label2.setFont(font);
      add(label2, c);

      // =====
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(10, 0, 0, 0);
      labels = new Label("Saturation", Label.CENTER);
      add(labels, c);

      // plot
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(splot, c);

      // checkboxes
      panels = new Panel();
      filterTypeS = new CheckboxGroup();
      bandPassS = new Checkbox("Pass");
      bandPassS.setCheckboxGroup(filterTypeS);
      bandPassS.addItemListener(this);
      panels.add(bandPassS);
      bandStopS = new Checkbox("Stop");
      bandStopS.setCheckboxGroup(filterTypeS);
      bandStopS.addItemListener(this);
      panels.add(bandStopS);
      bandPassS.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panels, c);

      // minSat slider
      minSlider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);
      add(minSlider2, c);
      minSlider2.addAdjustmentListener(this);
      minSlider2.setUnitIncrement(1);

      // minSat slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label3 = new Label("       ", Label.LEFT);
      label3.setFont(font);
      add(label3, c);

      // maxSat slider
      maxSlider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider2, c);
      maxSlider2.addAdjustmentListener(this);
      maxSlider2.setUnitIncrement(1);

      // maxSat slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label4 = new Label("       ", Label.LEFT);
      label4.setFont(font);
      add(label4, c);

      // =====
      c.gridx = 0;
      c.gridwidth = 1;
      c.gridy = y++;
      c.weightx = 0;
      c.insets = new Insets(10, 0, 0, 0);
      labelb = new Label("Brightness", Label.CENTER);
      add(labelb, c);

      c.gridx = 0;
      c.gridwidth = 1;
      c.gridy = y;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(bplot, c);

      // checkboxes
      panelb = new Panel();
      filterTypeB = new CheckboxGroup();
      bandPassB = new Checkbox("Pass");
      bandPassB.setCheckboxGroup(filterTypeB);
      bandPassB.addItemListener(this);
      panelb.add(bandPassB);
      bandStopB = new Checkbox("Stop");
      bandStopB.setCheckboxGroup(filterTypeB);
      bandStopB.addItemListener(this);
      panelb.add(bandStopB);
      bandPassB.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panelb, c);

      // minBri slider
      minSlider3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);
      add(minSlider3, c);
      minSlider3.addAdjustmentListener(this);
      minSlider3.setUnitIncrement(1);

      // minBri slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label5 = new Label("       ", Label.LEFT);
      label5.setFont(font);
      add(label5, c);

      // maxBri slider
      maxSlider3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider3, c);
      maxSlider3.addAdjustmentListener(this);
      maxSlider3.setUnitIncrement(1);

      // maxBri slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label6 = new Label("       ", Label.LEFT);
      label6.setFont(font);
      add(label6, c);

      // =====
      panelt = new Panel();
      threshold = new Checkbox("Threshold");
      threshold.addItemListener(this);
      panelt.add(threshold);

      invert = new Checkbox("Invert");
      invert.addItemListener(this);
      panelt.add(invert);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panelt, c);

      // buttons
      panel = new Panel();
      // panel.setLayout(new GridLayout(2, 2, 0, 0));
      originalB = new Button("Original");
      originalB.setEnabled(false);
      originalB.addActionListener(this);
      originalB.addKeyListener(ij);
      panel.add(originalB);

      filteredB = new Button("Filtered");
      filteredB.setEnabled(false);
      filteredB.addActionListener(this);
      filteredB.addKeyListener(ij);
      panel.add(filteredB);

      stackB = new Button("Stack");
      stackB.addActionListener(this);
      stackB.addKeyListener(ij);
      panel.add(stackB);

      helpB = new Button("Help");
      helpB.addActionListener(this);
      helpB.addKeyListener(ij);
      panel.add(helpB);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panel, c);

      panelMode = new Panel();

      sampleB = new Button("Sample");
      sampleB.addActionListener(this);
      sampleB.addKeyListener(ij);
      panelMode.add(sampleB);

      colourMode = new CheckboxGroup();
      hsb = new Checkbox("HSB");
      hsb.setCheckboxGroup(colourMode);
      hsb.addItemListener(this);
      panelMode.add(hsb);
      hsb.setState(true);
      rgb = new Checkbox("RGB");
      rgb.setCheckboxGroup(colourMode);
      rgb.addItemListener(this);
      panelMode.add(rgb);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panelMode, c);

      addKeyListener(ij); // ImageJ handles keyboard shortcuts
      pack();
      GUI.center(this);
      setVisible(true);

      ip = setup(imp);
      if (ip == null) {
        imp.unlock();
        IJ.beep();
        IJ.showStatus("RGB image cannot be thresholded");
        return;
      }
      thread.start();
    }