Пример #1
0
 public NodeSelectionDialog(Frame owner, NodeLibrary library, NodeLibraryManager manager) {
   super(owner, "New Node", true);
   getRootPane().putClientProperty("Window.style", "small");
   JPanel panel = new JPanel(new BorderLayout());
   this.library = library;
   this.manager = manager;
   filteredNodeListModel = new FilteredNodeListModel(library, manager);
   searchField = new JTextField();
   searchField.putClientProperty("JTextField.variant", "search");
   EscapeListener escapeListener = new EscapeListener();
   searchField.addKeyListener(escapeListener);
   ArrowKeysListener arrowKeysListener = new ArrowKeysListener();
   searchField.addKeyListener(arrowKeysListener);
   SearchFieldChangeListener searchFieldChangeListener = new SearchFieldChangeListener();
   searchField.getDocument().addDocumentListener(searchFieldChangeListener);
   nodeList = new JList(filteredNodeListModel);
   DoubleClickListener doubleClickListener = new DoubleClickListener();
   nodeList.addMouseListener(doubleClickListener);
   nodeList.addKeyListener(escapeListener);
   nodeList.addKeyListener(arrowKeysListener);
   nodeList.setSelectedIndex(0);
   nodeList.setCellRenderer(new NodeRenderer());
   JScrollPane nodeScroll =
       new JScrollPane(
           nodeList,
           JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
           JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
   nodeScroll.setBorder(null);
   panel.add(searchField, BorderLayout.NORTH);
   panel.add(nodeScroll, BorderLayout.CENTER);
   setContentPane(panel);
   setSize(500, 400);
   SwingUtils.centerOnScreen(this);
 }
Пример #2
0
  public void addFields() {
    //		gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.ipadx = 20;
    content.add(new JLabel("Host", JLabel.CENTER), gbc);
    gbc.gridy++;
    content.add(new JLabel("Database", JLabel.CENTER), gbc);
    gbc.gridy++;
    content.add(new JLabel("Table", JLabel.CENTER), gbc);
    gbc.gridy++;
    content.add(new JLabel("Username", JLabel.CENTER), gbc);
    gbc.gridy++;
    content.add(new JLabel("Password", JLabel.CENTER), gbc);
    gbc.gridy = 0;
    gbc.gridx = 1;
    content.add(host, gbc);
    gbc.gridy++;
    content.add(database, gbc);
    gbc.gridy++;
    content.add(table, gbc);
    gbc.gridy++;
    content.add(username, gbc);
    gbc.gridy++;
    content.add(password, gbc);
    gbc.gridy++;
    login.setMnemonic(KeyEvent.VK_L);

    ActionListener act =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (e.getSource() == login) {
              if (username.getText().length() > 0) alive = false;
              else {
                showMessage("Username required", "At least enter a username :)");
              }
            }
            if (e.getSource() == exit) {
              System.exit(0);
            }
          }
        };

    login.addActionListener(act);
    exit.addActionListener(act);
    JPanel p = new JPanel(new FlowLayout());
    p.add(login);
    p.add(exit);

    gbc.gridx = 0;
    gbc.gridwidth = 2;
    content.add(p, gbc);

    username.addKeyListener(this);
    password.addKeyListener(this);
    login.addKeyListener(this);
  }
Пример #3
0
 /**
  * Add the correct key listeners to the search text field, depending on whether and autocomplete
  * listener has been set and whether incremental search is selected.
  */
 private void updateKeyListeners() {
   KeyListener[] listeners = searchField.getKeyListeners();
   for (KeyListener listener : listeners) {
     searchField.removeKeyListener(listener);
   }
   if (increment.isSelected()) {
     searchField.addKeyListener(this);
   } else {
     if (searchAutoComplete.isSelected() && (autoCompleteListener != null)) {
       searchField.addKeyListener(autoCompleteListener);
     }
   }
 }
Пример #4
0
 public void setHook() {
   ComboBoxEditor anEditor = this.getEditor();
   if (anEditor.getEditorComponent() instanceof JTextField) {
     editor = (JTextField) anEditor.getEditorComponent();
     editor.setColumns(TXT_FILENAME_LENGTH);
     editor.addKeyListener(
         new KeyAdapter() {
           public void keyReleased(KeyEvent ev) {
             char key = ev.getKeyChar();
             if (!(Character.isLetterOrDigit(key) || Character.isSpaceChar(key))) {
               return;
             }
             caretPos = editor.getCaretPosition();
             String text = "";
             try {
               text = editor.getText(0, caretPos);
             } catch (Exception ex) {
               Debug.error(me + "setHook: Problem getting image file name\n%s", ex.getMessage());
             }
             int n = getItemCount();
             for (int i = 0; i < n; i++) {
               int ind = ((String) getItemAt(i)).indexOf(text);
               if (ind == 0) {
                 setSelectedIndex(i);
                 return;
               }
             }
           }
         });
   }
 }
Пример #5
0
  private void setupInputListeners(final JTextField currentInput) {
    currentInput.addKeyListener(
        new KeyAdapter() {
          // Plot the graph.

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER && currentInput.isFocusOwner()) {
              try {
                String[] equations = new String[nInputs];
                for (int i = 0; i < nInputs; i++) {
                  equations[i] = input[i].getText();
                }
                addPlot(
                    equations,
                    templateFunc.getColor(),
                    gridOP.getGridBounds(),
                    gridOP.getGridStepSize());
              } catch (IllegalExpressionException e1) {
                signalAll(new ActionEvent(e1, -1, ""));
              }
            }
          }
        });
    currentInput.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent arg0) {
            setSelected(templateFunc);
          }
        });
  }
Пример #6
0
  private void repaintContent() {
    if (content != null) {
      remove(content);
    }
    content = new JPanel();

    content.setLayout(new GridBagLayout());
    content.setBackground(Colors.TEMPLATE);
    int gridY = 0;
    GridBagConstraints c;
    for (Parameter p : shownParams.getParamList()) {
      c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = gridY;
      c.anchor = GridBagConstraints.WEST;
      c.fill = GridBagConstraints.NONE;
      c.insets = new Insets(0, 0, 0, 8);
      content.add(new JLabel(p.getName()), c);

      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = gridY++;
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1;
      final Parameter pFinal = p;
      final JTextField jTextField = new DJTextField();
      jTextField.setText(p.getValue());
      jTextField.addKeyListener(
          new KeyListener() {
            public void keyTyped(KeyEvent keyEvent) {
              // TODO
            }

            public void keyPressed(KeyEvent keyEvent) {
              // TODO
            }

            public void keyReleased(KeyEvent keyEvent) {
              pFinal.setValue(jTextField.getText());
            }
          });
      content.add(jTextField, c);
    }

    GridBagConstraints nc = new GridBagConstraints();
    nc.gridx = 0;
    nc.gridy = 0;
    nc.weightx = 1;
    nc.fill = GridBagConstraints.HORIZONTAL;

    add(content, nc);

    content.updateUI();
    content.repaint();
    this.repaint();
  }
Пример #7
0
  public GalaxyViewer(Settings settings, boolean animatorFrame) throws Exception {
    super("Stars GalaxyViewer");
    this.settings = settings;
    this.animatorFrame = animatorFrame;
    if (settings.gameName.equals("")) throw new Exception("GameName not defined in settings.");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    File dir = new File(settings.directory);
    File map = new File(dir, settings.getGameName() + ".MAP");
    if (map.exists() == false) {
      File f = new File(dir.getParentFile(), settings.getGameName() + ".MAP");
      if (f.exists()) map = f;
      else {
        String error = "Could not find " + map.getAbsolutePath() + "\n";
        error += "Export this file from Stars! (Only needs to be done one time pr game)";
        throw new Exception(error);
      }
    }
    Vector<File> mFiles = new Vector<File>();
    Vector<File> hFiles = new Vector<File>();
    for (File f : dir.listFiles()) {
      if (f.getName().toUpperCase().endsWith("MAP")) continue;
      if (f.getName().toUpperCase().endsWith("HST")) continue;
      if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".M")) mFiles.addElement(f);
      else if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".H"))
        hFiles.addElement(f);
    }
    if (mFiles.size() == 0) throw new Exception("No M-files found matching game name.");
    if (hFiles.size() == 0) throw new Exception("No H-files found matching game name.");
    parseMapFile(map);
    Vector<File> files = new Vector<File>();
    files.addAll(mFiles);
    files.addAll(hFiles);
    p = new Parser(files);
    calculateColors();

    // UI:
    JPanel cp = (JPanel) getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(universe, BorderLayout.CENTER);
    JPanel south = createPanel(0, hw, new JLabel("Search: "), search, names, zoom, colorize);
    search.setPreferredSize(new Dimension(100, -1));
    cp.add(south, BorderLayout.SOUTH);
    hw.addActionListener(this);
    names.addActionListener(this);
    zoom.addChangeListener(this);
    search.addKeyListener(this);
    colorize.addActionListener(this);
    setSize(800, 600);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2);
    setVisible(animatorFrame == false);
    if (animatorFrame) names.setSelected(false);
  }
 private void createSearchTextFieldListeners() {
   searchTextField.addKeyListener(
       new KeyAdapter() {
         @Override
         @SuppressWarnings("unchecked")
         public void keyReleased(KeyEvent anEvent) {
           String text = ((JTextField) anEvent.getSource()).getText();
           List<Classroom> res = department.getClassroomsDepartment().searchClassroomByName(text);
           ((ReadOnlyTableModel<Classroom>) classroomsTable.getModel()).setModel(res);
         }
       });
 }
Пример #9
0
  public SearchDialogPanel(OWLEditorKit editorKit) {
    this.editorKit = editorKit;
    setLayout(new BorderLayout());
    searchField = new AugmentedJTextField("Enter search string");
    searchPanel = new SearchPanel(editorKit);
    add(searchField, BorderLayout.NORTH);
    add(searchPanel, BorderLayout.CENTER);

    searchField.addKeyListener(
        new KeyAdapter() {
          public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              selectEntity();
            }
          }

          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_UP) {
              searchPanel.moveSelectionUp();
              e.consume();
            }
            if (e.getKeyCode() == KeyEvent.VK_DOWN) {
              searchPanel.moveSelectionDown();
              e.consume();
            }
          }
        });
    searchField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {}

              public void insertUpdate(DocumentEvent e) {
                performSearch();
              }

              public void removeUpdate(DocumentEvent e) {
                performSearch();
              }
            });
    searchPanel.setSearchResultClickedListener(
        new SearchResultClickedListener() {
          @Override
          public void handleSearchResultClicked(SearchResult searchResult, MouseEvent e) {
            if (e.getClickCount() == 2) {
              selectEntity();
            }
          }
        });
  }
Пример #10
0
  public void addComponentsToPane() {

    testfield = new JTextField("", 33);
    testfield.addKeyListener(this);

    testtextarea = new TextArea(buffer, 15, 33, TextArea.SCROLLBARS_VERTICAL_ONLY);
    testtextarea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(testtextarea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(600, 200));

    getContentPane().add(testfield, BorderLayout.PAGE_END);
    getContentPane().add(testtextarea, BorderLayout.CENTER);
  }
Пример #11
0
  private void initComponents() {

    btLogin.setFocusable(false); // Fókusz letiltása
    btSettings.setFocusable(false); // Fókusz letiltása

    btLogin.setBackground(Color.lightGray); // A "bejelentkezés" gomb háttérszínének beállítása
    btSettings.setBackground(
        pnLogin.getBackground()); // A "Beállítások" gomb háttérszínének beállítása

    tfUsername.setPreferredSize(new Dimension(120, 25)); // Szövegmező átméretezése
    pfPassword.setPreferredSize(new Dimension(120, 25)); // Jelszómező átméretezése

    tfUsername.addKeyListener(btEnabler); // A figyelő hozzáadása a felhasználónév mezőhőz
    pfPassword.addKeyListener(btEnabler); // A figyelő hozzáadása a jelszó mezőhőz
  }
Пример #12
0
  private void jbInit() throws Exception {
    // this.setResizable(false);
    this.setSize(ancho, alto);
    this.setLocation(0, 0);

    // this.setUndecorated(true);
    // this.getContentPane().setLayout(null);

    // limites de componentes
    labelFondo.setBounds(
        new Rectangle((int) (ancho / 5), 2 * (alto / 6), (int) (ancho / 1.5), alto / 4));
    botonCancelar.setBounds(
        new Rectangle(
            (int) (2.9 * (ancho / 5)), (int) (2 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonCancelar.setBorder(null);
    // botonAceptar.setBounds(new Rectangle(0, 0, 100, 30));
    botonAceptar.setBounds(
        new Rectangle(
            (int) (2.15 * (ancho / 5)), (int) (2 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonAceptar.setBorder(null);
    textNombre.setFont(new java.awt.Font("Serif", 3, 15));
    textNombre.setBounds(
        new Rectangle((int) (2.5 * (ancho / 5)), (int) (1.5 * (alto / 4)), ancho / 5, alto / 25));
    textNombre.addKeyListener(new PanelNick_textNombre_keyAdapter(this));

    textContra.setFont(new java.awt.Font("Serif", 3, 15));
    textContra.setBounds(
        new Rectangle(
            (int) (2.9 * (ancho / 5)), (int) (1.65 * (alto / 4)) + 20, ancho / 8, alto / 25));

    // imagenes de componentes
    labelFondo.setIcon(new ImageIcon("../imagenes/introduceNick.jpg"));
    botonCancelar.setIcon(new ImageIcon("../imagenes/botoncancelar.jpg"));
    botonCancelar.addMouseListener(new PanelNick_botonCancelar_mouseAdapter(this));
    botonAceptar.setIcon(new ImageIcon("../imagenes/botonaceptar.jpg"));
    botonAceptar.addMouseListener(new PanelNick_botonAceptar_mouseAdapter(this));

    // agregar componentes al panel
    this.add(textContra, null);
    this.add(botonCancelar, null);
    this.add(botonAceptar, null);
    this.add(textNombre, null);
    this.add(labelFondo, null);

    // acciones de botones
    botonAceptar.addActionListener(new PanelNick_botonAceptar_actionAdapter(this));
    botonCancelar.addActionListener(new PanelNick_botonCancelar_actionAdapter(this));
  }
Пример #13
0
  public void init() {
    Container contentPane = f.getContentPane();
    JPanel p = new JPanel();
    // 將兩個元件及 JPanel 加入 JFrame
    contentPane.add(degree, "North");
    contentPane.add(p, "Center");
    contentPane.add(go, "South");

    // 將 JPanel 設定為使用 GridLayout (4 列、2 行)
    p.setLayout(new GridLayout(4, 2));
    // 將各元件加到 JPanel 中
    p.add(deg);
    p.add(rad);
    p.add(sinlab);
    p.add(sintxt);
    p.add(coslab);
    p.add(costxt);
    p.add(tanlab);
    p.add(tantxt);

    // 設定選擇角度單位的快捷鍵
    deg.setMnemonic(KeyEvent.VK_D);
    rad.setMnemonic(KeyEvent.VK_R);

    // 將兩個單選鈕設為一組
    ButtonGroup group = new ButtonGroup();
    group.add(deg);
    group.add(rad);
    deg.setSelected(true); // 將 deg 設為預設選取的項目

    go.addActionListener(this);
    degree.addKeyListener(this);

    // 單選鈕的選取事件之處理方法
    deg.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) convert = 180 / Math.PI;
            else convert = 1;
          }
        });

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(250, 200);
    f.setVisible(true);
  }
Пример #14
0
  public void startGui() {
    JTerminalListener listener = new JTerminalListener();

    jFrame = new JFrame("Glowstone");
    jTerminal = new JTerminal();
    jInput =
        new JTextField(80) {
          @Override
          public void setBorder(Border border) {}
        };
    jInput.paint(null);
    jInput.setFont(new Font("Monospaced", Font.PLAIN, 12));
    jInput.setBackground(Color.BLACK);
    jInput.setForeground(Color.WHITE);
    jInput.setMargin(new Insets(0, 0, 0, 0));
    jInput.addKeyListener(listener);

    JLabel caret = new JLabel("> ");
    caret.setFont(new Font("Monospaced", Font.PLAIN, 12));
    caret.setForeground(Color.WHITE);

    JPanel ipanel = new JPanel();
    ipanel.add(caret, BorderLayout.WEST);
    ipanel.add(jInput, BorderLayout.EAST);
    ipanel.setBorder(BorderFactory.createEmptyBorder());
    ipanel.setBackground(Color.BLACK);
    ipanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    ipanel.setSize(jTerminal.getWidth(), ipanel.getHeight());

    jFrame.getContentPane().add(jTerminal, BorderLayout.NORTH);
    jFrame.getContentPane().add(ipanel, BorderLayout.SOUTH);
    jFrame.addWindowListener(listener);
    jFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    jFrame.setLocationRelativeTo(null);
    jFrame.pack();
    jFrame.setVisible(true);

    sender = new ColoredCommandSender();
    logger.removeHandler(consoleHandler);
    logger.addHandler(
        new StreamHandler(new TerminalOutputStream(), new DateOutputFormatter(CONSOLE_DATE)));
  }
  private void setupEvents() {
    specifyUPB.addActionListener(specifyUPBListener);

    specifyLWB.addActionListener(specifyLWBListener);

    yesUPB.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (yesUPB.isSelected()) {
              specifyUPB.setVisible(true);
              UPBLabel.setVisible(specifyUPB.isSelected());
              UPBDetailPanel.setVisible(true);
            } else {
              if (yesCyclic.isSelected()) {
                specifyUPB.setVisible(true);
                yesUPB.setSelected(true);
                UPBDetailPanel.setVisible(true);
                UPBLabel.setVisible(specifyUPB.isSelected());
              } else {
                specifyUPB.setSelected(false);
                specifyUPB.setVisible(false);
                UPBLabel.setText("0");
                UPBLabel.setVisible(false);
                UPBDetailPanel.setVisible(false);
              }
            }
          }
        });

    yesLWB.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (yesLWB.isSelected()) {
              specifyLWB.setVisible(true);
              LWBLabel.setVisible(specifyLWB.isSelected());
              LWBDetailPanel.setVisible(true);
            } else {
              if (yesCyclic.isSelected()) {
                specifyLWB.setVisible(true);
                yesLWB.setSelected(true);
                LWBDetailPanel.setVisible(true);
                LWBLabel.setVisible(specifyLWB.isSelected());
              } else {
                specifyLWB.setSelected(false);
                specifyLWB.setVisible(false);
                LWBLabel.setText("0");
                LWBLabel.setVisible(false);
                LWBDetailPanel.setVisible(false);
              }
            }
          }
        });

    UPBLabel.addKeyListener(listener);

    LWBLabel.addKeyListener(listener);

    yesCyclic.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (yesCyclic.isSelected()) {
              specifyLWB.setVisible(true);
              yesLWB.setSelected(true);
              specifyUPB.setVisible(true);
              yesUPB.setSelected(true);
              LWBLabel.setVisible(specifyLWB.isSelected());
              UPBLabel.setVisible(specifyUPB.isSelected());
            }
          }
        });
  }
Пример #16
0
  public JComponent buildCommon() {
    String colSpec = FormLayoutUtil.getColSpec(COMMON_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, COMMON_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    maxbuffer = new JTextField("" + configuration.getMaxMemoryBufferSize());
    maxbuffer.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(maxbuffer.getText());
              configuration.setMaxMemoryBufferSize(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse max memory buffer size from \"" + maxbuffer.getText() + "\"");
            }
          }
        });

    JComponent cmp =
        builder.addSeparator(
            Messages.getString("NetworkTab.5"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("NetworkTab.6")
            .replaceAll("MAX_BUFFER_SIZE", configuration.getMaxMemoryBufferSizeStr()),
        FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation));
    builder.add(maxbuffer, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    String nCpusLabel =
        String.format(
            Messages.getString("NetworkTab.7"), Runtime.getRuntime().availableProcessors());
    builder.addLabel(nCpusLabel, FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation));

    String[] guiCores = new String[MAX_CORES];
    for (int i = 0; i < MAX_CORES; i++) {
      guiCores[i] = Integer.toString(i + 1);
    }
    nbcores = new JComboBox(guiCores);
    nbcores.setEditable(false);
    int nbConfCores = configuration.getNumberOfCpuCores();
    if (nbConfCores > 0 && nbConfCores <= MAX_CORES) {
      nbcores.setSelectedItem(Integer.toString(nbConfCores));
    } else {
      nbcores.setSelectedIndex(0);
    }

    nbcores.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setNumberOfCpuCores(Integer.parseInt(e.getItem().toString()));
          }
        });
    builder.add(nbcores, FormLayoutUtil.flip(cc.xy(3, 5), colSpec, orientation));

    chapter_interval = new JTextField("" + configuration.getChapterInterval());
    chapter_interval.setEnabled(configuration.isChapterSupport());
    chapter_interval.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(chapter_interval.getText());
              configuration.setChapterInterval(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse chapter interval from \"" + chapter_interval.getText() + "\"");
            }
          }
        });

    chapter_support = new JCheckBox(Messages.getString("TrTab2.52"));
    chapter_support.setContentAreaFilled(false);
    chapter_support.setSelected(configuration.isChapterSupport());

    chapter_support.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setChapterSupport((e.getStateChange() == ItemEvent.SELECTED));
            chapter_interval.setEnabled(configuration.isChapterSupport());
          }
        });

    builder.add(chapter_support, FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation));

    builder.add(chapter_interval, FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.3"),
            FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    channels =
        new JComboBox(
            new Object[] {
              Messages.getString("TrTab2.55"),
              Messages.getString("TrTab2.56") /*, "8 channels 7.1" */
            }); // 7.1 not supported by Mplayer :\
    channels.setEditable(false);
    if (configuration.getAudioChannelCount() == 2) {
      channels.setSelectedIndex(0);
    } else {
      channels.setSelectedIndex(1);
    }
    channels.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setAudioChannelCount(
                Integer.parseInt(e.getItem().toString().substring(0, 1)));
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.50"), FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));
    builder.add(channels, FormLayoutUtil.flip(cc.xy(3, 13), colSpec, orientation));

    forcePCM = new JCheckBox(Messages.getString("TrTab2.27"));
    forcePCM.setContentAreaFilled(false);
    if (configuration.isMencoderUsePcm()) {
      forcePCM.setSelected(true);
    }
    forcePCM.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderUsePcm(e.getStateChange() == ItemEvent.SELECTED);
          }
        });

    builder.add(forcePCM, FormLayoutUtil.flip(cc.xyw(1, 15, 3), colSpec, orientation));

    ac3remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.32")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    ac3remux.setContentAreaFilled(false);
    if (configuration.isRemuxAC3()) {
      ac3remux.setSelected(true);
    }
    ac3remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setRemuxAC3((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(ac3remux, FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation));

    forceDTSinPCM =
        new JCheckBox(
            Messages.getString("TrTab2.28")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    forceDTSinPCM.setContentAreaFilled(false);
    if (configuration.isDTSEmbedInPCM()) {
      forceDTSinPCM.setSelected(true);
    }
    forceDTSinPCM.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            configuration.setDTSEmbedInPCM(forceDTSinPCM.isSelected());
            if (configuration.isDTSEmbedInPCM()) {
              JOptionPane.showMessageDialog(
                  (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                  Messages.getString("TrTab2.10"),
                  "Information",
                  JOptionPane.INFORMATION_MESSAGE);
            }
          }
        });

    builder.add(forceDTSinPCM, FormLayoutUtil.flip(cc.xyw(1, 19, 3), colSpec, orientation));

    abitrate = new JTextField("" + configuration.getAudioBitrate());
    abitrate.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(abitrate.getText());
              configuration.setAudioBitrate(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug("Could not parse audio bitrate from \"" + abitrate.getText() + "\"");
            }
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.29"), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation));
    builder.add(abitrate, FormLayoutUtil.flip(cc.xy(3, 21), colSpec, orientation));

    mpeg2remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.39")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    mpeg2remux.setContentAreaFilled(false);
    if (configuration.isMencoderRemuxMPEG2()) {
      mpeg2remux.setSelected(true);
    }
    mpeg2remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderRemuxMPEG2((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(mpeg2remux, FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.4"),
            FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("TrTab2.32"),
        FormLayoutUtil.flip(cc.xyw(1, 29, 3), colSpec, orientation));

    Object data[] =
        new Object[] {
          configuration.getMencoderMainSettings(), /* default */
          String.format(
              "keyint=5:vqscale=1:vqmin=2  /* %s */", Messages.getString("TrTab2.60")), /* great */
          String.format(
              "keyint=5:vqscale=1:vqmin=1  /* %s */",
              Messages.getString("TrTab2.61")), /* lossless */
          String.format(
              "keyint=5:vqscale=2:vqmin=3  /* %s */",
              Messages.getString("TrTab2.62")), /* good (wired) */
          String.format(
              "keyint=25:vqmax=5:vqmin=2  /* %s */",
              Messages.getString("TrTab2.63")), /* good (wireless) */
          String.format(
              "keyint=25:vqmax=7:vqmin=2  /* %s */",
              Messages.getString("TrTab2.64")), /* medium (wireless) */
          String.format(
              "keyint=25:vqmax=8:vqmin=3  /* %s */", Messages.getString("TrTab2.65")) /* low */
        };

    MyComboBoxModel cbm = new MyComboBoxModel(data);

    vq = new JComboBox(cbm);
    vq.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String s = (String) e.getItem();
              if (s.indexOf("/*") > -1) {
                s = s.substring(0, s.indexOf("/*")).trim();
              }
              configuration.setMencoderMainSettings(s);
            }
          }
        });
    vq.getEditor()
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              @Override
              public void keyPressed(KeyEvent e) {}

              @Override
              public void keyTyped(KeyEvent e) {}

              @Override
              public void keyReleased(KeyEvent e) {
                vq.getItemListeners()[0].itemStateChanged(
                    new ItemEvent(vq, 0, vq.getEditor().getItem(), ItemEvent.SELECTED));
              }
            });
    vq.setEditable(true);
    builder.add(vq, FormLayoutUtil.flip(cc.xyw(1, 31, 3), colSpec, orientation));

    String help1 = Messages.getString("TrTab2.39");
    help1 += Messages.getString("TrTab2.40");
    help1 += Messages.getString("TrTab2.41");
    help1 += Messages.getString("TrTab2.42");
    help1 += Messages.getString("TrTab2.43");
    help1 += Messages.getString("TrTab2.44");

    JTextArea decodeTips = new JTextArea(help1);
    decodeTips.setEditable(false);
    decodeTips.setBorder(BorderFactory.createEtchedBorder());
    decodeTips.setBackground(new Color(255, 255, 192));
    builder.add(decodeTips, FormLayoutUtil.flip(cc.xyw(1, 41, 3), colSpec, orientation));

    disableSubs = new JCheckBox(Messages.getString("TrTab2.51"));
    disableSubs.setContentAreaFilled(false);

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.7"),
            FormLayoutUtil.flip(cc.xyw(1, 33, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.add(disableSubs, FormLayoutUtil.flip(cc.xy(1, 35), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.8"), FormLayoutUtil.flip(cc.xy(1, 37), colSpec, orientation));

    notranscode = new JTextField(configuration.getNoTranscode());
    notranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setNoTranscode(notranscode.getText());
          }
        });
    builder.add(notranscode, FormLayoutUtil.flip(cc.xy(3, 37), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.9"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation));

    forcetranscode = new JTextField(configuration.getForceTranscode());
    forcetranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setForceTranscode(forcetranscode.getText());
          }
        });
    builder.add(forcetranscode, FormLayoutUtil.flip(cc.xy(3, 39), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
  }
    private void initComponents() {

      setPreferredSize(new java.awt.Dimension(420, 65));

      this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

      JPanel buttonPanel = new JPanel();
      buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      JPanel textPanel = new JPanel();
      SpringLayout textLayout = new SpringLayout();
      textPanel.setLayout(textLayout);
      this.add(buttonPanel);
      this.add(textPanel);

      // button area
      abortButton_ = new JButton();
      abortButton_.setBackground(new java.awt.Color(255, 255, 255));
      abortButton_.setIcon(
          new javax.swing.ImageIcon(
              getClass().getResource("/org/micromanager/icons/cancel.png"))); // NOI18N
      abortButton_.setToolTipText("Abort acquisition");
      abortButton_.setFocusable(false);
      abortButton_.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
      abortButton_.setMaximumSize(new java.awt.Dimension(30, 28));
      abortButton_.setMinimumSize(new java.awt.Dimension(30, 28));
      abortButton_.setPreferredSize(new java.awt.Dimension(30, 28));
      abortButton_.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
      abortButton_.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              try {
                JavaUtils.invokeRestrictedMethod(vad_, VirtualAcquisitionDisplay.class, "abort");
              } catch (Exception ex) {
                ReportingUtils.showError(
                    "Couldn't abort. Try pressing stop on Multi-Dimensional acquisition Window");
              }
            }
          });
      buttonPanel.add(abortButton_);

      pauseButton_ = new JButton();
      pauseButton_.setIcon(
          new javax.swing.ImageIcon(
              getClass().getResource("/org/micromanager/icons/control_pause.png"))); // NOI18N
      pauseButton_.setToolTipText("Pause acquisition");
      pauseButton_.setFocusable(false);
      pauseButton_.setMargin(new java.awt.Insets(0, 0, 0, 0));
      pauseButton_.setMaximumSize(new java.awt.Dimension(30, 28));
      pauseButton_.setMinimumSize(new java.awt.Dimension(30, 28));
      pauseButton_.setPreferredSize(new java.awt.Dimension(30, 28));
      pauseButton_.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              try {
                JavaUtils.invokeRestrictedMethod(vad_, VirtualAcquisitionDisplay.class, "pause");
              } catch (Exception ex) {
                ReportingUtils.showError("Couldn't pause");
              }
              if (eng_.isPaused()) {
                pauseButton_.setIcon(
                    new javax.swing.ImageIcon(
                        getClass()
                            .getResource("/org/micromanager/icons/resultset_next.png"))); // NOI18N
              } else {
                pauseButton_.setIcon(
                    new javax.swing.ImageIcon(
                        getClass()
                            .getResource("/org/micromanager/icons/control_pause.png"))); // NOI18N
              }
            }
          });
      buttonPanel.add(pauseButton_);

      gridXSpinner_ = new JSpinner();
      gridXSpinner_.setModel(new SpinnerNumberModel(2, 1, 1000, 1));
      gridXSpinner_.setPreferredSize(new Dimension(35, 24));
      gridYSpinner_ = new JSpinner();
      gridYSpinner_.setModel(new SpinnerNumberModel(2, 1, 1000, 1));
      gridYSpinner_.setPreferredSize(new Dimension(35, 24));
      gridXSpinner_.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              gridSizeChanged();
            }
          });
      gridYSpinner_.addChangeListener(
          new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
              gridSizeChanged();
            }
          });
      final JLabel gridLabel = new JLabel(" grid");
      final JLabel byLabel = new JLabel("by");
      gridLabel.setEnabled(false);
      byLabel.setEnabled(false);
      gridXSpinner_.setEnabled(false);
      gridYSpinner_.setEnabled(false);

      final JButton createGridButton = new JButton("Create");
      createGridButton.setEnabled(false);
      createGridButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              createGrid();
            }
          });

      newGridButton_ = new JToggleButton("New grid");
      buttonPanel.add(new JLabel("    "));
      buttonPanel.add(newGridButton_);
      newGridButton_.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              if (newGridButton_.isSelected()) {
                makeGridOverlay(
                    vad_.getImagePlus().getWidth() / 2, vad_.getImagePlus().getHeight() / 2);
                newGridButton_.setText("Cancel");
                gridLabel.setEnabled(true);
                byLabel.setEnabled(true);
                gridXSpinner_.setEnabled(true);
                gridYSpinner_.setEnabled(true);
                createGridButton.setEnabled(true);
              } else {
                vad_.getImagePlus().getOverlay().clear();
                vad_.getImagePlus().getCanvas().repaint();
                newGridButton_.setText("New grid");
                gridLabel.setEnabled(false);
                byLabel.setEnabled(false);
                gridXSpinner_.setEnabled(false);
                gridYSpinner_.setEnabled(false);
                createGridButton.setEnabled(false);
              }
            }
          });

      buttonPanel.add(gridXSpinner_);
      buttonPanel.add(byLabel);
      buttonPanel.add(gridYSpinner_);
      buttonPanel.add(gridLabel);
      buttonPanel.add(createGridButton);

      // text area
      zPosLabel_ = new JLabel("Z position:                    ");
      textPanel.add(zPosLabel_);

      timeStampLabel_ = new JLabel("Elapsed time:                               ");
      textPanel.add(timeStampLabel_);

      fpsField_ = new JTextField();
      fpsField_.setText("7");
      fpsField_.setToolTipText("Set the speed at which the acquisition is played back.");
      fpsField_.setPreferredSize(new Dimension(25, 18));
      fpsField_.addFocusListener(
          new java.awt.event.FocusAdapter() {

            public void focusLost(java.awt.event.FocusEvent evt) {
              updateFPS();
            }
          });
      fpsField_.addKeyListener(
          new java.awt.event.KeyAdapter() {

            public void keyReleased(java.awt.event.KeyEvent evt) {
              updateFPS();
            }
          });
      JLabel fpsLabel = new JLabel("Animation playback FPS: ");
      textPanel.add(fpsLabel);
      textPanel.add(fpsField_);

      textLayout.putConstraint(SpringLayout.WEST, textPanel, 0, SpringLayout.WEST, zPosLabel_);
      textLayout.putConstraint(
          SpringLayout.EAST, zPosLabel_, 0, SpringLayout.WEST, timeStampLabel_);
      textLayout.putConstraint(SpringLayout.EAST, timeStampLabel_, 0, SpringLayout.WEST, fpsLabel);
      textLayout.putConstraint(SpringLayout.EAST, fpsLabel, 0, SpringLayout.WEST, fpsField_);
      textLayout.putConstraint(SpringLayout.EAST, fpsField_, 0, SpringLayout.EAST, textPanel);

      textLayout.putConstraint(SpringLayout.NORTH, fpsField_, 0, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(SpringLayout.NORTH, zPosLabel_, 3, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(
          SpringLayout.NORTH, timeStampLabel_, 3, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(SpringLayout.NORTH, fpsLabel, 3, SpringLayout.NORTH, textPanel);
    }
Пример #18
0
  public NewUser() {
    super("Adding New User");
    label1 = new JLabel("Name");
    label2 = new JLabel("Category");
    username = new JLabel("Username");
    password = new JLabel("Password");
    confirm = new JLabel("Re-enter Password");
    pass1 = new JPasswordField();
    pass2 = new JPasswordField();
    txtusername = new JTextField();
    name = new JTextField();
    combo1 = new JComboBox();
    button1 = new JButton("Ok", new ImageIcon("Icon/i16x16/ok.png"));
    button2 = new JButton("Cancel", new ImageIcon("Icon/i16x16/exit.png"));

    panel1 = new JPanel(new GridLayout(6, 2));
    panel1.add(label1);
    panel1.add(name);
    panel1.add(label2);
    panel1.add(combo1);
    panel1.add(username);
    panel1.add(txtusername);
    panel1.add(password);
    panel1.add(pass1);
    panel1.add(confirm);
    panel1.add(pass2);
    panel1.add(button1);
    panel1.add(button2);
    combo1.addItem("Manager");
    combo1.addItem("Booking Clerk");
    combo1.addItem("Supervisor");
    panel2 = new JPanel();
    panel2.add(panel1);
    getContentPane().add(panel2);
    setSize(350, 195);
    setVisible(true);
    setLocation((screen.width - 500) / 2, ((screen.height - 350) / 2));
    setResizable(false);
    name.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            if (!(Character.isLetter(c)
                || (c == KeyEvent.VK_BACK_SPACE)
                || (c == KeyEvent.VK_SPACE)
                || (c == KeyEvent.VK_DELETE))) {

              getToolkit().beep();
              JOptionPane.showMessageDialog(
                  null, "Invalid Character", "ERROR", JOptionPane.DEFAULT_OPTION);
              e.consume();
            }
          }
        });
    txtusername.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            if (!(Character.isLetter(c)
                || (c == KeyEvent.VK_BACK_SPACE)
                || (c == KeyEvent.VK_SPACE)
                || (c == KeyEvent.VK_DELETE))) {

              getToolkit().beep();
              JOptionPane.showMessageDialog(
                  null, "Invalid Character", "ERROR", JOptionPane.DEFAULT_OPTION);
              e.consume();
            }
          }
        });
    button1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {

            if (name.getText() == null || name.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter name", "ERROR", JOptionPane.DEFAULT_OPTION);
              name.requestFocus();
              return;
            }
            if (txtusername.getText() == null || txtusername.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter username", "ERROR", JOptionPane.DEFAULT_OPTION);
              txtusername.requestFocus();
              return;
            }
            if (pass1.getText() == null || pass1.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter password", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass1.requestFocus();
              return;
            }
            if (pass2.getText() == null || pass2.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Confirm your password", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass2.requestFocus();
              return;
            }
            if (!pass1.getText().equals(pass2.getText())) {
              JOptionPane.showMessageDialog(
                  null, "passwords do not match.", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass2.requestFocus();
              return;
            }
            try {
              Statement statement = Connect.getConnection().createStatement();
              {
                String temp =
                    "INSERT INTO users (Name,Category,username, password) VALUES ('"
                        + name.getText()
                        + "', '"
                        + combo1.getSelectedItem()
                        + "', '"
                        + txtusername.getText()
                        + "', '"
                        + pass1.getText()
                        + "')";

                int result = statement.executeUpdate(temp);
                JOptionPane.showMessageDialog(
                    null, "User is succesfully added", "SUCCESS", JOptionPane.DEFAULT_OPTION);
                dispose();
              }

            } catch (Exception in) {
              in.printStackTrace();
            }
          }
        });
    button2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
  }
Пример #19
0
  // {{{ InstallPanel constructor
  InstallPanel(PluginManager window, boolean updates) {
    super(new BorderLayout(12, 12));

    this.window = window;
    this.updates = updates;

    setBorder(new EmptyBorder(12, 12, 12, 12));

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setResizeWeight(0.75);
    /* Setup the table */
    table = new JTable(pluginModel = new PluginTableModel());
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setRowHeight(table.getRowHeight() + 2);
    table.setPreferredScrollableViewportSize(new Dimension(500, 200));
    table.setDefaultRenderer(
        Object.class,
        new TextRenderer((DefaultTableCellRenderer) table.getDefaultRenderer(Object.class)));
    table.addFocusListener(new TableFocusHandler());
    InputMap tableInputMap = table.getInputMap(JComponent.WHEN_FOCUSED);
    ActionMap tableActionMap = table.getActionMap();
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "tabOutForward");
    tableActionMap.put("tabOutForward", new KeyboardAction(KeyboardCommand.TAB_OUT_FORWARD));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK), "tabOutBack");
    tableActionMap.put("tabOutBack", new KeyboardAction(KeyboardCommand.TAB_OUT_BACK));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "editPlugin");
    tableActionMap.put("editPlugin", new KeyboardAction(KeyboardCommand.EDIT_PLUGIN));
    tableInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "closePluginManager");
    tableActionMap.put(
        "closePluginManager", new KeyboardAction(KeyboardCommand.CLOSE_PLUGIN_MANAGER));

    TableColumn col1 = table.getColumnModel().getColumn(0);
    TableColumn col2 = table.getColumnModel().getColumn(1);
    TableColumn col3 = table.getColumnModel().getColumn(2);
    TableColumn col4 = table.getColumnModel().getColumn(3);
    TableColumn col5 = table.getColumnModel().getColumn(4);

    col1.setPreferredWidth(30);
    col1.setMinWidth(30);
    col1.setMaxWidth(30);
    col1.setResizable(false);

    col2.setPreferredWidth(180);
    col3.setPreferredWidth(130);
    col4.setPreferredWidth(70);
    col5.setPreferredWidth(70);

    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.addMouseListener(new HeaderMouseHandler());
    header.setDefaultRenderer(
        new HeaderRenderer((DefaultTableCellRenderer) header.getDefaultRenderer()));

    scrollpane = new JScrollPane(table);
    scrollpane.getViewport().setBackground(table.getBackground());
    split.setTopComponent(scrollpane);

    /* Create description */
    JScrollPane infoPane = new JScrollPane(infoBox = new PluginInfoBox());
    infoPane.setPreferredSize(new Dimension(500, 100));
    split.setBottomComponent(infoPane);

    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            split.setDividerLocation(0.75);
          }
        });

    final JTextField searchField = new JTextField();
    searchField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
              table.dispatchEvent(e);
              table.requestFocus();
            }
          }
        });
    searchField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              void update() {
                pluginModel.setFilterString(searchField.getText());
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                update();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update();
              }
            });
    table.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            int i = table.getSelectedRow(), n = table.getModel().getRowCount();
            if (e.getKeyCode() == KeyEvent.VK_DOWN && i == (n - 1)
                || e.getKeyCode() == KeyEvent.VK_UP && i == 0) {
              searchField.requestFocus();
              searchField.selectAll();
            }
          }
        });
    Box filterBox = Box.createHorizontalBox();
    filterBox.add(new JLabel("Filter : "));
    filterBox.add(searchField);
    add(BorderLayout.NORTH, filterBox);
    add(BorderLayout.CENTER, split);

    /* Create buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    buttons.add(new InstallButton());
    buttons.add(Box.createHorizontalStrut(12));
    buttons.add(new SelectallButton());
    buttons.add(chooseButton = new ChoosePluginSet());
    buttons.add(new ClearPluginSet());
    buttons.add(Box.createGlue());
    buttons.add(new SizeLabel());

    add(BorderLayout.SOUTH, buttons);
    String path = jEdit.getProperty(PluginManager.PROPERTY_PLUGINSET, "");
    if (!path.isEmpty()) {
      loadPluginSet(path);
    }
  } // }}}
Пример #20
0
  /** Instantiates a new game panel. */
  public GamePanel() {
    super();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    CARD_BACK.add(new CardPanel("img/cards/BACK.png"));

    // The code below is just for reference
    //        dealerCards = new ArrayList<>();
    //        for (int i = 0; i < dealerInHand.size(); i++)
    //        {
    //            dealerCards.add(new CardPanel("img/cards/" + dealerInHand.get(i) + ".png"));
    //        }
    //
    //        playerCardsOne = new ArrayList<>();
    //        for (int i = 0; i < playerInHandOne.size(); i++)
    //        {
    //            playerCardsOne.add(new CardPanel("img/cards/" + playerInHandOne.get(i) + ".png"));
    //        }
    //
    //        playerCardsTwo = new ArrayList<>();
    //        for (int i = 0; i < playerInHandTwo.size(); i++)
    //        {
    //            playerCardsTwo.add(new CardPanel("img/cards/" + playerInHandTwo.get(i) + ".png"));
    //        }
    // The code above is just for reference

    dealerDeckContainer = new CardDeckContainer();
    dealerStatContainer = new JPanel(new BorderLayout());
    dealerStatContainer.setOpaque(false);
    JLabel dealerStatTitle = new JLabel("Dealer in Hand");
    dealerStatTitle.setForeground(Color.WHITE);
    dealerStatTitle.setHorizontalAlignment(JLabel.CENTER);
    dealerStatTitle.setFont(new Font("", Font.PLAIN, 12));
    dealerStatPoint.setForeground(Color.WHITE);
    dealerStatPoint.setHorizontalAlignment(JLabel.CENTER);
    dealerStatPoint.setFont(new Font("", Font.PLAIN, 12));
    dealerStatContainer.add(dealerStatTitle, BorderLayout.NORTH);
    dealerStatContainer.add(dealerStatPoint, BorderLayout.CENTER);

    playerDeckOneContainer = new CardDeckContainer();
    playerStatOneContainer = new JPanel(new BorderLayout());
    playerStatOneContainer.setOpaque(false);
    JLabel playerStatOneTitle = new JLabel("Player in Hand");
    playerStatOneTitle.setForeground(Color.WHITE);
    playerStatOneTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatOnePoint.setForeground(Color.WHITE);
    playerStatOnePoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatOnePoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatOneDescription.setForeground(Color.WHITE);
    playerStatOneDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatOneContainer.add(playerStatOneTitle, BorderLayout.NORTH);
    playerStatOneContainer.add(playerStatOnePoint, BorderLayout.CENTER);
    playerStatOneContainer.add(playerStatOneDescription, BorderLayout.SOUTH);

    playerDeckTwoContainer = new CardDeckContainer(new CardDeckPanel(CARD_BACK));
    playerStatTwoContainer = new JPanel(new BorderLayout());
    playerStatTwoContainer.setOpaque(false);
    JLabel playerStatTwoTitle = new JLabel("Player Hand 2");
    playerStatTwoTitle.setForeground(Color.WHITE);
    playerStatTwoTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoPoint.setForeground(Color.WHITE);
    playerStatTwoPoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoPoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoDescription.setForeground(Color.WHITE);
    playerStatTwoDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatTwoContainer.add(playerStatTwoTitle, BorderLayout.NORTH);
    playerStatTwoContainer.add(playerStatTwoPoint, BorderLayout.CENTER);
    playerStatTwoContainer.add(playerStatTwoDescription, BorderLayout.SOUTH);

    gameStatPanel = new JPanel();
    gameStatPanelPlayerName = new JLabel();
    gameStatPanelCurrentChips = new JLabel();
    gameStatPanelCurrentBet = new JLabel();
    gameStatPanelPlayerName.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelPlayerName.setForeground(Color.WHITE);
    gameStatPanelPlayerName.setBorder(new EmptyBorder(0, 0, 0, 5));
    gameStatPanelCurrentChips.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentChips.setForeground(Color.WHITE);
    gameStatPanelCurrentChips.setBorder(new EmptyBorder(0, 5, 0, 5));
    gameStatPanelCurrentBet.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentBet.setForeground(Color.WHITE);
    gameStatPanelCurrentBet.setBorder(new EmptyBorder(0, 5, 0, 0));
    gameStatPanel.add(gameStatPanelPlayerName);
    gameStatPanel.add(gameStatPanelCurrentChips);
    gameStatPanel.add(gameStatPanelCurrentBet);
    gameStatPanel.setOpaque(false);

    gameButtonPanel = new JPanel(cardLayout);
    betButtonPanel = new JPanel();
    playButtonPanel = new JPanel();
    JLabel pleaseBet = new JLabel("Please bet: ");
    pleaseBet.setFont(new Font("", Font.PLAIN, 14));
    pleaseBet.setForeground(Color.WHITE);
    betButtonPanel.add(pleaseBet);
    betField = new JTextField();
    betField.setFont(new Font("", Font.PLAIN, 14));
    betField.setPreferredSize(new Dimension(80, 28));
    betButtonPanel.add(betField);
    JButton betButton = new JButton("Bet");
    JButton backButton = new JButton("Back");
    betButtonPanel.add(betButton);
    betButtonPanel.add(backButton);
    betButtonPanel.setOpaque(false);

    hitButton = new JButton("Hit");
    standButton = new JButton("Stand");
    doubleButton = new JButton("Double");
    // JButton splitButton = new JButton("Split");
    // splitButton.setEnabled(false);
    playButtonPanel.add(hitButton);
    playButtonPanel.add(standButton);
    playButtonPanel.add(doubleButton);
    // playButtonPanel.add(splitButton);
    playButtonPanel.setOpaque(false);
    gameButtonPanel.add("betbutton", betButtonPanel);
    gameButtonPanel.add("playbutton", playButtonPanel);
    gameButtonPanel.setOpaque(false);

    add(gameStatPanel);
    add(dealerDeckContainer);
    add(playerDeckTwoContainer);
    add(playerDeckOneContainer);
    add(gameButtonPanel);

    this.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            Game.initGame();
          }
        });

    betButtonPanel.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            betField.setText("");
            if (BlackJack.player.getChip() <= 0) {
              JOptionPane.showMessageDialog(
                  null, "You are penniless!", "Information", JOptionPane.INFORMATION_MESSAGE);
              User.deleteUserByName(BlackJack.player.getName());
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
            hitButton.setEnabled(true);
            standButton.setEnabled(true);
            doubleButton.setEnabled(true);
            BlackJack.player.setBet(0);
            BlackJack.player.getHandOne().clear();
            BlackJack.player.getHandTwo().clear();
            BlackJack.dealer.getHandOne().clear();
            GamePanel.gameStatPanelPlayerName.setText("Player: " + BlackJack.player.getName());
            GamePanel.gameStatPanelCurrentChips.setText("Chips: " + BlackJack.player.getChip());
            GamePanel.gameStatPanelCurrentBet.setText("Bet: 0");
            GamePanel.gameStatPanel.repaint();
          }
        });

    betField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent e) {
            int keyChar = e.getKeyChar();
            if (keyChar < KeyEvent.VK_0 || keyChar > KeyEvent.VK_9) {
              e.consume();
            }
          }
        });

    betButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Game.bet(Integer.parseInt(betField.getText()));
          }
        });

    backButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int choice =
                JOptionPane.showConfirmDialog(
                    null,
                    "Do you want to go back to main menu?\nYour record will be saved.",
                    "Go Back",
                    JOptionPane.YES_NO_OPTION);
            if (choice == JOptionPane.YES_OPTION) {
              User.updateUser();
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
          }
        });

    hitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            doubleButton.setEnabled(false);
            Game.hit();
          }
        });

    standButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            playerStatOneDescription.setText("Stand");
            playerStatOneDescription.repaint();
            Game.dealerGame();
          }
        });

    doubleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            if (!Game.doubleDown()) {
              hitButton.setEnabled(true);
              standButton.setEnabled(true);
              doubleButton.setEnabled(false);
            }
          }
        });
  }
Пример #21
0
  public MCMCPanel(BeautiFrame parent) {
    setLayout(new BorderLayout());

    // Mac OS X components have more spacing round them already
    optionsPanel = new OptionsPanel(12, (OSType.isMac() ? 6 : 24));

    this.frame = parent;

    setOpaque(false);
    optionsPanel.setOpaque(false);

    chainLengthField.setValue(100000);
    chainLengthField.setColumns(10);
    optionsPanel.addComponentWithLabel("Length of chain:", chainLengthField);
    chainLengthField.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            options.chainLength = chainLengthField.getValue();
            frame.setDirty();
          }
        });

    optionsPanel.addSeparator();

    echoEveryField.setValue(1000);
    echoEveryField.setColumns(10);
    optionsPanel.addComponentWithLabel("Echo state to screen every:", echoEveryField);
    echoEveryField.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            options.echoEvery = echoEveryField.getValue();
            frame.setDirty();
          }
        });

    logEveryField.setValue(100);
    logEveryField.setColumns(10);
    optionsPanel.addComponentWithLabel("Log parameters every:", logEveryField);
    logEveryField.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            options.logEvery = logEveryField.getValue();
            frame.setDirty();
          }
        });

    optionsPanel.addSeparator();

    fileNameStemField.setColumns(32);
    optionsPanel.addComponentWithLabel("File name stem:", fileNameStemField);
    fileNameStemField.setEditable(true);
    fileNameStemField.addKeyListener(
        new java.awt.event.KeyListener() {
          public void keyTyped(KeyEvent e) {}

          public void keyPressed(KeyEvent e) {}

          public void keyReleased(KeyEvent e) {
            options.fileNameStem = fileNameStemField.getText();
            updateOtherFileNames(options);
            frame.setDirty();
          }
        });

    optionsPanel.addComponent(addTxt);
    if (OSType.isWindows()) {
      addTxt.setSelected(true);
    } else {
      addTxt.setSelected(false);
    }
    addTxt.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent changeEvent) {
            setOptions(options);
            frame.setDirty();
          }
        });

    optionsPanel.addSeparator();

    logFileNameField.setColumns(32);
    optionsPanel.addComponentWithLabel("Log file name:", logFileNameField);
    logFileNameField.setEditable(false);

    //        optionsPanel.addComponent(allowOverwriteLogCheck);
    //        allowOverwriteLogCheck.setSelected(false);
    //        allowOverwriteLogCheck.addChangeListener(new ChangeListener() {
    //            public void stateChanged(ChangeEvent changeEvent) {
    //            	options.allowOverwriteLog = allowOverwriteLogCheck.isSelected();
    //            }
    //        });

    treeFileNameField.setColumns(32);
    optionsPanel.addComponentWithLabel("Trees file name:", treeFileNameField);
    treeFileNameField.setEditable(false);

    //        addComponent(mapTreeLogCheck);
    //        mapTreeLogCheck.setOpaque(false);
    //        mapTreeLogCheck.addActionListener(new java.awt.event.ActionListener() {
    //            public void actionPerformed(ActionEvent e) {
    //                mapTreeFileNameField.setEnabled(mapTreeLogCheck.isSelected());
    //            }
    //        });
    //
    //        mapTreeFileNameField.setColumns(32);
    //        addComponentWithLabel("MAP tree file name:", mapTreeFileNameField);

    optionsPanel.addComponent(substTreeLogCheck);
    substTreeLogCheck.setOpaque(false);
    substTreeLogCheck.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            options.substTreeLog = substTreeLogCheck.isSelected();
            updateTreeFileNameList();
            substTreeFileNameField.setEnabled(substTreeLogCheck.isSelected());
            if (substTreeLogCheck.isSelected()) {
              substTreeFileNameField.setText(displayTreeList(options.substTreeFileName));
            } else {
              substTreeFileNameField.setText("");
            }

            frame.setDirty();
          }
        });

    substTreeFileNameField.setColumns(32);
    substTreeFileNameField.setEditable(false);
    substTreeFileNameField.setEnabled(false);
    optionsPanel.addComponentWithLabel("Substitutions trees file name:", substTreeFileNameField);

    optionsPanel.addComponent(operatorAnalaysisCheck);
    operatorAnalaysisCheck.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            options.operatorAnalysis = operatorAnalaysisCheck.isSelected();

            updateOtherFileNames(options);

            frame.setDirty();
          }
        });

    operatorAnalaysisFileNameField.setColumns(32);
    operatorAnalaysisFileNameField.setEditable(false);
    operatorAnalaysisFileNameField.setEnabled(false);
    optionsPanel.addComponentWithLabel(
        "Operator analysis file name:", operatorAnalaysisFileNameField);

    optionsPanel.addSeparator();

    optionsPanel.addComponent(samplePriorCheckBox);
    samplePriorCheckBox.setOpaque(false);
    samplePriorCheckBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent changeEvent) {
            frame.setDirty();
          }
        });

    //        logFileNameField.addKeyListener(listener);
    //        treeFileNameField.addKeyListener(listener);
    // mapTreeFileNameField.addKeyListener(listener);
    //        substTreeFileNameField.addKeyListener(listener);

    //        optionsPanel.setPreferredSize(new java.awt.Dimension(500, 600));

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    panel.add(optionsPanel, BorderLayout.CENTER);
    panel.setOpaque(false);

    JScrollPane scrollPane =
        new JScrollPane(
            panel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setOpaque(false);
    scrollPane.setBorder(null);
    scrollPane.getViewport().setOpaque(false);

    add(scrollPane, BorderLayout.CENTER);
  }
Пример #22
0
  protected FontOptions(@NotNull ColorAndFontOptions options, final String title) {
    setLayout(new MigLayout("ins 0, gap 5, flowx"));
    Insets borderInsets =
        new Insets(
            IdeBorderFactory.TITLED_BORDER_TOP_INSET,
            IdeBorderFactory.TITLED_BORDER_LEFT_INSET,
            0,
            IdeBorderFactory.TITLED_BORDER_RIGHT_INSET);
    setBorder(IdeBorderFactory.createTitledBorder(title, false, borderInsets));
    myOptions = options;
    add(myOnlyMonospacedCheckBox, "sgx b, sx 2");

    add(new JLabel(ApplicationBundle.message("primary.font")), "newline, ax right");
    add(myPrimaryCombo, "sgx b");
    add(new JLabel(ApplicationBundle.message("editbox.font.size")), "gapleft 20");
    add(myEditorFontSizeField);
    add(new JLabel(ApplicationBundle.message("editbox.line.spacing")), "gapleft 20");
    add(myLineSpacingField);

    add(
        new JLabel(
            ApplicationBundle.message("label.fallback.fonts.list.description"),
            MessageType.INFO.getDefaultIcon(),
            SwingConstants.LEFT),
        "newline, sx 5");
    add(myUseSecondaryFontCheckbox, "newline, ax right");
    add(mySecondaryCombo, "sgx b");
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    myEnableLigaturesCheckbox.setBorder(null);
    panel.add(myEnableLigaturesCheckbox);
    myLigaturesInfoLinkLabel =
        new LinkLabel<Void>(
            ApplicationBundle.message("ligatures.more.info"),
            null,
            new LinkListener<Void>() {
              @Override
              public void linkSelected(LinkLabel aSource, Void aLinkData) {
                BrowserUtil.browse(
                    "https://confluence.jetbrains.com/display/IDEADEV/Support+for+Ligatures+in+Editor");
              }
            });
    myLigaturesInfoLinkLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
    panel.add(myLigaturesInfoLinkLabel);
    add(panel, "newline, sx 2");

    myOnlyMonospacedCheckBox.setBorder(null);
    myUseSecondaryFontCheckbox.setBorder(null);
    mySecondaryCombo.setEnabled(false);

    myOnlyMonospacedCheckBox.setSelected(
        EditorColorsManager.getInstance().isUseOnlyMonospacedFonts());
    myOnlyMonospacedCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            EditorColorsManager.getInstance()
                .setUseOnlyMonospacedFonts(myOnlyMonospacedCheckBox.isSelected());
            myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
            mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
          }
        });
    myPrimaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
    myPrimaryCombo.setRenderer(RENDERER);

    mySecondaryCombo.setMonospacedOnly(myOnlyMonospacedCheckBox.isSelected());
    mySecondaryCombo.setRenderer(RENDERER);

    myUseSecondaryFontCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            mySecondaryCombo.setEnabled(myUseSecondaryFontCheckbox.isSelected());
            syncFontFamilies();
          }
        });
    ItemListener itemListener =
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              syncFontFamilies();
            }
          }
        };
    myPrimaryCombo.addItemListener(itemListener);
    mySecondaryCombo.addItemListener(itemListener);

    ActionListener actionListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            syncFontFamilies();
          }
        };
    myPrimaryCombo.addActionListener(actionListener);
    mySecondaryCombo.addActionListener(actionListener);

    myEditorFontSizeField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void textChanged(DocumentEvent event) {
                if (myIsInSchemeChange || !SwingUtilities.isEventDispatchThread()) return;
                String selectedFont = myPrimaryCombo.getFontName();
                if (selectedFont != null) {
                  FontPreferences fontPreferences = getFontPreferences();
                  fontPreferences.register(selectedFont, getFontSizeFromField());
                }
                updateDescription(true);
              }
            });
    myEditorFontSizeField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return;
            boolean up = e.getKeyCode() == KeyEvent.VK_UP;
            try {
              int value = Integer.parseInt(myEditorFontSizeField.getText());
              value += (up ? 1 : -1);
              value =
                  Math.min(
                      OptionsConstants.MAX_EDITOR_FONT_SIZE,
                      Math.max(OptionsConstants.MIN_EDITOR_FONT_SIZE, value));
              myEditorFontSizeField.setText(String.valueOf(value));
            } catch (NumberFormatException ignored) {
            }
          }
        });

    myLineSpacingField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              @Override
              public void textChanged(DocumentEvent event) {
                if (myIsInSchemeChange) return;
                float lineSpacing = getLineSpacingFromField();
                if (getLineSpacing() != lineSpacing) {
                  setCurrentLineSpacing(lineSpacing);
                }
                updateDescription(true);
              }
            });
    myLineSpacingField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_UP && e.getKeyCode() != KeyEvent.VK_DOWN) return;
            boolean up = e.getKeyCode() == KeyEvent.VK_UP;
            try {
              float value = Float.parseFloat(myLineSpacingField.getText());
              value += (up ? 1 : -1) * .1F;
              value =
                  Math.min(
                      OptionsConstants.MAX_EDITOR_LINE_SPACING,
                      Math.max(OptionsConstants.MIN_EDITOR_LINE_SPACING, value));
              myLineSpacingField.setText(String.format(Locale.ENGLISH, "%.1f", value));
            } catch (NumberFormatException ignored) {
            }
          }
        });
    myEnableLigaturesCheckbox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            getFontPreferences().setUseLigatures(myEnableLigaturesCheckbox.isSelected());
          }
        });
  }
  public JobForm() {

    final JobForm form = this;

    this.setContentPane(mainPanel);
    this.setModal(true);
    saveButton.setEnabled(false);

    ButtonGroup group = new ButtonGroup();
    group.add(onDemandRadioButton);
    group.add(scheduledRadioButton);

    jobNameTextField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent keyEvent) {
            super.keyTyped(keyEvent);

            saveButton.setEnabled(!jobNameTextField.getText().isEmpty());
          }
        });

    ActionListener radioActionListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            setEnabledOptions();
          }
        };

    scheduledRadioButton.addActionListener(radioActionListener);
    onDemandRadioButton.addActionListener(radioActionListener);

    intervalUnitComboBox.setModel(new DefaultComboBoxModel(Job.getUnits()));

    scheduledRadioButton.setSelected(true);
    intervalFormattedTextField.setText("15");
    setEnabledOptions();

    intervalFormattedTextField.setInputVerifier(
        new InputVerifier() {
          @Override
          public boolean verify(JComponent jComponent) {
            if (jComponent instanceof JFormattedTextField) {
              JFormattedTextField field = (JFormattedTextField) jComponent;

              try {
                parseInt(field.getText());
              } catch (NumberFormatException e) {
                return false;
              }

              return true;
            }

            return false;
          }
        });

    saveButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            try {
              form.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

              String jobName = jobNameTextField.getText().trim();
              int interval =
                  onDemandRadioButton.isSelected()
                      ? 0
                      : parseInt(intervalFormattedTextField.getText());
              String unit =
                  onDemandRadioButton.isSelected()
                      ? "none"
                      : Job.getUnits()[intervalUnitComboBox.getSelectedIndex()];

              SimpleDateFormat ISO8601DATEFORMAT =
                  new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH);
              String now = ISO8601DATEFORMAT.format(new Date());

              if (!jobName.matches("^[A-Za-z][A-Za-z0-9_]+")) {
                form.setCursor(Cursor.getDefaultCursor());
                JOptionPane.showMessageDialog(
                    form,
                    "Invalid service name. Job name must start with a letter, \n"
                        + "contain only letters, numbers, and undercores.",
                    "Error creating the job",
                    JOptionPane.ERROR_MESSAGE);
                return;
              }

              if (existingJobNames == null) {
                existingJobNames = new ArrayList<String>();

                for (Job job :
                    AzureRestAPIManager.getManager().listJobs(subscriptionId, serviceName)) {
                  existingJobNames.add(job.getName().toLowerCase());
                }
              }

              if (existingJobNames.contains(jobName.toLowerCase())) {
                form.setCursor(Cursor.getDefaultCursor());
                JOptionPane.showMessageDialog(
                    form,
                    "Invalid job name. A job with that name already exists in this service.",
                    "Error creating the job",
                    JOptionPane.ERROR_MESSAGE);
                return;
              }

              if (id == null)
                AzureRestAPIManager.getManager()
                    .createJob(subscriptionId, serviceName, jobName, interval, unit, now);
              else {
                AzureRestAPIManager.getManager()
                    .updateJob(
                        subscriptionId,
                        serviceName,
                        jobName,
                        interval,
                        unit,
                        now,
                        enabledCheckBox.isSelected());
              }

              if (afterSave != null) afterSave.run();

              form.setCursor(Cursor.getDefaultCursor());

              form.setVisible(false);
              form.dispose();

            } catch (Throwable ex) {
              form.setCursor(Cursor.getDefaultCursor());
              UIHelper.showException("Error trying to save job", ex);
            }
          }
        });

    cancelButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            form.setVisible(false);
            form.dispose();
          }
        });
  }
  public NewElementCatalog(Project project, final JFrame frame) {
    super(project);

    setTitle("Oracle WebCenter Sites New Element");
    webCenterSitesPluginModuleConfigurationData =
        WebCenterSitesPluginModuleConfigurationData.getInstance(project);
    newElementCatalog = this;

    this.elementCatalogEntry = new ElementCatalogEntry();
    setDefaultProperties();

    setOKButtonText("Finish");
    setOKActionEnabled(isPageComplete());

    init();
    setSize(600, 550);
    textFieldElementCatalogName.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            super.keyPressed(e);
            populateElementFields();
          }

          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            populateElementFields();
          }
        });

    textFieldElementCatalogElementParameter.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            super.keyPressed(e);
            elementCatalogEntry.setElementParameters(
                textFieldElementCatalogElementParameter.getText());
            setPageError();
          }

          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            elementCatalogEntry.setElementParameters(
                textFieldElementCatalogElementParameter.getText());
            setPageError();
          }
        });
    textFieldElementCatalogAdditionalParameters.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            super.keyPressed(e);
            elementCatalogEntry.setAdditionalElementParameters(
                textFieldElementCatalogAdditionalParameters.getText());
            setPageError();
          }

          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            elementCatalogEntry.setAdditionalElementParameters(
                textFieldElementCatalogAdditionalParameters.getText());
            setPageError();
          }
        });
    XMLRadioButton.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (XMLRadioButton.isSelected()) {
              elementCatalogEntry.setElementType(ElementFileType.XML_EC);
              populateElementFields();
            }
          }
        });
    JSPRadioButton.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (JSPRadioButton.isSelected()) {
              elementCatalogEntry.setElementType(ElementFileType.JSP_EC);
              populateElementFields();
            }
          }
        });
    groovyRadioButton.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (groovyRadioButton.isSelected()) {
              elementCatalogEntry.setElementType(ElementFileType.GROOVY);
              populateElementFields();
            }
          }
        });
    HTMLRadioButton.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (HTMLRadioButton.isSelected()) {
              elementCatalogEntry.setElementType(ElementFileType.HTML);
              populateElementFields();
            }
          }
        });

    show();
  }
Пример #25
0
  private void initializeUI() {

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle(Constants.WINDOW_TITLE);

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            closePort();
          }
        });

    JMenuBar menuBar = new JMenuBar();
    portMenu = new JMenu(Constants.WINDOW_PORT);
    menuBar.add(portMenu);

    refreshItem = new JMenuItem(Constants.WINDOW_REFRESH_PORTS);
    refreshItem.addActionListener(e -> refreshSerialPortList());

    portMenu.add(refreshItem);

    setJMenuBar(menuBar);

    Container mainPane = getContentPane();

    mainPane.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setRows(16);
    textArea.setColumns(40);
    textArea.setEditable(false);

    JScrollPane scrollPane = new JScrollPane(textArea);

    mainPane.add(scrollPane, BorderLayout.CENTER);

    JPanel lowerPane = new JPanel();
    lowerPane.setLayout(new BoxLayout(lowerPane, BoxLayout.X_AXIS));
    lowerPane.setBorder(new EmptyBorder(4, 4, 4, 4));

    JButton transferFileButton = new JButton(Constants.WINDOW_TRANSFER_FILE);
    transferFileButton.addActionListener(e -> onTransferFileClicked());
    lowerPane.add(transferFileButton);
    lowerPane.add(Box.createRigidArea(new Dimension(4, 0)));

    textField = new JTextField(40);
    textField.addKeyListener(this);

    JButton sendButton = new JButton(Constants.WINDOW_SEND);

    JButton clearButton = new JButton(Constants.WINDOW_CLEAN);
    clearButton.addActionListener(e -> textArea.setText(""));

    sendButton.addActionListener(e -> onSendButtonClicked());

    lowerPane.add(textField);
    lowerPane.add(Box.createRigidArea(new Dimension(4, 0)));
    lowerPane.add(sendButton);
    lowerPane.add(Box.createRigidArea(new Dimension(4, 0)));
    lowerPane.add(clearButton);

    mainPane.add(lowerPane, BorderLayout.SOUTH);

    pack();

    refreshSerialPortList();
  }
Пример #26
0
  private void initPanel() {

    mapButtons = new HashMap<>();

    for (Commontags commontags : CommontagsTools.getAll()) {
      mapAllTags.put(commontags.getText(), commontags);
    }

    int tagnum = 1;
    for (Commontags selectedTags : listSelectedTags) {
      if (tagnum % MAXLINE == 0) {
        add(createButton(selectedTags), RiverLayout.LINE_BREAK);
      } else {
        add(createButton(selectedTags), RiverLayout.LEFT);
      }
      tagnum++;
    }

    if (editmode) {
      txtTags = new JTextField(10);

      SelectAllUtils.install(txtTags);
      ac = new AutoCompletion(txtTags, mapAllTags.keySet().toArray(new String[] {}));

      ac.setStrict(false);
      ac.setStrictCompletion(false);
      txtTags.addActionListener(e -> cmbTagsActionPerformed(e));

      txtTags.addFocusListener(
          new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
              cmbTagsActionPerformed(null);
            }
          });

      txtTags.addKeyListener(
          new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {
              char c = e.getKeyChar();
              if (Character.isAlphabetic(c) || Character.isDigit(c)) {
                super.keyTyped(e);
              } else {
                e.consume();
              }
            }
          });

      add(txtTags);

      btnPickTags =
          GUITools.getTinyButton("opde.tags.pnlcommontags.allTags", SYSConst.icon22checkbox);
      btnPickTags.setPressedIcon(SYSConst.icon22Pressed);
      btnPickTags.addActionListener(
          e -> {
            final JidePopup popup = new JidePopup();
            JPanel pnl = new JPanel(new BorderLayout());
            pnl.add(new JScrollPane(getClickableTagsPanel()), BorderLayout.CENTER);
            //                        JButton btnApply = new JButton(SYSConst.icon22apply);
            //                        pnl.add(btnApply, BorderLayout.SOUTH);
            //
            //                        btnApply.addActionListener(new ActionListener() {
            //                            @Override
            //                            public void actionPerformed(ActionEvent ae) {
            //                                popup.hidePopup();
            //                            }
            //                        });

            popup.setMovable(false);
            popup
                .getContentPane()
                .setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
            popup.setOwner(btnPickTags);
            popup.removeExcludedComponent(btnPickTags);
            pnl.setPreferredSize(new Dimension(400, 200));
            popup.getContentPane().add(pnl);
            popup.setDefaultFocusComponent(pnl);

            popup.addPopupMenuListener(
                new PopupMenuListener() {
                  @Override
                  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    OPDE.debug("popupMenuWillBecomeVisible");
                  }

                  @Override
                  public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                    SwingUtilities.invokeLater(
                        () -> {
                          removeAll();

                          add(txtTags);
                          if (btnPickTags != null) {
                            add(btnPickTags);
                          }
                          int tagnum1 = 1;

                          for (JButton btn : mapButtons.values()) {
                            if (tagnum1 % MAXLINE == 0) {
                              add(btn, RiverLayout.LINE_BREAK);
                            } else {
                              add(btn, RiverLayout.LEFT);
                            }
                            tagnum1++;
                          }

                          revalidate();
                          repaint();
                        });
                  }

                  @Override
                  public void popupMenuCanceled(PopupMenuEvent e) {
                    OPDE.debug("popupMenuCanceled");
                  }
                });

            GUITools.showPopup(popup, SwingConstants.WEST);
          });

      add(btnPickTags);
    }
  }
Пример #27
0
  /**
   * This method is used to display the window to interact with obix as well as colibri.
   *
   * @param chosenComponents The {@link ObixObject} which have been chosen in the previous windows.
   * @return The container which contains all elemtents that are used for interacting with obix as
   *     well as colibri.
   */
  private Container interactionWindow(List<ObixObject> chosenComponents) {
    Container pane = new Container();
    pane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 10;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(30, 20, 0, 0);

    c.gridy++;
    pane.add(registeredColibriChannelCheckBox, c);

    JLabel label = new JLabel("OBIX Components");
    Font headerF = new Font("Courier", Font.BOLD, 25);
    label.setFont(headerF);
    c.gridy++;
    pane.add(label, c);

    /*
       Print lobby Data
    */
    for (ObixObject o : chosenComponents) {
      if (connector.getColibriChannel().getRegistered()) {
        connector.getColibriChannel().send(ColibriMessage.createAddServiceMessage(o));
      }

      c.gridy++;
      c.insets = new Insets(30, 10, 0, 0);

      JLabel uriLabel = new JLabel(o.getObixUri());
      uriLabel.setFont(new Font("Courier", Font.ITALIC, 15));
      c.gridx = 0;
      c.gridwidth = 10;
      pane.add(uriLabel, c);

      c.gridwidth = 1;
      c.insets = new Insets(5, 10, 0, 0);

      final JTextField textField = new JTextField("NOT OBSERVED", 20);
      Font tempF = new Font("Courier", Font.PLAIN, 15);
      textField.setFont(tempF);
      c.gridy++;
      pane.add(textField, c);

      JLabel unitLabel = new JLabel();
      if (o.hasUnit()) {
        String unitString = o.getUnit().symbol().get();
        int unitCode = unitString.codePointAt(0);
        if (unitCode == 65533) {
          unitString = "\u2103";
        }
        unitLabel.setText(unitString);
      }
      c.gridx++;
      pane.add(unitLabel, c);

      final JButton getObixButton = new JButton("GET from OBIX");
      c.gridx++;
      pane.add(getObixButton, c);

      final JButton getColibriButton = new JButton("GET from Colibri");
      c.gridx++;
      pane.add(getColibriButton, c);

      final JCheckBox writableCheckBox = new JCheckBox("Writable");
      writableCheckBox.setSelected(o.getObj().isWritable());
      writableCheckBox.setEnabled(false);
      c.gridx++;
      pane.add(writableCheckBox, c);

      final JCheckBox observeObixCheckBox = new JCheckBox("observe Obix Data");
      observeObixCheckBox.setMargin(new Insets(0, 20, 0, 20));
      c.gridx++;
      pane.add(observeObixCheckBox, c);

      final JCheckBox observedByColibriCheckBox = new JCheckBox("Colibri observes Data");
      observedByColibriCheckBox.setEnabled(false);
      commandFactory.addCommand(
          () -> observedByColibriCheckBox.setSelected(o.getObservedByColibri()));
      c.gridx++;
      pane.add(observedByColibriCheckBox, c);

      final JCheckBox addServiceCheckbox = new JCheckBox("Service Added to Colibri");
      commandFactory.addCommand(() -> addServiceCheckbox.setSelected(o.getAddedAsService()));
      commandFactory.addCommand(
          () -> addServiceCheckbox.setEnabled(connector.getColibriChannel().getRegistered()));
      c.gridx++;
      pane.add(addServiceCheckbox, c);

      final JCheckBox observeColibriActionsCheckbox = new JCheckBox("Observe Colibri Actions");
      if (o.getObj().isWritable()) {
        commandFactory.addCommand(
            () -> observeColibriActionsCheckbox.setEnabled(o.getAddedAsService()));
        commandFactory.addCommand(
            () -> observeColibriActionsCheckbox.setSelected(o.getObservesColibriActions()));
      } else {
        observeColibriActionsCheckbox.setEnabled(false);
      }
      c.gridx++;
      pane.add(observeColibriActionsCheckbox, c);

      representationRows.add(
          new RepresentationRow(
              uriLabel,
              observeObixCheckBox,
              textField,
              o,
              writableCheckBox,
              getObixButton,
              getColibriButton,
              addServiceCheckbox,
              observedByColibriCheckBox,
              observeColibriActionsCheckbox));
      PutToObixTask putToObixTask =
          new PutToObixTask(o, connector.getColibriChannel(), connector.getObixChannel(), null);
      connector.getColibriChannel().addPutToObixTask(o.getServiceUri(), putToObixTask);
      ObixObservationUpdates observationUpdates =
          new ObixObservationUpdates(observeObixCheckBox, textField, o, connector);

      /**
       * Listener for the checkbox which indicates, if an {@link ObixObject] is observed by the obix connector.
       */
      observeObixCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getObservedCheckBox().equals(observeObixCheckBox)) {
                  object = r.getObixObject();
                }
              }
              if (e.getStateChange() == ItemEvent.SELECTED) {
                obixChannel.observe(object);
                commandFactory.addCommand(
                    object.getObixUri() + "ObserveCommand", observationUpdates::run);
              } else {
                commandFactory.removeCommand(object.getObixUri() + "ObserveCommand");
                object.getRelation().proactiveCancel();
              }
            }
          });

      /**
       * Listener for the checkbox which indicates, if an {@link ObixObject] is writeable.
       */
      writableCheckBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getWritableCheckbox().equals(writableCheckBox)) {
                  object = r.getObixObject();
                }
              }

              if (e.getStateChange() == ItemEvent.SELECTED) {

              } else {
                object.getObj().setWritable(false);
              }
              object = obixChannel.put(object);
              writableCheckBox.setSelected(object.getObj().isWritable());
            }
          });

      /**
       * Listener for the checkbox which indicates, if an {@link ObixObject] is added as a service at colibri.
       */
      addServiceCheckbox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getAddedAsServiceCheckBox().equals(addServiceCheckbox)) {
                  object = r.getObixObject();
                }
              }
              if (e.getStateChange() == ItemEvent.SELECTED) {
                if (!object.getAddedAsService()) {
                  connector
                      .getColibriChannel()
                      .send(ColibriMessage.createAddServiceMessage(object));
                }
              } else {
                if (object.getAddedAsService()) {
                  connector
                      .getColibriChannel()
                      .send(ColibriMessage.createRemoveServiceMessage(object));
                }
              }
            }
          });

      /**
       * Listener for the checkbox which indicates, if the connector observes the actions that the colibri
       * semantic core performs on an {@link ObixObject].
       */
      observeColibriActionsCheckbox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getObserveColibriActionsCheckbox().equals(observeColibriActionsCheckbox)) {
                  object = r.getObixObject();
                }
              }
              if (e.getStateChange() == ItemEvent.SELECTED) {
                if (!object.getObservesColibriActions()) {
                  connector
                      .getColibriChannel()
                      .send(ColibriMessage.createObserveServiceMessage(object));
                }
              } else {
                if (object.getObservesColibriActions()) {
                  connector
                      .getColibriChannel()
                      .send(ColibriMessage.createDetachServiceMessage(object));
                }
              }
            }
          });

      /** GET Obix button listener */
      Action getObixAction =
          new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              JTextField textF = null;
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getGetObixButton().equals(getObixButton)) {
                  object = r.getObixObject();
                  textF = r.getValueTextField();
                }
              }
              textField.setText("");
              object = obixChannel.get(object.getObixUri());
              textF.setText(object.toString());
              if (o.getObservedByColibri()) {
                o.getPutMessageToColibriTask().execute(o);
              }
            }
          };
      getObixButton.addActionListener(getObixAction);

      /** GET Colibri button listener */
      Action getColibriAction =
          new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
              ObixObject object = new ObixObject("", o.getObixChannelPort());
              JTextField textF = null;
              for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                if (r.getGetColibriButton().equals(getColibriButton)) {
                  object = r.getObixObject();
                  textF = r.getValueTextField();
                }
              }
              connector.getColibriChannel().send(ColibriMessage.createGetMessage(object));
            }
          };
      getColibriButton.addActionListener(getColibriAction);

      /**
       * Listener for the textfield connected with an {@link ObixObject}, to send PUT messages to
       * obix on <Enter>.
       */
      textField.addKeyListener(
          new KeyListener() {
            public void keyTyped(KeyEvent e) {
              // intentionally empty
            }

            public void keyPressed(KeyEvent e) {
              // intentionally empty
            }

            public void keyReleased(KeyEvent e) {
              if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                ObixObject object = new ObixObject("", o.getObixChannelPort());
                for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
                  if (r.getValueTextField().equals(textField)) {
                    object = r.getObixObject();
                  }
                }
                object.setValueParameter1(textField.getText());
                textField.setText("");
                object = obixChannel.put(object);
                textField.setText(object.toString());
              }
            }
          });
    }

    JTextArea receivedMessagesTextArea = new JTextArea("Received Messages");
    receivedMessagesTextArea.setLineWrap(true);
    receivedMessagesTextArea.setWrapStyleWord(true);
    c.gridy++;
    c.gridx = 0;
    c.insets = new Insets(50, 0, 0, 0);
    c.gridwidth = 10;
    pane.add(receivedMessagesTextArea, c);
    receivedMessagesTextArea.setEnabled(false);
    commandFactory.addCommand(
        () ->
            receivedMessagesTextArea.setText(
                connector.getColibriChannel().getLastMessageReceived()));

    c.gridy++;
    c.gridwidth = 1;

    JLabel sendMessageLabel = new JLabel("Send Message to Colibri Semantic Core:");
    pane.add(sendMessageLabel, c);

    c.gridy++;
    c.gridwidth = 10;
    JTextArea sendMessageArea = new JTextArea("");
    pane.add(sendMessageArea, c);

    c.gridy++;
    c.gridwidth = 2;
    JButton sendQueMessageButton = new JButton("Send Query Message");
    pane.add(sendQueMessageButton, c);
    c.gridx++;
    c.gridx++;
    c.gridwidth = 2;
    JButton sendUpdMessageButton = new JButton("Send Update Message");
    pane.add(sendUpdMessageButton, c);

    commandFactory.addCommand(
        () -> sendQueMessageButton.setEnabled(connector.getColibriChannel().getRegistered()));
    commandFactory.addCommand(
        () -> sendUpdMessageButton.setEnabled(connector.getColibriChannel().getRegistered()));

    /** QUE to Colibri button listener */
    Action sendQueMessageAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            connector
                .getColibriChannel()
                .send(
                    ColibriMessage.createQueryMessage(
                        sendMessageArea.getText(), new ArrayList<>()));
          }
        };
    sendQueMessageButton.addActionListener(sendQueMessageAction);

    /** UPD to Colibri button listener */
    Action sendUpdMessageAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            connector
                .getColibriChannel()
                .send(ColibriMessage.createUpdateMessage(sendMessageArea.getText()));
          }
        };
    sendUpdMessageButton.addActionListener(sendUpdMessageAction);
    return pane;
  }
  /**
   * Called by constructors to initialize the dialog.
   *
   * @since ostermillerutils 1.00.00
   */
  @Override
  protected void dialogInit() {

    if (labels == null) {
      setLocale(Locale.getDefault());
    }

    name = new JTextField("", 20);
    pass = new JPasswordField("", 20);
    okButton = new JButton(labels.getString("dialog.ok"));
    cancelButton = new JButton(labels.getString("dialog.cancel"));
    nameLabel = new JLabel(labels.getString("dialog.name") + " ");
    passLabel = new JLabel(labels.getString("dialog.pass") + " ");

    super.dialogInit();

    KeyListener keyListener =
        (new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE
                || (e.getSource() == cancelButton && e.getKeyCode() == KeyEvent.VK_ENTER)) {
              pressed_OK = false;
              PasswordDialog.this.setVisible(false);
            }
            if (e.getSource() == okButton && e.getKeyCode() == KeyEvent.VK_ENTER) {
              pressed_OK = true;
              PasswordDialog.this.setVisible(false);
            }
          }
        });
    addKeyListener(keyListener);

    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            if (source == name) {
              // the user pressed enter in the name field.
              name.transferFocus();
            } else {
              // other actions close the dialog.
              pressed_OK = (source == pass || source == okButton);
              PasswordDialog.this.setVisible(false);
            }
          }
        };

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.insets.top = 5;
    c.insets.bottom = 5;
    JPanel pane = new JPanel(gridbag);
    pane.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));
    c.anchor = GridBagConstraints.EAST;
    gridbag.setConstraints(nameLabel, c);
    pane.add(nameLabel);

    gridbag.setConstraints(name, c);
    name.addActionListener(actionListener);
    name.addKeyListener(keyListener);
    pane.add(name);

    c.gridy = 1;
    gridbag.setConstraints(passLabel, c);
    pane.add(passLabel);

    gridbag.setConstraints(pass, c);
    pass.addActionListener(actionListener);
    pass.addKeyListener(keyListener);
    pane.add(pass);

    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.CENTER;
    JPanel panel = new JPanel();
    okButton.addActionListener(actionListener);
    okButton.addKeyListener(keyListener);
    panel.add(okButton);
    cancelButton.addActionListener(actionListener);
    cancelButton.addKeyListener(keyListener);
    panel.add(cancelButton);
    gridbag.setConstraints(panel, c);
    pane.add(panel);

    getContentPane().add(pane);

    pack();
  }
  private HypothecCalculator() {
    initialize();

    KeyAdapter keyListener =
        new KeyAdapter() {
          public void keyReleased(final KeyEvent e) {
            bind();
            viewModel.checkInput();
            backBind();
          }
        };
    houseCost.addKeyListener(keyListener);
    interestRate.addKeyListener(keyListener);
    downPayment.addKeyListener(keyListener);
    countOfPeriods.addKeyListener(keyListener);
    flatFee.addKeyListener(keyListener);
    monthlyFee.addKeyListener(keyListener);
    month.addKeyListener(keyListener);
    year.addKeyListener(keyListener);

    currencyType.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            bind();
            backBind();
          }
        });
    periodType.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            bind();
            backBind();
          }
        });
    interestRateType.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            bind();
            backBind();
          }
        });
    flatFeeType.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            bind();
            backBind();
          }
        });
    monthlyFeeType.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            bind();
            backBind();
          }
        });
    creditType.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            bind();
            backBind();
          }
        });
    compute.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            bind();
            viewModel.compute();
            backBind();
          }
        });
  }
Пример #30
0
  public void gold() throws Exception {
    frm = new JFrame();
    frm.setTitle("Background Color for JFrame");
    // frm.setSize(400, 400);
    frm.setLocationRelativeTo(null);
    // frm.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frm.setVisible(true);
    frm.setLayout(new BorderLayout());
    JLabel background =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\Untitled.jpg"));
    frm.add(background);
    // background.setLayout(new FlowLayout());
    background.setLayout(null);
    lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 7);
    lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 7);
    lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);

    // JLabel l1=new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif"));
    JLabel l1 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif"));
    JLabel l2 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l3 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l4 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l5 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l6 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l7 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l8 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l9 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l0 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));

    txter = new JTextField(100);
    txter.setBounds(3, 4, 0, 35);

    txter.addKeyListener(this);
    txter.getCursor();
    txter.setText(strgr);
    row += 10;
    for (int it = 1; it > 0; it += 7) {
      // Rectangle r=compu
      l1.setBounds(300 + my_car.row, 400 + my_car.col, 90, 190);
      l2.setBounds(lh2, -250 + chg, 90, 190);
      l3.setBounds(lh3, -750 + chg, 90, 190);
      l4.setBounds(lh4, -1200 + chg, 90, 190);
      l5.setBounds(lh5, -1750 + chg, 90, 190);
      l6.setBounds(lh6, -2250 + chg, 90, 190);
      l7.setBounds(lh7, -2700 + chg, 90, 190);
      l8.setBounds(lh8, -3250 + chg, 90, 190);
      l9.setBounds(lh9, -3800 + chg, 90, 190);
      l0.setBounds(lh0, -4250 + chg, 90, 190);
      chg += 20;
      if (chg >= (5000)) {
        chg = 0;
        lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
      }
      txter.requestDefaultFocus();
      {
      }

      Thread.sleep(50);
      System.out.println(my_car.row);
      l1.repaint();
      l2.repaint();

      // b1=new JButton("I am a button");
      background.add(l1);
      background.add(l2);
      background.add(l3);
      background.add(l4);
      background.add(l5);
      background.add(l6);
      background.add(l7);
      background.add(l8);
      background.add(l9);
      background.add(l0);
      background.add(txter);

      // background.add(b1);
      // frm.setSize(799, 699);
      frm.setBounds(0, 0, 800, 700);
      frm.setResizable(false);
    }
  }