示例#1
0
    @Override
    public void actionPerformed(ActionEvent e) {
      Frame frame = getFrame();
      JFileChooser chooser = new JFileChooser();
      int ret = chooser.showOpenDialog(frame);

      if (ret != JFileChooser.APPROVE_OPTION) {
        return;
      }

      File f = chooser.getSelectedFile();
      if (f.isFile() && f.canRead()) {
        Document oldDoc = getEditor().getDocument();
        if (oldDoc != null) {
          oldDoc.removeUndoableEditListener(undoHandler);
        }
        if (elementTreePanel != null) {
          elementTreePanel.setEditor(null);
        }
        getEditor().setDocument(new PlainDocument());
        frame.setTitle(f.getName());
        Thread loader = new FileLoader(f, editor.getDocument());
        loader.start();
      } else {
        JOptionPane.showMessageDialog(
            getFrame(),
            "Could not open file: " + f,
            "Error opening file",
            JOptionPane.ERROR_MESSAGE);
      }
    }
示例#2
0
 private boolean ignoreArrowKeys(ImagePlus imp) {
   Frame frame = WindowManager.getFrontWindow();
   String title = frame.getTitle();
   if (title != null && title.equals("ROI Manager")) return true;
   // Control Panel?
   if (frame != null && frame instanceof javax.swing.JFrame) return true;
   ImageWindow win = imp.getWindow();
   // LOCI Data Browser window?
   if (imp.getStackSize() > 1 && win != null && win.getClass().getName().startsWith("loci"))
     return true;
   return false;
 }
示例#3
0
    public void actionPerformed(ActionEvent e) {
      Frame frame = getFrame();
      JFileChooser chooser = new JFileChooser();
      int ret = chooser.showSaveDialog(frame);

      if (ret != JFileChooser.APPROVE_OPTION) {
        return;
      }

      File f = chooser.getSelectedFile();
      frame.setTitle(f.getName());
      Thread saver = new FileSaver(f, editor.getDocument());
      saver.start();
    }
示例#4
0
 void saveWindowLocations() {
   Frame frame = WindowManager.getFrame("B&C");
   if (frame != null) Prefs.saveLocation(ContrastAdjuster.LOC_KEY, frame.getLocation());
   frame = WindowManager.getFrame("Threshold");
   if (frame != null) Prefs.saveLocation(ThresholdAdjuster.LOC_KEY, frame.getLocation());
   frame = WindowManager.getFrame("Results");
   if (frame != null) {
     Prefs.saveLocation(TextWindow.LOC_KEY, frame.getLocation());
     Dimension d = frame.getSize();
     Prefs.set(TextWindow.WIDTH_KEY, d.width);
     Prefs.set(TextWindow.HEIGHT_KEY, d.height);
   }
   frame = WindowManager.getFrame("Log");
   if (frame != null) {
     Prefs.saveLocation(TextWindow.LOG_LOC_KEY, frame.getLocation());
     Dimension d = frame.getSize();
     Prefs.set(TextWindow.LOG_WIDTH_KEY, d.width);
     Prefs.set(TextWindow.LOG_HEIGHT_KEY, d.height);
   }
 }
示例#5
0
  void addEvent() {
    mainFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    addressTextField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();

            if (keyCode == KeyEvent.VK_ENTER) {
              showContent();
            }
          }
        });

    gotoButton.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();

            if (keyCode == KeyEvent.VK_ENTER) {
              showContent();
            }
          }
        });

    gotoButton.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            showContent();
          }
        });
  }
示例#6
0
  void init() {
    mainFrame = new Frame();
    mainFrame.setBounds(400, 500, 800, 600);
    mainFrame.setLayout(new FlowLayout());
    mainFrame.setResizable(false);

    upPanel = new Panel();
    downPanel = new Panel();
    addressTextField = new TextField(75);
    gotoButton = new Button("转到");
    contentTextArea = new TextArea(30, 82);

    upPanel.add(addressTextField);
    upPanel.add(gotoButton);
    downPanel.add(contentTextArea);

    mainFrame.add(upPanel);
    mainFrame.add(downPanel);

    addEvent();

    mainFrame.setVisible(true);
  }
示例#7
0
 public void paint(Graphics g) {
   super.paint(g);
   if (notrunning) {
     notrunning = false;
   } // end of if
 }
 public void run() {
   frame.setVisible(true);
 }
示例#9
0
  RootWindow(Container container, Screen screen, Format[] format, Client c) {
    super(screen.rootId);
    rootwindow = container;
    client = c;
    screen.setRoot((Window) this);
    this.width = (short) (screen.width);
    this.height = (short) (screen.height);
    this.screen = screen;
    depth = screen.rootDepth;
    id = screen.rootId;
    type = DRAWABLE_WINDOW;
    x = y = 0;
    origin.x = 0;
    origin.y = 0;
    clss = (byte) InputOutput;
    for (int i = 0; i < format.length; i++) {
      if (format[i].depth == screen.rootDepth) {
        this.bitsPerPixel = format[i].bpp;
      }
    }
    setVisual(screen.rootVisual);
    setBackgroundIsPixel();
    background.pixel = screen.white;

    setBorderIsPixel();
    border.pixel = screen.black;
    borderWidth = 0;
    Resource.add(this);
    makeOptional();
    attr &= ~(1 << 3); // cursorIsNone

    optional.cursor = Cursor.rootCursor;
    setColormap(screen.defaultColormap);

    //  if(rootwindow instanceof JFrame){
    //    rootwindow.setSize(this.width+10, this.height+30); // ??
    //  }
    //  else{
    rootwindow.setSize(this.width, this.height);
    //  }

    try {
      ddxwindow = (DDXWindow) (Window.dDXWindow.newInstance());
    } catch (Exception e) {
      System.err.println(e);
      /*ddxwindow=new DDXWindowImp();*/
    }

    ddxwindow.init(this);
    ddxwindow.setLocation(0, 0);

    if (rootwindow instanceof Frame) {
      // ((Frame)rootwindow).setLayout(null);
      ((Frame) rootwindow).setResizable(false);
      ((Frame) rootwindow).setMenuBar(null);
      ((Frame) rootwindow).add((java.awt.Component) ddxwindow);
    } else if (rootwindow instanceof Applet) {
      ((Applet) rootwindow).add((java.awt.Component) ddxwindow);
    }
    /*
        else if(rootwindow instanceof JFrame){
          ((JFrame)rootwindow).getContentPane().setLayout(null);
          ((JFrame)rootwindow).setResizable(false);
          ((JFrame)rootwindow).setJMenuBar(null);
          ((JFrame)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
        else if(rootwindow instanceof JWindow){
          ((JWindow)rootwindow).getContentPane().setLayout(null);
          ((JWindow)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
        else if (rootwindow instanceof JApplet){
          ((JApplet)rootwindow).setJMenuBar(null);
          ((JApplet)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
    */
    else {
      rootwindow.add((java.awt.Component) ddxwindow);
    }

    if (screen.windowmode != WeirdX.InBrowser) {
      rootwindow.addNotify();
    } else {
      rootwindow.setVisible(true);
    }
    ddxwindow.setVisible(true);

    {
      rootwindow.validate();
      Insets insets = rootwindow.getInsets();
      rootwindow.setSize(
          this.width + insets.left + insets.right, this.height + insets.top + insets.bottom);
      ddxwindow.setLocation(insets.left, insets.top);
      rootwindow.validate();
    }

    ddxwindow.requestFocus();
    Window.focus.win = id;

    Window.LOCK = rootwindow.getTreeLock();
    Client.LOCK = rootwindow.getTreeLock();
    Resource.LOCK = rootwindow.getTreeLock();

    spriteTrace[0] = this;
    sprite.win = this;
  }