public void addKeyListener(KeyListener kl) {
    super.addKeyListener(kl);

    m_titleLabel.addKeyListener(kl);
    m_southPanel.addKeyListener(kl);
    m_inputPanel.addKeyListener(kl);
    m_responsePanel.addKeyListener(kl);
  }
예제 #2
0
 /**
  * 创建一个文本标签
  *
  * @param strElement 显示的字符
  * @return 新创建的文本标签
  */
 private JLabel createElement(String strElement) {
   JLabel lblElement = new JLabel(strElement);
   if (!strElement.isEmpty()) {
     lblElement.setHorizontalAlignment(SwingConstants.CENTER);
     lblElement.setFocusable(true); // 设置标签可以获得焦点
     lblElement.setOpaque(true); // 设置标签可以绘制背景
     lblElement.setBorder(this.etchedBorder);
     lblElement.setBackground(Color.WHITE);
     lblElement.addKeyListener(this.keyAdapter);
     lblElement.addFocusListener(this);
     lblElement.addMouseListener(this.mouseAdapter);
   }
   return lblElement;
 }
예제 #3
0
 /**
  * 创建一个文本标签
  *
  * @param strElement 显示的字符
  * @param isSpecial 是否为特殊格式
  * @return 新创建的文本标签
  */
 private JLabel createElement(String strElement, boolean isSpecial) {
   JLabel lblElement = null;
   if (isSpecial) {
     lblElement =
         new JLabel(Util.SIGN_IDENTIFIER_NAMES[Util.IDENTIFIER_CHARS.indexOf(strElement)]);
   } else {
     lblElement = new JLabel(strElement);
     lblElement.setFont(Util.SIGN_VIEW_FONT);
   }
   if (!strElement.isEmpty()) {
     lblElement.setHorizontalAlignment(SwingConstants.CENTER);
     lblElement.setFocusable(true); // 设置标签可以获得焦点
     lblElement.setOpaque(true); // 设置标签可以绘制背景
     lblElement.setBorder(this.etchedBorder);
     lblElement.setBackground(Color.WHITE);
     lblElement.addKeyListener(this.keyAdapter);
     lblElement.addFocusListener(this);
     lblElement.addMouseListener(this.mouseAdapter);
   }
   return lblElement;
 }
예제 #4
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();
  }
예제 #5
0
  private JLabel crearJLabel(final int pI, final int pJ, String pNum) {
    Font fuente;

    fuente = new Font("Monospaced", Font.BOLD, 20);

    final JLabel j = new JLabel();
    j.setText(pNum + "");
    j.setFont(fuente);
    j.setBackground(Color.green);
    j.setHorizontalAlignment(WIDTH / 2);
    j.setBorder(LineBorder.createBlackLineBorder());
    j.setFocusable(true);
    if (tab.esValorInicial(pI, pJ)) {
      j.setForeground(Color.red);
    } else {

      j.addKeyListener(keyListener);
    }
    MouseListener mouseListener1 =
        new MouseListener() {

          public void mouseClicked(MouseEvent e) {}

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {
            if (!tab.esValorInicial(pI, pJ)) {
              if (j.getBackground() != Color.green) {
                desactivar();
                j.setBackground(Color.green);
                j.setOpaque(true);
                activado[0] = pI;
                activado[1] = pJ;
              } else {
                if (!j.isOpaque()) {
                  desactivar();
                  j.setBackground(Color.green);
                  j.setOpaque(true);
                  activado[0] = pI;
                  activado[1] = pJ;
                } else {
                  j.setOpaque(false);
                  activado[0] = -1;
                  activado[1] = -1;
                }
              }
            } else {
              activado[0] = -1;
              activado[1] = -1;
              desactivar();
            }
            todosLosNumeros(tab.obtValorCasilla(pI, pJ));
            j.updateUI();
          }

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}
        };

    j.addMouseListener(mouseListener1);
    return j;
  }