/** Demo. */
 public static void main(String[] args) {
   try {
     JFrame frame = new JFrame("Panner");
     JPanel p = (JPanel) frame.getContentPane();
     URL url = PannerHandler.class.getResource("desert.jpg");
     String key =
         System.getProperty("os.name").toLowerCase().indexOf("mac") != -1 ? "\u2318" : "control";
     JLabel label =
         new JLabel("Press " + key + "+shift to display panner, click/drag to navigate");
     label.setBorder(new EmptyBorder(4, 4, 4, 4));
     p.add(label, BorderLayout.NORTH);
     JLabel image = new JLabel(new ImageIcon(url));
     image.setFocusable(true);
     PannerHandler handler = new PannerHandler(image, 95, new Point(0, 0));
     image.putClientProperty("panner", handler);
     p.add(new JScrollPane(image));
     frame.pack();
     Dimension size = image.getPreferredSize();
     size.width /= 2;
     size.height /= 2;
     Dimension ssize = frame.getToolkit().getScreenSize();
     frame.setLocation((ssize.width - size.width) / 2, (ssize.height - size.height) / 2);
     frame.setSize(size);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     frame.setVisible(true);
     image.requestFocus();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#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
  /**
   * This method initializes this
   *
   * @return void
   */
  @SuppressWarnings("unchecked")
  private void initialize() {
    cliente = Cliente.getInstancia();
    cliente.comunicar(Comando.OBTENER_CURSO_PROFESOR, ControladorLogin.getIdProfesor());
    cursos = (ArrayList<Curso>) cliente.recibir();
    cliente.comunicar(Comando.OBTENER_MATERIA_POR_PROFESOR, ControladorLogin.getIdProfesor());
    materias = (ArrayList<Materia>) cliente.recibir();
    lblNombreProfesor = new JLabel();
    lblNombreProfesor.setFocusable(false);
    lblNombreProfesor.setBorder(null);
    lblNombreProfesor.setHorizontalAlignment(SwingConstants.CENTER);
    lblNombreProfesor.setBounds(new Rectangle(1, 23, 688, 23));
    lblNombreProfesor.setText("Nombre del Profesor");
    lblNombreProfesor.setText(PantallaPrincipalProfesor.getNombre());
    lblTitulo = new JLabel();
    lblTitulo.setBounds(new Rectangle(1, 0, 688, 18));
    lblTitulo.setHorizontalAlignment(SwingConstants.CENTER);
    lblTitulo.setText("Notas");
    lblTitulo.setForeground(Color.WHITE);
    lblTitulo.setOpaque(true);
    lblTitulo.setBackground(new Color(72, 129, 191));
    lblTitulo.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    lblPeriodo = new JLabel();
    lblPeriodo.setBounds(new Rectangle(373, 88, 48, 23));
    lblPeriodo.setText("Periodo:");
    lblCurso = new JLabel();
    lblCurso.setBounds(new Rectangle(373, 59, 48, 23));
    lblCurso.setText("Curso:");
    lblAsignatura = new JLabel();

    lblAsignatura.setBounds(new Rectangle(9, 59, 73, 23));
    lblAsignatura.setText("Asignatura:");
    this.setSize(690, 463);
    this.setLayout(null);
    this.add(lblAsignatura, null);
    this.add(getCmbMateria(), null);
    this.add(lblCurso, null);
    this.add(getCmbCurso(), null);
    this.add(lblPeriodo, null);
    this.add(getCmbPeriodo(), null);
    this.add(lblTitulo, null);
    this.add(lblNombreProfesor, null);
    this.add(getJspListaNota(), null);
    this.add(getBtnGenerarNota(), null);
  }
  public EmailAailable() {
    setLayout(new GridLayout(2, 1));
    add(label);
    add(field);
    label.setFocusable(true);
    field.setForeground(Color.LIGHT_GRAY);

    field.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            for (String s : stringEmails) {
              if (field.getText().equals(s)) {
                new Dialog("Email already exist");
                return;
              }
            }
            new Dialog("You create new email");
          }
        });

    field.addFocusListener(
        new FocusListener() {

          @Override
          public void focusGained(FocusEvent e) {
            field.setFocusable(true);
            field.setText("");
            field.setForeground(Color.BLACK);
          }

          @Override
          public void focusLost(FocusEvent e) {}
        });

    setTitle("Edit email");
    setSize(400, 120);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);
  }
示例#5
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;
 }
    private OneLineComponent() {
      super(new GridBagLayout());

      myLabel.setOpaque(true);
      myLabel.setFont(NORMAL_FONT);
      if (myRequestFocus) myLabel.setFocusable(true);

      add(
          myLabel,
          new GridBagConstraints(
              0,
              0,
              1,
              1,
              1,
              1,
              GridBagConstraints.WEST,
              GridBagConstraints.NONE,
              new Insets(0, 0, 0, 0),
              0,
              0));
    }
  @Override
  protected javax.swing.JLabel createAwtComponent() {
    javax.swing.JLabel rv =
        new javax.swing.JLabel() {
          @Override
          public void addNotify() {
            super.addNotify();
            this.getRootPane().setDefaultButton(null);
            this.requestFocusInWindow();
            this.addKeyListener(keyListener);
          }

          @Override
          public void removeNotify() {
            this.removeKeyListener(keyListener);
            super.removeNotify();
          }
        };
    rv.setFocusable(true);
    rv.setFocusTraversalKeysEnabled(false);
    rv.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    return rv;
  }
 public XFInputDialogField(
     String fieldCaption, String inputType, String parmID, XFInputDialog dialog) {
   super();
   parmID_ = parmID;
   if (!inputType.equals("ALPHA")
       && !inputType.equals("KANJI")
       && !inputType.equals("NUMERIC")
       && !inputType.equals("DATE")
       && !inputType.equals("LISTBOX")
       && !inputType.equals("CHECKBOX")) {
     inputType_ = "ALPHA";
   }
   inputType_ = inputType;
   dialog_ = dialog;
   jLabelField.setText(fieldCaption + " ");
   jLabelField.setFocusable(false);
   jLabelField.setHorizontalAlignment(SwingConstants.RIGHT);
   jLabelField.setVerticalAlignment(SwingConstants.TOP);
   jLabelField.setFont(new java.awt.Font("Dialog", 0, 14));
   metrics = jLabelField.getFontMetrics(new java.awt.Font("Dialog", 0, 14));
   jLabelField.setPreferredSize(new Dimension(120, XFUtility.FIELD_UNIT_HEIGHT));
   if (metrics.stringWidth(fieldCaption) > 120) {
     jLabelField.setFont(new java.awt.Font("Dialog", 0, 12));
     metrics = jLabelField.getFontMetrics(new java.awt.Font("Dialog", 0, 12));
     if (metrics.stringWidth(fieldCaption) > 120) {
       jLabelField.setFont(new java.awt.Font("Dialog", 0, 10));
     }
   }
   if (inputType_.equals("ALPHA") || inputType_.equals("KANJI") || inputType_.equals("NUMERIC")) {
     JTextField field = new JTextField();
     field.addFocusListener(new ComponentFocusListener());
     if (inputType_.equals("NUMERIC")) {
       field.setHorizontalAlignment(SwingConstants.RIGHT);
       field.setDocument(new LimitedDocument(this));
     }
     component = field;
   }
   if (inputType_.equals("DATE")) {
     XFDateField field = new XFDateField(dialog_.getSession());
     component = field;
   }
   if (inputType_.equals("LISTBOX")) {
     JComboBox field = new JComboBox();
     component = field;
   }
   if (inputType_.equals("CHECKBOX")) {
     JCheckBox field = new JCheckBox();
     component = field;
   }
   component.setFont(new java.awt.Font("Monospaced", 0, 14));
   metrics = component.getFontMetrics(new java.awt.Font("Monospaced", 0, 14));
   this.setOpaque(false);
   if (inputType_.equals("DATE")) {
     int fieldWidth = XFUtility.getWidthOfDateValue(dialog_.getSession().getDateFormat(), 14);
     this.setBounds(
         this.getBounds().x, this.getBounds().y, 150 + fieldWidth, XFUtility.FIELD_UNIT_HEIGHT);
   } else {
     this.setBounds(this.getBounds().x, this.getBounds().y, 150, XFUtility.FIELD_UNIT_HEIGHT);
   }
   this.setLayout(new BorderLayout());
   this.add(jLabelField, BorderLayout.WEST);
   this.add(component, BorderLayout.CENTER);
 }
示例#9
0
  /** Create the panel. */
  public LC3View() {
    setLayout(null);

    JPanel panel = new JPanel();
    panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
    panel.setBounds(31, 29, 192, 229);
    add(panel);
    panel.setLayout(null);

    r0 = new JTextField();
    r0.setHorizontalAlignment(SwingConstants.CENTER);
    r0.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    r0.setEditable(false);
    r0.setFocusable(false);
    r0.setBounds(46, 10, 70, 26);
    panel.add(r0);
    r0.setColumns(10);

    JLabel lblR = new JLabel("R0");
    lblR.setFocusable(false);
    lblR.setBounds(21, 16, 25, 16);
    panel.add(lblR);

    r2 = new JTextField();
    r2.setHorizontalAlignment(SwingConstants.CENTER);
    r2.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    r2.setEditable(false);
    r2.setFocusable(false);
    r2.setColumns(10);
    r2.setBounds(46, 62, 70, 26);
    panel.add(r2);

    JLabel lblR_2 = new JLabel("R2");
    lblR_2.setFocusable(false);
    lblR_2.setBounds(21, 68, 25, 16);
    panel.add(lblR_2);

    r1 = new JTextField();
    r1.setHorizontalAlignment(SwingConstants.CENTER);
    r1.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    r1.setEditable(false);
    r1.setFocusable(false);
    r1.setColumns(10);
    r1.setBounds(46, 36, 70, 26);
    panel.add(r1);

    JLabel lblR_1 = new JLabel("R1");
    lblR_1.setFocusable(false);
    lblR_1.setBounds(21, 42, 25, 16);
    panel.add(lblR_1);

    r3 = new JTextField();
    r3.setHorizontalAlignment(SwingConstants.CENTER);
    r3.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    r3.setEditable(false);
    r3.setFocusable(false);
    r3.setColumns(10);
    r3.setBounds(46, 88, 70, 26);
    panel.add(r3);

    JLabel lblR_3 = new JLabel("R3");
    lblR_3.setFocusable(false);
    lblR_3.setBounds(21, 94, 25, 16);
    panel.add(lblR_3);

    r4 = new JTextField();
    r4.setHorizontalAlignment(SwingConstants.CENTER);
    r4.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    r4.setEditable(false);
    r4.setFocusable(false);
    r4.setColumns(10);
    r4.setBounds(46, 114, 70, 26);
    panel.add(r4);

    JLabel lblR_4 = new JLabel("R4");
    lblR_4.setFocusable(false);
    lblR_4.setBounds(21, 120, 25, 16);
    panel.add(lblR_4);

    r5 = new JTextField();
    r5.setHorizontalAlignment(SwingConstants.CENTER);
    r5.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    r5.setEditable(false);
    r5.setFocusable(false);
    r5.setColumns(10);
    r5.setBounds(46, 140, 70, 26);
    panel.add(r5);

    JLabel lblR_5 = new JLabel("R5");
    lblR_5.setFocusable(false);
    lblR_5.setBounds(21, 146, 25, 16);
    panel.add(lblR_5);

    r6 = new JTextField();
    r6.setHorizontalAlignment(SwingConstants.CENTER);
    r6.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    r6.setEditable(false);
    r6.setFocusable(false);
    r6.setColumns(10);
    r6.setBounds(46, 166, 70, 26);
    panel.add(r6);

    JLabel lblR_6 = new JLabel("R6");
    lblR_6.setFocusable(false);
    lblR_6.setBounds(21, 172, 25, 16);
    panel.add(lblR_6);

    r7 = new JTextField();
    r7.setHorizontalAlignment(SwingConstants.CENTER);
    r7.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    r7.setEditable(false);
    r7.setFocusable(false);
    r7.setColumns(10);
    r7.setBounds(46, 192, 70, 26);
    panel.add(r7);

    JLabel lblR_7 = new JLabel("R7");
    lblR_7.setFocusable(false);
    lblR_7.setBounds(21, 198, 25, 16);
    panel.add(lblR_7);

    d0 = new JTextField();
    d0.setText("0");
    d0.setHorizontalAlignment(SwingConstants.RIGHT);
    d0.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    d0.setFocusable(false);
    d0.setEditable(false);
    d0.setColumns(10);
    d0.setBounds(118, 10, 62, 26);
    panel.add(d0);

    d1 = new JTextField();
    d1.setText("0");
    d1.setHorizontalAlignment(SwingConstants.RIGHT);
    d1.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    d1.setFocusable(false);
    d1.setEditable(false);
    d1.setColumns(10);
    d1.setBounds(118, 36, 62, 26);
    panel.add(d1);

    d2 = new JTextField();
    d2.setText("0");
    d2.setHorizontalAlignment(SwingConstants.RIGHT);
    d2.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    d2.setFocusable(false);
    d2.setEditable(false);
    d2.setColumns(10);
    d2.setBounds(118, 62, 62, 26);
    panel.add(d2);

    d3 = new JTextField();
    d3.setText("0");
    d3.setHorizontalAlignment(SwingConstants.RIGHT);
    d3.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    d3.setFocusable(false);
    d3.setEditable(false);
    d3.setColumns(10);
    d3.setBounds(118, 88, 62, 26);
    panel.add(d3);

    d4 = new JTextField();
    d4.setText("0");
    d4.setHorizontalAlignment(SwingConstants.RIGHT);
    d4.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    d4.setFocusable(false);
    d4.setEditable(false);
    d4.setColumns(10);
    d4.setBounds(118, 114, 62, 26);
    panel.add(d4);

    d5 = new JTextField();
    d5.setText("0");
    d5.setHorizontalAlignment(SwingConstants.RIGHT);
    d5.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    d5.setFocusable(false);
    d5.setEditable(false);
    d5.setColumns(10);
    d5.setBounds(118, 140, 62, 26);
    panel.add(d5);

    d6 = new JTextField();
    d6.setText("0");
    d6.setHorizontalAlignment(SwingConstants.RIGHT);
    d6.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    d6.setFocusable(false);
    d6.setEditable(false);
    d6.setColumns(10);
    d6.setBounds(118, 166, 62, 26);
    panel.add(d6);

    d7 = new JTextField();
    d7.setText("0");
    d7.setHorizontalAlignment(SwingConstants.RIGHT);
    d7.setFont(new Font("Lucida Grande", Font.PLAIN, 13));
    d7.setFocusable(false);
    d7.setEditable(false);
    d7.setColumns(10);
    d7.setBounds(118, 192, 62, 26);
    panel.add(d7);

    JButton btnReset = new JButton("Reset");
    btnReset.setFocusable(false);
    btnReset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            machine.reset();
            console.setText("");
            update();
          }
        });
    btnReset.setBounds(55, 369, 99, 29);
    add(btnReset);

    btnStep = new JButton("Step");
    btnStep.setFocusable(false);
    btnStep.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            machine.step();
            update();
          }
        });
    btnStep.setBounds(9, 400, 99, 29);
    add(btnStep);

    btnStepOver = new JButton("Step Over");
    btnStepOver.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            status.setText("running...");
            memView.select(0, 0);
            btnStep.setEnabled(false);
            btnStepOver.setEnabled(false);
            btnRun.setEnabled(false);
            btnStop.setEnabled(true);
            machine.stepOver();
          }
        });
    btnStepOver.setBounds(104, 400, 92, 29);
    add(btnStepOver);

    btnRun = new JButton("Run");
    btnRun.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            status.setText("running...");
            memView.select(0, 0);
            btnStep.setEnabled(false);
            btnStepOver.setEnabled(false);
            btnRun.setEnabled(false);
            btnStop.setEnabled(true);
            machine.run();
          }
        });
    btnRun.setBounds(9, 432, 99, 29);
    add(btnRun);

    btnStop = new JButton("Stop");
    btnStop.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            machine.stop();
          }
        });
    btnStop.setBounds(104, 432, 99, 29);
    add(btnStop);

    JScrollPane memScroll = new JScrollPane();
    memScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    memScroll.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
    memScroll.setBounds(235, 29, 421, 485);
    add(memScroll);

    memView = new JTextArea();
    memView.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {
            if (e.getClickCount() == 2) {
              int line = getLine(memView.getText(), memView.getCaretPosition());
              machine.toggleBreakPnt(line);
            }
            update();
          }
        });
    memView.setEditable(false);
    memView.setFont(new Font("Courier New", Font.PLAIN, 13));
    memScroll.setViewportView(memView);

    JLabel lblStatus = new JLabel("Status:");
    lblStatus.setBounds(17, 541, 50, 16);
    add(lblStatus);

    status = new JTextField();
    status.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
    status.setBounds(67, 536, 589, 26);
    add(status);
    status.setColumns(10);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
    panel_1.setBounds(31, 270, 123, 71);
    add(panel_1);
    panel_1.setLayout(null);

    cbNeg = new JCheckBox("Neg");
    cbNeg.setFocusable(false);
    cbNeg.setBounds(28, 6, 57, 23);
    panel_1.add(cbNeg);

    cbZero = new JCheckBox("Zero");
    cbZero.setFocusable(false);
    cbZero.setSelected(true);
    cbZero.setBounds(28, 25, 60, 23);
    panel_1.add(cbZero);

    cbPos = new JCheckBox("Pos");
    cbPos.setFocusable(false);
    cbPos.setBounds(28, 43, 54, 23);
    panel_1.add(cbPos);

    JButton btnLoadProgram = new JButton("Load Program");
    btnLoadProgram.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            JFileChooser fileChooser = new JFileChooser();
            if (currentDir != null) fileChooser.setCurrentDirectory(currentDir);
            fileChooser.setFileFilter(
                new FileNameExtensionFilter("Prolog Files", new String[] {"lc3"}));
            if (fileChooser.showOpenDialog(memView) == JFileChooser.APPROVE_OPTION) {
              File file = fileChooser.getSelectedFile();
              try {
                machine.loadProgram(file.getAbsolutePath());
                update();
                JFrame frame =
                    (JFrame)
                        memView
                            .getParent()
                            .getParent()
                            .getParent()
                            .getParent()
                            .getParent()
                            .getParent()
                            .getParent();
                frame.setTitle("LC3 Simulator    " + machine.programName());
                currentDir = file.getParentFile();
              } catch (Exception error) {
              }
            }
          }
        });
    btnLoadProgram.setBounds(48, 473, 117, 29);
    add(btnLoadProgram);

    console = new JTextArea();
    console.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {
            memView.setCaretPosition(console.getText().length());
          }
        });
    console.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            e.consume();
            machine.consoleNewChar(c);
          }

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyChar() == '\n') e.consume();
          }
        });
    console.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
    console.setBounds(69, 574, 589, 145);
    add(console);

    JLabel lblConsole = new JLabel("Console:");
    lblConsole.setBounds(9, 574, 58, 16);
    add(lblConsole);

    machine = new LC3(this);
    update();
  }
示例#10
0
 public void setJLabel(JLabel jlb) {
   jlb.setOpaque(false);
   jlb.setBorder(null);
   jlb.setFocusable(false);
   jlb.addMouseListener(new ButtonListener());
 }
  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;
  }
 private JLabel createLabel(String name) {
   JLabel label = new JLabel(name);
   label.setFocusable(false);
   label.setFont(new Font(label.getFont().getFamily(), Font.PLAIN, label.getFont().getSize()));
   return label;
 }
  public RegexpPropertyDialog(
      final Collection<String> items, String predefinedRegexp, String description) {
    super(
        ApplicationFrame.getApplicationFrame(),
        "parameter.regexp",
        ModalityType.APPLICATION_MODAL,
        new Object[] {});
    this.items = items;
    this.supportsItems = items != null;
    this.infoText =
        "<html>"
            + I18N.getMessage(I18N.getGUIBundle(), getKey() + ".title")
            + ": <br/>"
            + description
            + "</html>";
    Dimension size = new Dimension(420, 500);
    this.setMinimumSize(size);
    this.setPreferredSize(size);

    JPanel panel = new JPanel(createGridLayout(1, supportsItems ? 2 : 1));

    // create regexp text field
    regexpTextField = new JTextField(predefinedRegexp);
    regexpTextField.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.tip"));
    regexpTextField.addKeyListener(
        new KeyListener() {

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            fireRegularExpressionUpdated();
          }

          @Override
          public void keyTyped(KeyEvent e) {}
        });
    regexpTextField.requestFocus();

    // create replacement text field
    replacementTextField = new JTextField();
    replacementTextField.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.tip"));
    replacementTextField.addKeyListener(
        new KeyListener() {

          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            fireRegularExpressionUpdated();
          }

          @Override
          public void keyTyped(KeyEvent e) {}
        });

    // create inline search documents
    inlineSearchDocument = new RegexpSearchStyledDocument();
    inlineReplaceDocument = new RegexpReplaceStyledDocument();

    // create search results list
    DefaultListCellRenderer resultCellRenderer =
        new DefaultListCellRenderer() {

          private static final long serialVersionUID = 1L;

          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            setBackground(list.getBackground());
            setForeground(list.getForeground());
            setBorder(getNoFocusBorder());
            return this;
          }

          private Border getNoFocusBorder() {
            Border border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray);
            return border;
          }
        };

    JList<RegExpResult> regexpFindingsList = new JList<RegExpResult>(resultsListModel);
    regexpFindingsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    regexpFindingsList.setLayoutOrientation(JList.VERTICAL);
    regexpFindingsList.setCellRenderer(resultCellRenderer);

    // regexp panel on left side of dialog
    JPanel regexpPanel = new JPanel(new GridBagLayout());
    regexpPanel.setBorder(
        createTitledBorder(
            I18N.getMessage(
                I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.border")));
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(4, 4, 4, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    regexpPanel.add(regexpTextField, c);

    // make shortcut button
    final Action nullAction = new DefaultAction();
    PlainArrowDropDownButton autoWireDropDownButton =
        PlainArrowDropDownButton.makeDropDownButton(nullAction);

    for (String[] popupItem : (String[][]) ArrayUtils.addAll(regexpConstructs, regexpShortcuts)) {
      String shortcut =
          popupItem[0].length() > 14 ? popupItem[0].substring(0, 14) + "..." : popupItem[0];
      autoWireDropDownButton.add(
          new InsertionAction(
              "<html><table border=0 cellpadding=0 cellspacing=0><tr><td width=100>"
                  + shortcut
                  + "</td><td>"
                  + popupItem[1]
                  + "</td></tr></table></html>",
              popupItem[0]));
    }
    c.insets = new Insets(4, 0, 4, 0);
    c.gridx = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    regexpPanel.add(autoWireDropDownButton.getDropDownArrowButton(), c);

    // make delete button
    c.insets = new Insets(4, 0, 4, 4);
    c.gridx = 2;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    JButton clearRegexpTextFieldButton = new JButton(SwingTools.createIcon("16/delete2.png"));
    clearRegexpTextFieldButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            regexpTextField.setText("");
            fireRegularExpressionUpdated();
            regexpTextField.requestFocusInWindow();
          }
        });

    regexpPanel.add(clearRegexpTextFieldButton, c);

    errorMessage = new JLabel(NO_ERROR_MESSAGE, NO_ERROR_ICON, SwingConstants.LEFT);
    errorMessage.setFocusable(false);
    c.insets = new Insets(4, 8, 4, 4);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    regexpPanel.add(errorMessage, c);

    // create replacement panel
    JPanel replacementPanel = new JPanel(new GridBagLayout());
    replacementPanel.setBorder(
        createTitledBorder(
            I18N.getMessage(
                I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.border")));

    JPanel testerPanel = new JPanel(new GridBagLayout());

    c.insets = new Insets(4, 4, 4, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    replacementPanel.add(replacementTextField, c);

    // create inline search panel
    JPanel inlineSearchPanel = new JPanel(new GridBagLayout());

    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    inlineSearchPanel.add(
        new JLabel(
            I18N.getMessage(
                I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.search")),
        c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    inlineSearchPanel.add(new JScrollPane(new JTextPane(inlineSearchDocument)), c);

    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    inlineSearchPanel.add(
        new JLabel(
            I18N.getMessage(
                I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.replaced")),
        c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    JTextPane replaceTextPane = new JTextPane(inlineReplaceDocument);
    replaceTextPane.setEditable(false);
    inlineSearchPanel.add(new JScrollPane(replaceTextPane), c);

    // create regexp options panel
    ItemListener defaultOptionListener =
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            fireRegexpOptionsChanged();
          }
        };

    cbCaseInsensitive =
        new JCheckBox(
            I18N.getMessage(
                I18N.getGUIBundle(),
                "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive"));
    cbCaseInsensitive.setToolTipText(
        I18N.getMessage(
            I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive.tip"));
    cbCaseInsensitive.addItemListener(defaultOptionListener);

    cbMultiline =
        new JCheckBox(
            I18N.getMessage(
                I18N.getGUIBundle(),
                "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode"));
    cbMultiline.setToolTipText(
        I18N.getMessage(
            I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode.tip"));
    cbMultiline.addItemListener(defaultOptionListener);

    cbDotall =
        new JCheckBox(
            I18N.getMessage(
                I18N.getGUIBundle(),
                "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode"));
    cbDotall.setToolTipText(
        I18N.getMessage(
            I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode.tip"));
    cbDotall.addItemListener(defaultOptionListener);

    cbUnicodeCase =
        new JCheckBox(
            I18N.getMessage(
                I18N.getGUIBundle(),
                "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case"));
    cbUnicodeCase.setToolTipText(
        I18N.getMessage(
            I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case.tip"));
    cbUnicodeCase.addItemListener(defaultOptionListener);

    JPanel regexpOptionsPanelWrapper = new JPanel(new BorderLayout());
    JPanel regexpOptionsPanel = new JPanel(new GridBagLayout());
    regexpOptionsPanelWrapper.add(regexpOptionsPanel, BorderLayout.NORTH);

    c.insets = new Insets(12, 4, 0, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    regexpOptionsPanel.add(cbMultiline, c);
    c.insets = new Insets(8, 4, 0, 4);
    c.gridy = 1;
    regexpOptionsPanel.add(cbCaseInsensitive, c);
    c.gridy = 2;
    regexpOptionsPanel.add(cbUnicodeCase, c);
    c.gridy = 3;
    regexpOptionsPanel.add(cbDotall, c);

    // create tabbed panel
    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    testExp = new JTabbedPane();
    testExp.add(
        I18N.getMessage(
            I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.inline_search.title"),
        new JScrollPane(inlineSearchPanel));
    testExp.add(
        I18N.getMessage(
            I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.result_list.title"),
        new JScrollPane(regexpFindingsList));
    testExp.add(
        I18N.getMessage(
            I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.title"),
        regexpOptionsPanelWrapper);
    testerPanel.add(testExp, c);

    JPanel groupPanel = new JPanel(new GridBagLayout());
    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    groupPanel.add(regexpPanel, c);

    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    groupPanel.add(replacementPanel, c);

    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    groupPanel.add(testerPanel, c);

    panel.add(groupPanel, 1, 0);

    if (supportsItems) {
      // item shortcuts list
      itemShortcutsList = new JList<String>(items.toArray(new String[items.size()]));
      itemShortcutsList.setToolTipText(
          I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.tip"));
      itemShortcutsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      itemShortcutsList.addMouseListener(
          new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
              if (e.getClickCount() == 2) {
                String text = regexpTextField.getText();
                int cursorPosition = regexpTextField.getCaretPosition();
                int index = itemShortcutsList.getSelectedIndex();
                if (index > -1 && index < itemShortcutsList.getModel().getSize()) {
                  String insertionString =
                      itemShortcutsList.getModel().getElementAt(index).toString();
                  String newText =
                      text.substring(0, cursorPosition)
                          + insertionString
                          + (cursorPosition < text.length() ? text.substring(cursorPosition) : "");
                  regexpTextField.setText(newText);
                  regexpTextField.setCaretPosition(cursorPosition + insertionString.length());
                  regexpTextField.requestFocus();
                  fireRegularExpressionUpdated();
                }
              }
            }

            @Override
            public void mouseEntered(MouseEvent e) {}

            @Override
            public void mouseExited(MouseEvent e) {}

            @Override
            public void mousePressed(MouseEvent e) {}

            @Override
            public void mouseReleased(MouseEvent e) {}
          });
      JScrollPane itemShortcutsPane = new JScrollPane(itemShortcutsList);
      itemShortcutsPane.setBorder(
          createTitledBorder(
              I18N.getMessage(
                  I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.border")));

      // matched items list
      matchedItemsListModel = new DefaultListModel<String>();
      JList<String> matchedItemsList = new JList<String>(matchedItemsListModel);
      matchedItemsList.setToolTipText(
          I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.tip"));
      // add custom cell renderer to disallow selections
      matchedItemsList.setCellRenderer(
          new DefaultListCellRenderer() {

            private static final long serialVersionUID = -5795848004756768378L;

            @Override
            public Component getListCellRendererComponent(
                JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
              return super.getListCellRendererComponent(list, value, index, false, false);
            }
          });
      JScrollPane matchedItemsPanel = new JScrollPane(matchedItemsList);
      matchedItemsPanel.setBorder(
          createTitledBorder(
              I18N.getMessage(
                  I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.border")));

      // item panel on right side of dialog
      JPanel itemPanel = new JPanel(createGridLayout(1, 2));
      itemPanel.add(itemShortcutsPane, 0, 0);
      itemPanel.add(matchedItemsPanel, 0, 1);

      panel.add(itemPanel, 0, 1);
    }

    okButton = makeOkButton("regexp_property_dialog_apply");
    fireRegularExpressionUpdated();

    layoutDefault(panel, supportsItems ? NORMAL : NARROW, okButton, makeCancelButton());
  }