Esempio n. 1
0
 public InputFrame(SipModel sipModel) {
   super(Which.INPUT, sipModel, "Input");
   sipModel.addParseListener(
       new SipModel.ParseListener() {
         @Override
         public void updatedRecord(MetadataRecord metadataRecord) {
           exec(new RecordSetter(metadataRecord));
         }
       });
   recordTree =
       new JTree(EMPTY_MODEL) {
         @Override
         public String getToolTipText(MouseEvent evt) {
           TreePath treePath = recordTree.getPathForLocation(evt.getX(), evt.getY());
           return treePath != null
               ? ((GroovyTreeNode) treePath.getLastPathComponent()).toolTip
               : "";
         }
       };
   recordTree.setToolTipText("Input Record");
   recordTree.setCellRenderer(new Renderer());
   recordTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
   recordTree.setTransferHandler(new TreeTransferHandler());
   filterField.addActionListener(rewind);
 }
Esempio n. 2
0
  public Mapper() {
    super("Action/Input Mapper");
    setSize(500, 600);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel setupPane = new JPanel(new GridLayout(0, 1));
    JPanel classPane = new JPanel(new BorderLayout());
    classPane.add(new JLabel("Class: "), BorderLayout.WEST);
    classPane.add(nameF, BorderLayout.CENTER);
    classPane.add(stateC, BorderLayout.EAST);
    JPanel mapPane = new JPanel();
    mapPane.add(inputB);
    mapPane.add(actionB);
    mapPane.add(bindingB);

    setupPane.add(classPane);
    setupPane.add(mapPane);

    getContentPane().add(setupPane, BorderLayout.NORTH);
    getContentPane().add(new JScrollPane(results), BorderLayout.CENTER);

    nameF.addActionListener(this);
    stateC.addActionListener(this);
    stateC.setEditable(false);
    new Probe().loadAudioActions(); // !!!
    setVisible(true);
  }
  public void buildPanel() {
    input.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (input.getText().isEmpty() == false) {
              outputLabel.setText("");
              outputLabel.append(sumNumbers(input.getText()));
              outputLabel.setEditable(false);
            }
          }
        });

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    JLabel header = new JLabel("Sum of all digits");
    JPanel headerFrame = new JPanel();
    headerFrame.add(header);
    mainPanel.add(headerFrame, BorderLayout.NORTH);

    inputPanel.add(inputLabel);
    inputPanel.add(input);
    mainPanel.add(inputPanel, BorderLayout.CENTER);

    outputPanel.add(outputLabel);
    mainPanel.add(outputPanel, BorderLayout.SOUTH);

    topPanel.add(mainPanel);
  }
Esempio n. 4
0
 /*
  *Creates the JTextField for the GUI.
  */
 private JTextField inputField() {
   inputField = new JTextField();
   Border inputBorder = BorderFactory.createEtchedBorder();
   inputBorder = BorderFactory.createTitledBorder(inputBorder, "Please type your words here:");
   inputField.setBorder(inputBorder);
   inputField.addActionListener(new ActionListenerField());
   return inputField;
 }
 /** Constructor */
 public ServiceFilterPanel(String text, Vector list) {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   service_box = new JCheckBox(text);
   service_box.addActionListener(this);
   service_data = new Vector();
   if (list != null) {
     service_box.setSelected(true);
     service_data = (Vector) list.clone();
   }
   service_list = new JList(service_data);
   service_list.setBorder(new EtchedBorder());
   service_list.setVisibleRowCount(5);
   service_list.addListSelectionListener(this);
   service_list.setEnabled(service_box.isSelected());
   service_scroll = new JScrollPane(service_list);
   service_scroll.setBorder(new EtchedBorder());
   remove_service_button = new JButton("Remove");
   remove_service_button.addActionListener(this);
   remove_service_button.setEnabled(false);
   remove_service_panel = new JPanel();
   remove_service_panel.setLayout(new FlowLayout());
   remove_service_panel.add(remove_service_button);
   service_area = new JPanel();
   service_area.setLayout(new BorderLayout());
   service_area.add(service_scroll, BorderLayout.CENTER);
   service_area.add(remove_service_panel, BorderLayout.EAST);
   service_area.setBorder(indent_border);
   add_service_field = new JTextField();
   add_service_field.addActionListener(this);
   add_service_field.getDocument().addDocumentListener(this);
   add_service_field.setEnabled(service_box.isSelected());
   add_service_button = new JButton("Add");
   add_service_button.addActionListener(this);
   add_service_button.setEnabled(false);
   add_service_panel = new JPanel();
   add_service_panel.setLayout(new BorderLayout());
   JPanel dummy = new JPanel();
   dummy.setBorder(empty_border);
   add_service_panel.add(dummy, BorderLayout.WEST);
   add_service_panel.add(add_service_button, BorderLayout.EAST);
   add_service_area = new JPanel();
   add_service_area.setLayout(new BorderLayout());
   add_service_area.add(add_service_field, BorderLayout.CENTER);
   add_service_area.add(add_service_panel, BorderLayout.EAST);
   add_service_area.setBorder(indent_border);
   setLayout(new BorderLayout());
   add(service_box, BorderLayout.NORTH);
   add(service_area, BorderLayout.CENTER);
   add(add_service_area, BorderLayout.SOUTH);
   setBorder(empty_border);
 }
 // --------初始化界面的方法---------
 public void init() {
   JPanel top = new JPanel();
   top.add(new JLabel("输入查询语句:"));
   top.add(sqlField);
   top.add(execBn);
   // 为执行按钮、单行文本框添加事件监听器
   execBn.addActionListener(new ExceListener());
   sqlField.addActionListener(new ExceListener());
   jf.add(top, BorderLayout.NORTH);
   jf.setSize(680, 480);
   jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   jf.setVisible(true);
 }
Esempio n. 7
0
    public EventAdapter(JTextField tf, JTable tbl) {

      boolean autoIme = Project.getBoolean("autoIme", true);
      if (autoIme) {
        tf.addFocusListener(AutoKanjiListener.getInstance());
      } else {
        tf.addFocusListener(AutoRomanListener.getInstance());
      }
      tf.addActionListener(EventAdapter.this);

      tbl.getSelectionModel().addListSelectionListener(EventAdapter.this);
      tbl.addMouseListener(EventAdapter.this);
    }
 /**
  * References checked: 8.10.2003 (2.0b2)
  *
  * @param editorType editor type, one of this constants
  *     <UL>
  *       <LI>EDITOR_TYPE_DEFAULT
  *       <LI>EDITOR_TYPE_STYLED
  *       <LI>EDITOR_TYPE_SINGLE_LINE
  *     </UL>
  *
  * @param controler if not <code>null</code> for <code>EDITOR_TYPE_STYLED</code> editors a toolbar
  *     is created
  * @see PresentationDetail#PresentationDetail
  */
 TextEditorPanel(
     int editorType,
     GraphPanelControler controler,
     boolean showToolbar,
     PresentationDetail detail) {
   this.editorType = editorType;
   this.controler = controler;
   this.showToolbar = showToolbar;
   this.detail = detail;
   setLayout(new BorderLayout());
   // --- build this text editor panel ---
   switch (editorType) {
     case EDITOR_TYPE_DEFAULT:
       textComponent = new JTextArea();
       add(new JScrollPane(textComponent));
       break;
     case EDITOR_TYPE_STYLED:
       textComponent = new JTextPane();
       textComponent.setTransferHandler(new TextTransferHandler()); // ### requires Java 1.4
       // --- add toolbar ---
       if (showToolbar) {
         JPanel bar = new JPanel();
         Hashtable actions = DeepaMehtaClientUtils.createActionTable(textComponent);
         bar.setBackground(COLOR_PROPERTY_PANEL);
         toolbarButtons = new JButton[3];
         addButton(bar, new StyledEditorKit.BoldAction(), actions, controler.boldIcon());
         addButton(bar, new StyledEditorKit.ItalicAction(), actions, controler.italicIcon());
         addButton(bar, new StyledEditorKit.UnderlineAction(), actions, controler.underlineIcon());
         // ### addButton(bar, "H1", CMD_SET_HEADLINE1);
         // ### addButton(bar, "H2", CMD_SET_HEADLINE2);
         add(bar, BorderLayout.SOUTH);
       }
       add(new JScrollPane(textComponent));
       break;
     case EDITOR_TYPE_SINGLE_LINE:
       textComponent = new JTextField();
       ((JTextField) textComponent).addActionListener(this);
       add(textComponent);
       break;
     default:
       throw new DeepaMehtaException("unexpected text editor type: " + editorType);
   }
   // --- enable automatic drag and drop support ---
   try {
     textComponent.setDragEnabled(true);
   } catch (NoSuchMethodError e) {
     // requires JDK 1.4 ###
   }
 }
  public void validAuthenticate() {
    chatStatus.setText("Enter your message below");
    connected = true;

    // disable login button
    login.setEnabled(false);
    // enable the 2 buttons
    logout.setEnabled(true);
    // whoIsIn.setEnabled(true);
    // disable the Server and Port JTextField
    tfServer.setEditable(false);
    tfPort.setEditable(false);
    // Action listener for when the user enter a message
    chatField.addActionListener(this);

    switchCards("Menu");
  }
Esempio n. 10
0
  /** Add listeners to components. */
  private void addListeners() {
    dirBttn.addActionListener(this);
    backupBttn.addActionListener(this);
    runBttn.addActionListener(this);

    recursiveCheckBox.addItemListener(this);
    templateCh.addItemListener(this);

    dirTF.addActionListener(this);

    staticVersioningRadioButton.addItemListener(this);
    dynamicVersioningRadioButton.addItemListener(this);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            quit();
          }
        });
  }
Esempio n. 11
0
 public WordEntryField() {
   // Set up for human player's Text Entry Field
   textField = new JTextField(30);
   myString = new StringBuilder("");
   // Add listener to text entry field
   textField.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           String s = textField.getText().toLowerCase();
           if (myLexicon.wordStatus(s) != LexStatus.WORD) {
             BoggleGUI.this.showError(s + " not in lexicon");
           } else {
             java.util.List<BoardCell> list = myFinder.cellsForWord(myBoard, s);
             myString.delete(0, myString.length());
             for (BoardCell cell : list) {
               myString.append(myBoard.getFace(cell.row, cell.col));
             }
             if (!myString.toString().equals(s)) {
               // if (list.size() != s.length()){
               BoggleGUI.this.showError(s + " not on board");
             } else {
               if (humanPlayer.add(textField.getText().toLowerCase())) {
                 humanArea.showWord(s, list, humanPlayer);
                 myBoardPanel.highlightDice(list);
               }
             }
           }
         }
       });
   myDoneButton = new JButton("DONE");
   myDoneButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           gameOver();
         }
       });
   this.add(new JLabel("Enter word: "));
   this.add(textField);
   this.add(myDoneButton);
   setUnready();
 }
  void setupEntry() {
    textInput = new JTextField();
    if (parameter.getSingleParameterList() != null)
      textInput.setText(parameter.getSingleParameterList().getFirst().toString());
    optionPane =
        new JOptionPane(
            prompt(),
            JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);
    setContentPane(optionPane);

    textInput.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Logger.log("The text entered was " + textInput.getText());
            optionPane.setValue("Done");
          }
        });
  }
  /**
   * The constructor.
   *
   * @param parent The parent window.
   * @param idata The installation data.
   */
  public SudoPanel(InstallerFrame parent, InstallData idata) {
    super(parent, idata);

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

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.info")*/ "For installing administrator privileges are necessary",
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.tip")*/ "Please note that passwords are case-sensitive",
            parent.icons.getImageIcon("tip"),
            JLabel.TRAILING));

    add(Box.createRigidArea(new Dimension(0, 5)));

    JPanel spacePanel = new JPanel();
    spacePanel.setAlignmentX(LEFT_ALIGNMENT);
    spacePanel.setAlignmentY(CENTER_ALIGNMENT);
    spacePanel.setBorder(BorderFactory.createEmptyBorder(80, 30, 0, 50));
    spacePanel.setLayout(new BorderLayout(5, 5));
    spacePanel.add(
        new JLabel(
            /*parent.langpack.getString("SudoPanel.specifyAdminPassword")*/ "Please specify your password:"),
        BorderLayout.NORTH);
    passwordField = new JPasswordField();
    passwordField.addActionListener(this);
    JPanel space2Panel = new JPanel();
    space2Panel.setLayout(new BorderLayout());
    space2Panel.add(passwordField, BorderLayout.NORTH);
    space2Panel.add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.CENTER);
    spacePanel.add(space2Panel, BorderLayout.CENTER);
    add(spacePanel);
  }
 /** The constructor */
 private BranchNameEditor() {
   myDefaultForeground = myTextField.getForeground();
   myTextField
       .getDocument()
       .addDocumentListener(
           new DocumentAdapter() {
             @Override
             protected void textChanged(DocumentEvent e) {
               String s = myTextField.getText();
               if ((myInvalidValues == null || !myInvalidValues.contains(s))
                   && (s.length() == 0 || BranchNameValidator.INSTANCE.checkInput(s))) {
                 myTextField.setForeground(myDefaultForeground);
               } else {
                 myTextField.setForeground(Color.RED);
               }
             }
           });
   myTextField.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopCellEditing();
         }
       });
   myPanel.add(
       myTextField,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(0, 0, 0, 0),
           0,
           0));
 }
  /*-------------------------------------------------------------------------*/
  protected JPanel getEditControls() {
    impl = new JTextField(30);
    impl.addActionListener(this);
    impl.addKeyListener(this);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.NORTHWEST;

    JPanel result = new JPanel(new GridBagLayout());

    result.add(new JLabel("Impl:"), gbc);
    gbc.weightx = 1.0;
    gbc.gridx++;
    result.add(impl, gbc);

    sortOrder = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1));

    gbc.weightx = 0.0;
    gbc.gridx = 0;
    gbc.gridy++;
    result.add(new JLabel("Sort Order:"), gbc);

    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.gridx++;
    result.add(sortOrder, gbc);

    return result;
  }
  private void setupActions() {

    wordList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            wordEditField.setText((String) wordList.getSelectedValue());
            wordEditField.selectAll();
            new FocusRequester(wordEditField);
          }
        });

    newWord.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            newWordAction();
          }
        });

    wordEditFieldListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int index = wordList.getSelectedIndex();
            String old = (String) wordList.getSelectedValue(), newVal = wordEditField.getText();
            if (newVal.equals("") || newVal.equals(old)) {
              return; // Empty string or no change.
            }
            if (wordListModel.contains(newVal)) {
              // ensure that word already in list is visible
              index = wordListModel.indexOf(newVal);
              wordList.ensureIndexIsVisible(index);
              return;
            }

            int newIndex = findPos(wordListModel, newVal);
            if (index >= 0) {
              // initiate replacement of selected word
              wordListModel.remove(index);
              if (newIndex > index) {
                // newIndex has to be adjusted after removal of previous entry
                newIndex--;
              }
            }
            wordListModel.add(newIndex, newVal);
            wordList.ensureIndexIsVisible(newIndex);
            wordEditField.selectAll();
          }
        };
    wordEditField.addActionListener(wordEditFieldListener);

    removeWord.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int index = wordList.getSelectedIndex();
            if (index == -1) return;
            wordListModel.remove(index);
            wordEditField.setText("");
            if (wordListModel.size() > 0)
              wordList.setSelectedIndex(Math.min(index, wordListModel.size() - 1));
          }
        });

    fieldList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            currentField = (String) fieldList.getSelectedValue();
            fieldNameField.setText("");
            setupWordSelector();
          }
        });

    newField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!fieldListModel.get(0).equals(FIELD_FIRST_LINE)) {
              // only add <field name> once
              fieldListModel.add(0, FIELD_FIRST_LINE);
            }
            fieldList.setSelectedIndex(0);
            fPane.getVerticalScrollBar().setValue(0);
            fieldNameField.setEnabled(true);
            fieldNameField.setText(currentField);
            fieldNameField.selectAll();

            new FocusRequester(fieldNameField);
          }
        });

    fieldNameField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fieldNameField.transferFocus();
          }
        });

    fieldNameField.addFocusListener(
        new FocusAdapter() {

          /** Adds the text value to the list */
          public void focusLost(FocusEvent e) {
            String s = fieldNameField.getText();
            fieldNameField.setText("");
            fieldNameField.setEnabled(false);
            if (!FIELD_FIRST_LINE.equals(s) && !"".equals(s)) {
              // user has typed something

              // remove "<first name>" from list
              fieldListModel.remove(0);

              int pos;
              if (fieldListModel.contains(s)) {
                // field already exists, scroll to that field (below)
                pos = fieldListModel.indexOf(s);
              } else {
                // Add new field.
                pos = findPos(fieldListModel, s);
                fieldListModel.add(Math.max(0, pos), s);
              }
              fieldList.setSelectedIndex(pos);
              fieldList.ensureIndexIsVisible(pos);
              currentField = s;
              setupWordSelector();
              newWordAction();
              // new FocusRequester(wordEditField);
            }
          }
        });

    removeField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int index = fieldList.getSelectedIndex();
            if (index == -1) return;
            String fieldName = (String) fieldListModel.get(index);
            removedFields.add(fieldName);
            fieldListModel.remove(index);
            wordListModels.remove(fieldName);
            fieldNameField.setText("");
            if (fieldListModel.size() > 0)
              fieldList.setSelectedIndex(Math.min(index, wordListModel.size() - 1));
          }
        });

    help.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            frame.helpDiag.showPage(GUIGlobals.contentSelectorHelp);
          }
        });

    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            applyChanges();
            dispose();
          }
        });

    apply.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Store if an entry is currently being edited:
            if (!wordEditField.getText().equals("")) {
              wordEditFieldListener.actionPerformed(null);
            }
            applyChanges();
          }
        });

    @SuppressWarnings("serial")
    Action cancelAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        };
    cancelAction.putValue(Action.NAME, Globals.lang("Cancel"));
    cancel.setAction(cancelAction);
  }
Esempio n. 17
0
  private void jbInit() throws Exception {
    titledBorder1 = new TitledBorder("");
    this.setLayout(baseLayout);

    double[][] lower_size = {
      {TableLayout.PREFERRED, TableLayout.FILL, 25}, {25, 25, TableLayout.FILL}
    };
    mLowerPanelLayout = new TableLayout(lower_size);

    mLowerPanel.setLayout(mLowerPanelLayout);

    double[][] dir_size = {
      {TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED, TableLayout.FILL}
    };
    mDirectionsPanelLayout = new TableLayout(dir_size);
    mDirectionsPanel.setLayout(mDirectionsPanelLayout);

    // Try to get icons for the toolbar buttons
    try {
      ClassLoader loader = getClass().getClassLoader();
      mAddIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/add.gif"));
      mRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove.gif"));
      mDisabledRemoveIcon =
          new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove_disabled.gif"));

      mAddNodeBtn.setIcon(mAddIcon);
      mRemoveNodeBtn.setIcon(mRemoveIcon);
      mRemoveNodeBtn.setDisabledIcon(mDisabledRemoveIcon);
    } catch (Exception e) {
      // Ack! No icons. Use text labels instead
      mAddNodeBtn.setText("Add");
      mRemoveNodeBtn.setText("Remove");
    }

    /*
    mAddNodeBtn.setMaximumSize(new Dimension(130, 33));
    mAddNodeBtn.setMinimumSize(new Dimension(130, 33));
    mAddNodeBtn.setPreferredSize(new Dimension(130, 33));
    mAddNodeBtn.setText("Add Node");
    */
    mAddNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    /*
    mRemoveNodeBtn.setMaximumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setMinimumSize(new Dimension(130, 33));
    mRemoveNodeBtn.setPreferredSize(new Dimension(130, 33));
    mRemoveNodeBtn.setText("Remove Node");
    */
    mRemoveNodeBtn.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mRemoveNode();
          }
        });
    mHostnameLabel.setHorizontalAlignment(SwingConstants.TRAILING);
    mHostnameLabel.setLabelFor(mHostnameField);
    mHostnameLabel.setText("Hostname:");

    mHostnameField.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mAddNodeBtn_actionPerformed(e);
          }
        });
    mDirectionsPanel.setBorder(BorderFactory.createEtchedBorder());
    mTitleLabel.setFont(new java.awt.Font("Serif", 1, 20));
    mTitleLabel.setHorizontalAlignment(SwingConstants.CENTER);
    mTitleLabel.setText("Add Cluster Nodes");
    mDirectionsLabel.setText("Click on the add button to add nodes to your cluster configuration.");
    mDirectionsLabel.setLineWrap(true);
    mDirectionsLabel.setEditable(false);
    mDirectionsLabel.setBackground(mTitleLabel.getBackground());

    baseLayout.setHgap(5);
    baseLayout.setVgap(5);
    mLowerPanel.add(
        mHostnameLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mHostnameField, new TableLayoutConstraints(1, 0, 1, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mListScrollPane1,
        new TableLayoutConstraints(0, 1, 1, 2, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mAddNodeBtn, new TableLayoutConstraints(2, 0, 2, 0, TableLayout.FULL, TableLayout.FULL));
    mLowerPanel.add(
        mRemoveNodeBtn, new TableLayoutConstraints(2, 1, 2, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mLowerPanel, BorderLayout.CENTER);
    mListScrollPane1.getViewport().add(lstNodes, null);
    mDirectionsPanel.add(
        mTitleLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mDirectionsLabel,
        new TableLayoutConstraints(0, 1, 0, 1, TableLayout.FULL, TableLayout.FULL));
    mDirectionsPanel.add(
        mIconLabel, new TableLayoutConstraints(1, 0, 1, 1, TableLayout.FULL, TableLayout.FULL));
    this.add(mDirectionsPanel, BorderLayout.NORTH);
  }
Esempio n. 18
0
  public EditorPaneHTMLHelp(String htmlFile) {
    if (GlobalValues.useSystemBrowserForHelp) {
      Desktop d = GlobalValues.desktop;
      try {
        // create a temp file
        GlobalValues.forHTMLHelptempFile = new File("tempHTMLHelpSynthetic.html");
        FileWriter fw = new FileWriter(GlobalValues.forHTMLHelptempFile);

        java.util.List<String> list = readTextFromJar(htmlFile);
        Iterator<String> it = list.iterator();
        while (it.hasNext()) {
          fw.write(it.next() + "\n");
        }

        String canonicalPathOfFile = GlobalValues.forHTMLHelptempFile.getCanonicalPath();
        URL urlFile = new URL("file://" + canonicalPathOfFile);
        URI uriOfFile = urlFile.toURI();

        fw.close();

        d.browse(uriOfFile);

      } catch (Exception e) {
        e.printStackTrace();
      }

    } else {
      URL initialURL = getClass().getResource(htmlFile);

      font = GlobalValues.htmlfont;

      String title = "HTML Help";
      setTitle(title);

      final Stack<String> urlStack = new Stack<String>();
      final JEditorPane editorPane;

      editorPane = new JEditorPane(new HTMLEditorKit().getContentType(), " ");

      editorPane.setOpaque(false);
      editorPane.setBorder(null);
      editorPane.setEditable(false);

      JPanel magPanel = new JPanel();

      magnificationFactor = GlobalValues.helpMagnificationFactor;
      magFactor = new JTextField(Double.toString(magnificationFactor));

      JButton magButton = new JButton("Set Magnification: ");
      magButton.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              magnificationFactor = Double.parseDouble(magFactor.getText());
              GlobalValues.helpMagnificationFactor = magnificationFactor;
            }
          });

      magPanel.setLayout(new GridLayout(1, 2));
      magPanel.add(magButton);
      magPanel.add(magFactor);

      final JTextField url = new JTextField(initialURL.toString());

      // set up hyperlink listener
      editorPane.setEditable(false);

      try {
        // remember URL for back button
        urlStack.push(initialURL.toString());
        // show URL in text field
        url.setText(initialURL.toString());

        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss

        String bodyRule =
            "body { font-family: "
                + font.getFamily()
                + "; "
                + "font-size: "
                + font.getSize() * GlobalValues.helpMagnificationFactor
                + "pt; }";
        ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule);

        editorPane.setPage(initialURL);

        editorPane.firePropertyChange("dummyProp", true, false);

      } catch (IOException e) {
        editorPane.setText("Exception: " + e);
      }

      editorPane.addPropertyChangeListener(
          new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent evt) {

              String bodyRule =
                  "body { font-family: "
                      + font.getFamily()
                      + "; "
                      + "font-size: "
                      + font.getSize() * GlobalValues.helpMagnificationFactor
                      + "pt; }";
              ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule);
            }
          });

      editorPane.addHyperlinkListener(
          new HyperlinkListener() {
            public void hyperlinkUpdate(HyperlinkEvent event) {
              if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                try {
                  // remember URL for back button
                  urlStack.push(event.getURL().toString());
                  // show URL in text field
                  url.setText(event.getURL().toString());
                  editorPane.setPage(event.getURL());

                  editorPane.firePropertyChange("dummyProp", true, false);

                } catch (IOException e) {
                  editorPane.setText("Exception: " + e);
                }
              }
            }
          });

      // set up checkbox for toggling edit mode
      final JCheckBox editable = new JCheckBox();
      editable.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              editorPane.setEditable(editable.isSelected());
            }
          });

      // set up load button for loading URL
      ActionListener listener =
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              try {
                // remember URL for back button
                urlStack.push(url.getText());
                editorPane.setPage(url.getText());

                editorPane.firePropertyChange("dummyProp", true, false);

              } catch (IOException e) {
                editorPane.setText("Exception: " + e);
              }
            }
          };

      JButton loadButton = new JButton("Load/Magnify");
      loadButton.addActionListener(listener);
      url.addActionListener(listener);

      // set up back button and button action

      JButton backButton = new JButton("Back");
      backButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              if (urlStack.size() <= 1) return;
              try {
                // get URL from back button
                urlStack.pop();
                // show URL in text field
                String urlString = urlStack.peek();
                url.setText(urlString);
                editorPane.setPage(urlString);

                editorPane.firePropertyChange("dummyProp", true, false);

              } catch (IOException e) {
                editorPane.setText("Exception: " + e);
              }
            }
          });

      JPanel allPanel = new JPanel(new BorderLayout());

      // put all control components in a panel

      JPanel ctrlPanel = new JPanel(new BorderLayout());
      JPanel urlPanel = new JPanel();
      urlPanel.add(new JLabel("URL"));
      urlPanel.add(url);
      JPanel buttonPanel = new JPanel();
      buttonPanel.add(loadButton);
      buttonPanel.add(backButton);
      buttonPanel.add(new JLabel("Editable"));
      buttonPanel.add(magPanel);
      buttonPanel.add(editable);
      ctrlPanel.add(buttonPanel, BorderLayout.NORTH);
      ctrlPanel.add(urlPanel, BorderLayout.CENTER);

      allPanel.add(ctrlPanel, BorderLayout.NORTH);
      allPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER);

      add(allPanel);
    }
  }
  /**
   * 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();
  }
  public EditorPaneFrame() {
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    final Stack<String> urlStack = new Stack<>();
    final JEditorPane editorPane = new JEditorPane();
    final JTextField url = new JTextField(30);

    // set up hyperlink listener

    editorPane.setEditable(false);
    editorPane.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent event) {
            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                // remember URL for back button
                urlStack.push(event.getURL().toString());
                // show URL in text field
                url.setText(event.getURL().toString());
                editorPane.setPage(event.getURL());
              } catch (IOException e) {
                editorPane.setText("Exception: " + e);
              }
            }
          }
        });

    // set up checkbox for toggling edit mode

    final JCheckBox editable = new JCheckBox();
    editable.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            editorPane.setEditable(editable.isSelected());
          }
        });

    // set up load button for loading URL

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            try {
              // remember URL for back button
              urlStack.push(url.getText());
              editorPane.setPage(url.getText());
            } catch (IOException e) {
              editorPane.setText("Exception: " + e);
            }
          }
        };

    JButton loadButton = new JButton("Load");
    loadButton.addActionListener(listener);
    url.addActionListener(listener);

    // set up back button and button action

    JButton backButton = new JButton("Back");
    backButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            if (urlStack.size() <= 1) return;
            try {
              // get URL from back button
              urlStack.pop();
              // show URL in text field
              String urlString = urlStack.peek();
              url.setText(urlString);
              editorPane.setPage(urlString);
            } catch (IOException e) {
              editorPane.setText("Exception: " + e);
            }
          }
        });

    add(new JScrollPane(editorPane), BorderLayout.CENTER);

    // put all control components in a panel

    JPanel panel = new JPanel();
    panel.add(new JLabel("URL"));
    panel.add(url);
    panel.add(loadButton);
    panel.add(backButton);
    panel.add(new JLabel("Editable"));
    panel.add(editable);

    add(panel, BorderLayout.SOUTH);
  }
Esempio n. 21
0
 private void jbInit() throws Exception {
   ////////////////////////////////////////////////////////
   // Init LAF
   ////////////////////////////////////////////////////////
   ButtonGroup grpLAF = new ButtonGroup();
   ActionListener lsnLAF =
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iIndex = mvtLAFItem.indexOf(evt.getSource());
           if (iIndex >= 0) changeLAF(iIndex);
         }
       };
   ////////////////////////////////////////////////////////
   UIManager.LookAndFeelInfo laf =
       new UIManager.LookAndFeelInfo(
           "Kunststoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel");
   marrLaf = UIManager.getInstalledLookAndFeels();
   int iIndex = 0;
   while (iIndex < marrLaf.length && !marrLaf[iIndex].getName().equals(laf.getName())) iIndex++;
   if (iIndex >= marrLaf.length) {
     UIManager.installLookAndFeel(laf);
     marrLaf = UIManager.getInstalledLookAndFeels();
   }
   for (iIndex = 0; iIndex < marrLaf.length; iIndex++) {
     JMenuItem mnu = new JRadioButtonMenuItem(marrLaf[iIndex].getName());
     mnu.addActionListener(lsnLAF);
     mvtLAFItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLAF.add(mnu);
   }
   mnuUI.addSeparator();
   ////////////////////////////////////////////////////////
   // Init language
   ////////////////////////////////////////////////////////
   ButtonGroup grpLanguage = new ButtonGroup();
   ActionListener lsnLanguage =
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           int iIndex = mvtLanguageItem.indexOf(e.getSource());
           if (iIndex >= 0) changeDictionary((String) mvtLanguage.elementAt(iIndex));
         }
       };
   ////////////////////////////////////////////////////////
   String[] str = MonitorDictionary.getSupportedLanguage();
   for (iIndex = 0; iIndex < str.length; iIndex++) {
     JMenuItem mnu =
         new JRadioButtonMenuItem(MonitorDictionary.getDictionary(str[iIndex]).getLanguage());
     mnu.addActionListener(lsnLanguage);
     mvtLanguage.addElement(str[iIndex]);
     mvtLanguageItem.addElement(mnu);
     mnuUI.add(mnu);
     grpLanguage.add(mnu);
   }
   ////////////////////////////////////////////////////////
   // Add to main menu
   ////////////////////////////////////////////////////////
   mnuMain.removeAll();
   mnuMain.add(mnuSystem);
   mnuSystem.add(mnuSystem_Login);
   mnuSystem.add(mnuSystem_ChangePassword);
   mnuSystem.addSeparator();
   mnuSystem.add(mnuSystem_StopServer);
   mnuSystem.add(mnuSystem_EnableThreads);
   mnuMain.add(mnuUI);
   mnuMain.add(mnuHelp);
   mnuHelp.add(mnuHelp_About);
   ////////////////////////////////////////////////////////
   mnuMain.add(chkVietnamese);
   mnuMain.add(lblStatus);
   ////////////////////////////////////////////////////////
   pnlThread.setTabPlacement(JTabbedPane.LEFT);
   pnlThread.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
   ////////////////////////////////////////////////////////
   tblUser.addColumn("", 1, false);
   tblUser.addColumn("", 2, false, Global.FORMAT_DATE_TIME);
   tblUser.addColumn("", 3, false);
   ////////////////////////////////////////////////////////
   JPanel pnlMessage = new JPanel();
   pnlMessage.setLayout(new GridBagLayout());
   pnlMessage.add(
       new JScrollPane(txtBoard),
       new GridBagConstraints(
           0,
           0,
           2,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       txtMessage,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           1.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlMessage.add(
       btnSend,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(2, 2, 2, 2),
           0,
           0));
   txtBoard.setEditable(false);
   txtBoard.setAutoscrolls(true);
   txtBoard.setContentType("text/html");
   clearAll(txtBoard);
   ////////////////////////////////////////////////////////
   JPanel pnlUserButton = new JPanel(new GridLayout(1, 2, 4, 4));
   pnlUserButton.add(btnKick);
   pnlUserButton.add(btnRefresh);
   ////////////////////////////////////////////////////////
   JPanel pnlManager = new JPanel(new GridBagLayout());
   pnlManager.add(
       new JScrollPane(tblUser),
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           1.0,
           1.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.BOTH,
           new Insets(2, 2, 2, 2),
           0,
           0));
   pnlManager.add(
       pnlUserButton,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(4, 2, 4, 2),
           0,
           0));
   ////////////////////////////////////////////////////////
   pnlUser.setDividerLocation(320);
   pnlUser.setLeftComponent(pnlManager);
   pnlUser.setRightComponent(pnlMessage);
   pnlUser.setOneTouchExpandable(true);
   ////////////////////////////////////////////////////////
   setOrientation(JSplitPane.VERTICAL_SPLIT);
   setOneTouchExpandable(true);
   pnlThread.setVisible(false);
   pnlUser.setVisible(false);
   setTopComponent(pnlThread);
   setBottomComponent(pnlUser);
   ////////////////////////////////////////////////////////
   pmn.add(mnuSelectAll);
   pmn.addSeparator();
   pmn.add(mnuClearSelected);
   pmn.add(mnuClearAll);
   ////////////////////////////////////////////////////////
   setBorder(BorderFactory.createEmptyBorder());
   pnlUser.setBorder(BorderFactory.createEmptyBorder());
   pnlManager.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   pnlMessage.setBorder(
       BorderFactory.createBevelBorder(
           javax.swing.border.BevelBorder.RAISED,
           Color.white,
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background"),
           UIManager.getColor("Panel.background")));
   ////////////////////////////////////////////////////////
   Skin.applySkin(mnuMain);
   Skin.applySkin(tblUser);
   Skin.applySkin(pmn);
   Skin.applySkin(this);
   ////////////////////////////////////////////////////////
   // Default setting
   ////////////////////////////////////////////////////////
   Hashtable prt = null;
   try {
     prt = Global.loadHashtable(Global.FILE_CONFIG);
   } catch (Exception e) {
     prt = new Hashtable();
   }
   changeLAF(Integer.parseInt(StringUtil.nvl(prt.get("LAF"), "0")));
   changeDictionary(StringUtil.nvl(prt.get("Language"), "VN"));
   Skin.LANGUAGE_CHANGE_LISTENER = this;
   MonitorProcessor.setRootObject(this);
   updateKeyboardUI();
   ////////////////////////////////////////////////////////
   // Event handler
   ////////////////////////////////////////////////////////
   tblUser.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() > 1) btnKick.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnRefresh.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           try {
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             DDTP response = channel.sendRequest("ThreadProcessor", "queryUserList", request);
             if (response != null) {
               tblUser.setData((Vector) response.getReturn());
               if (mstrChannel != null) removeUser(mstrChannel);
             }
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   btnKick.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           int iSelected = tblUser.getSelectedRow();
           if (iSelected < 0) return;
           int iResult =
               MessageBox.showConfirmDialog(
                   pnlThread,
                   mdic.getString("ConfirmKick"),
                   Global.APP_NAME,
                   MessageBox.YES_NO_OPTION);
           if (iResult == MessageBox.NO_OPTION) return;
           try {
             String strChannel = (String) tblUser.getRow(iSelected).elementAt(0);
             DDTP request = new DDTP();
             request.setRequestID(String.valueOf(System.currentTimeMillis()));
             request.setString("strChannel", strChannel);
             DDTP response = channel.sendRequest("ThreadProcessor", "kickUser", request);
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   txtMessage.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           btnSend.doClick();
         }
       });
   ////////////////////////////////////////////////////////
   btnSend.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           if (txtMessage.getText().length() == 0) return;
           try {
             DDTP request = new DDTP();
             request.setString("strMessage", txtMessage.getText());
             channel.sendRequest("ThreadProcessor", "sendMessage", request);
             txtMessage.setText("");
           } catch (Exception e) {
             e.printStackTrace();
             MessageBox.showMessageDialog(pnlThread, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
           }
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           clearAll(txtBoard);
         }
       });
   ////////////////////////////////////////////////////////
   mnuClearSelected.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.setEditable(true);
           txtBoard.replaceSelection("");
           txtBoard.setEditable(false);
         }
       });
   ////////////////////////////////////////////////////////
   mnuSelectAll.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           txtBoard.requestFocus();
           txtBoard.selectAll();
         }
       });
   ////////////////////////////////////////////////////////
   txtBoard.addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           if (e.getButton() == e.BUTTON3) pmn.show(txtBoard, e.getX(), e.getY());
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_Login.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           login();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_ChangePassword.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           changePassword();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_StopServer.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           stopServer();
         }
       });
   ////////////////////////////////////////////////////////
   mnuSystem_EnableThreads.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           manageThreads();
         }
       });
   ////////////////////////////////////////////////////////
   mnuHelp_About.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           WindowManager.centeredWindow(new DialogAbout(PanelThreadManager.this));
         }
       });
   ////////////////////////////////////////////////////////
   chkVietnamese.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           switchKeyboard();
         }
       });
 }
Esempio n. 22
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);
    }
  }
Esempio n. 23
0
  /** Construct the TV object - that is, the main GUI for the program */
  public TV(JFrame f, TD mod) {
    super();
    frm = f;
    theTD = mod;
    JButton b;

    // Build the GUI

    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.getAccessibleContext().setAccessibleName("File Toolbar");
    toolBar.addSeparator();
    b = addTool(toolBar, "Cut");
    b = addTool(toolBar, "Copy");
    b = addTool(toolBar, "Paste");
    toolBar.addSeparator();
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.FALSE);

    // The Slider
    numSlider = new JSlider(JSlider.HORIZONTAL, 1, 40, 1);
    numSlider.setPaintTicks(true);
    numSlider.setPaintLabels(false);
    numSlider.setMajorTickSpacing(10);
    numSlider.setMinorTickSpacing(2);
    numSlider.setExtent(1);
    numSlider.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent ce) {
            // System.out.println("CHANGE: " + ce);
            setQNumber(((JSlider) (ce.getSource())).getValue());
          }
        });
    numSlider.setToolTipText("Slide to select question by number");
    toolBar.add(numSlider);

    // The Question# textfield
    toolBar.add(numTF = new JTextField("01"));
    numTF.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String num = ((JTextField) e.getSource()).getText();
            int n = Integer.parseInt(num.trim());
            setQNumber(n);
          }
        });
    numTF.setToolTipText("Type number to select question by number");

    // The First Button
    b = addTool(toolBar, "First");
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setQNumber(1);
          }
        });

    // The Previous Button
    b = addTool(toolBar, "Previous");
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (getQNumber() <= 1) return;
            setQNumber(getQNumber() - 1);
          }
        });

    // The Next Button
    b = addTool(toolBar, "Next");
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (getQNumber() >= getNumQuestions()) return;
            setQNumber(getQNumber() + 1);
          }
        });

    // The "Last" Button
    b = addTool(toolBar, "Last");
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setQNumber(getNumQuestions());
          }
        });

    add(BorderLayout.NORTH, toolBar);

    // Rest is a panel to hold the questions, one at a time.
    questionsPanel = new JPanel();
    questionsPanel.setLayout(myCardLayout = new CardLayout());

    add(BorderLayout.SOUTH, questionsPanel);

    fc = new FileDialog(frm);
    fc.setFilenameFilter(
        new FilenameFilter() {
          public boolean accept(File ff, String fname) {
            // System.out.println("accept("+fname+")");
            // XXX TODO list of extentions, from properties.
            return fname.endsWith(".xam");
          }
        });
    TV.centre(fc);
  }
  public void installComponents(JFileChooser fc) {
    fc.setLayout(new BorderLayout(10, 10));
    fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    JPanel interior =
        new JPanel() {
          public Insets getInsets() {
            return insets;
          }
        };
    align(interior);
    interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));

    fc.add(interior, BorderLayout.CENTER);

    // PENDING(jeff) - I18N
    JLabel l = new JLabel(pathLabelText);
    l.setDisplayedMnemonic(pathLabelMnemonic);
    align(l);
    interior.add(l);

    File currentDirectory = fc.getCurrentDirectory();
    String curDirName = null;
    if (currentDirectory != null) {
      curDirName = currentDirectory.getPath();
    }
    pathField =
        new JTextField(curDirName) {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(pathField);
    align(pathField);

    // Change to folder on return
    pathField.addActionListener(getUpdateAction());
    interior.add(pathField);

    interior.add(Box.createRigidArea(vstrut10));

    // CENTER: left, right accessory
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
    align(centerPanel);

    // left panel - Filter & folderList
    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    align(leftPanel);

    // add the filter PENDING(jeff) - I18N
    l = new JLabel(filterLabelText);
    l.setDisplayedMnemonic(filterLabelMnemonic);
    align(l);
    leftPanel.add(l);

    filterComboBox =
        new JComboBox() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filterComboBox);
    filterComboBoxModel = createFilterComboBoxModel();
    filterComboBox.setModel(filterComboBoxModel);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    fc.addPropertyChangeListener(filterComboBoxModel);
    align(filterComboBox);
    leftPanel.add(filterComboBox);

    // leftPanel.add(Box.createRigidArea(vstrut10));

    // Add the Folder List PENDING(jeff) - I18N
    l = new JLabel(foldersLabelText);
    l.setDisplayedMnemonic(foldersLabelMnemonic);
    align(l);
    leftPanel.add(l);
    JScrollPane sp = createDirectoryList();
    sp.getVerticalScrollBar().setFocusable(false);
    sp.getHorizontalScrollBar().setFocusable(false);
    l.setLabelFor(sp.getViewport().getView());
    leftPanel.add(sp);

    // create files list
    JPanel rightPanel = new JPanel();
    align(rightPanel);
    rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));

    l = new JLabel(filesLabelText);
    l.setDisplayedMnemonic(filesLabelMnemonic);
    align(l);
    rightPanel.add(l);
    sp = createFilesList();
    l.setLabelFor(sp);
    rightPanel.add(sp);

    centerPanel.add(leftPanel);
    centerPanel.add(Box.createRigidArea(hstrut10));
    centerPanel.add(rightPanel);

    JComponent accessoryPanel = getAccessoryPanel();
    JComponent accessory = fc.getAccessory();
    if (accessoryPanel != null) {
      if (accessory == null) {
        accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
        accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
      } else {
        getAccessoryPanel().add(accessory, BorderLayout.CENTER);
        accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
        accessoryPanel.setMaximumSize(MAX_SIZE);
      }
      align(accessoryPanel);
      centerPanel.add(accessoryPanel);
    }
    interior.add(centerPanel);
    interior.add(Box.createRigidArea(vstrut10));

    // add the filename field PENDING(jeff) - I18N
    l = new JLabel(enterFileNameLabelText);
    l.setDisplayedMnemonic(enterFileNameLabelMnemonic);
    align(l);
    interior.add(l);

    filenameTextField =
        new JTextField() {
          public Dimension getMaximumSize() {
            Dimension d = super.getMaximumSize();
            d.height = getPreferredSize().height;
            return d;
          }
        };
    l.setLabelFor(filenameTextField);
    filenameTextField.addActionListener(getApproveSelectionAction());
    align(filenameTextField);
    filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    interior.add(filenameTextField);

    bottomPanel = getBottomPanel();
    bottomPanel.add(new JSeparator(), BorderLayout.NORTH);

    // Add buttons
    JPanel buttonPanel = new JPanel();
    align(buttonPanel);
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.add(Box.createGlue());

    approveButton =
        new JButton(getApproveButtonText(fc)) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    approveButton.setMnemonic(getApproveButtonMnemonic(fc));
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    align(approveButton);
    approveButton.setMargin(buttonMargin);
    approveButton.addActionListener(getApproveSelectionAction());
    buttonPanel.add(approveButton);
    buttonPanel.add(Box.createGlue());

    JButton updateButton =
        new JButton(updateButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    updateButton.setMnemonic(updateButtonMnemonic);
    updateButton.setToolTipText(updateButtonToolTipText);
    align(updateButton);
    updateButton.setMargin(buttonMargin);
    updateButton.addActionListener(getUpdateAction());
    buttonPanel.add(updateButton);
    buttonPanel.add(Box.createGlue());

    JButton cancelButton =
        new JButton(cancelButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    cancelButton.setMnemonic(cancelButtonMnemonic);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    align(cancelButton);
    cancelButton.setMargin(buttonMargin);
    cancelButton.addActionListener(getCancelSelectionAction());
    buttonPanel.add(cancelButton);
    buttonPanel.add(Box.createGlue());

    JButton helpButton =
        new JButton(helpButtonText) {
          public Dimension getMaximumSize() {
            return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
          }
        };
    helpButton.setMnemonic(helpButtonMnemonic);
    helpButton.setToolTipText(helpButtonToolTipText);
    align(helpButton);
    helpButton.setMargin(buttonMargin);
    helpButton.setEnabled(false);
    buttonPanel.add(helpButton);
    buttonPanel.add(Box.createGlue());

    bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
    if (fc.getControlButtonsAreShown()) {
      fc.add(bottomPanel, BorderLayout.SOUTH);
    }
  }
Esempio n. 25
0
  /**
   * The constructor creates the NodeTable and DirectedGraph taken the information from files
   * lines-gbg.txt and stops-gbg.txt and makes itself visible.
   */
  public ShortRoute(String file) {

    // try to convert to UTF-8 across plattforms to make Swedish chars work
    // System.out.println("charset = " + java.nio.charset.Charset.defaultCharset());
    // MacRoman macintosh  Windows-1252 ISO 8859-1 UTF-8
    try {
      // convert whatever this file is encoded in to UTF-8,
      // kill the exception (can't happen)
      introText =
          new String(
              introText.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8");
      felTextStart =
          new String(
              felTextStart.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8");
      felTextSlut =
          new String(
              felTextSlut.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8");
      frome =
          new String(frome.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8");
    } catch (UnsupportedEncodingException e) {
      System.exit(0);
    }

    // read the graph and draw it in a separate window
    // creates the graph and fills the p-queue "names"
    karta.setLocation(50, 250);
    if (file == null) {
      readAndDrawGraph();
    } else {
      readAndDrawBIGGraph(file);
    }
    System.out.println("Version with sorting fixed"); // debug
    // now to the graphics in the Frame
    // Left part
    // select is a panel for structuring the left part
    // i.e label, textfield for "from", label, textfield for "to"
    JPanel select = new JPanel(new GridLayout(4, 1));
    select.setBackground(Color.yellow);
    select.add(new JLabel("Ange startpunkt !", JLabel.CENTER));
    select.add(from);
    select.add(new JLabel("Ange slutpunkt !", JLabel.CENTER));
    select.add(to);
    from.setBackground(Color.white);
    from.setForeground(Color.blue);
    to.setBackground(Color.white);
    to.setForeground(Color.blue);
    from.addActionListener(this);
    to.addActionListener(this);

    // Middle part
    // route is the middle text area part where messages are displayed
    // give the middle text area a scrollbar to the right
    route = new JTextArea(introText, 12, 40);
    route.setEditable(false);
    JScrollPane routeScrollPane = new JScrollPane(route);
    routeScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    route.setBackground(Color.white);
    route.setForeground(Color.blue);

    // Rigth part
    JLabel head = new JLabel("   ****        Alternativ     *****     ");
    head.setForeground(Color.red);

    // add all stations to the right scrollpane
    // tanken är att dom skall vara valbara men det fungerar inte än
    // En JList vill ha en ListModel som parameter
    // En ListModel är ett interface som implementeras av klassen AbstractListModel
    // DefaultListModel ärver AbstractListModel
    DefaultListModel<String> valList = new DefaultListModel<String>();
    JList<String> alternativ = new JList<String>(valList);
    alternativ.setBackground(Color.white);
    alternativ.setForeground(Color.blue);
    // add a scroll pane to the station list in alternativ
    stationList = new JScrollPane(alternativ);
    // read names from p-queue and load them into the list
    while (!names.isEmpty()) valList.addElement(names.poll());

    // panel for structure
    JPanel valPanel = new JPanel(new BorderLayout());
    valPanel.setBackground(Color.white);
    valPanel.add(head, "North");
    valPanel.add(stationList, "Center");

    // put it all together in the frame
    add(select, "West");
    add(routeScrollPane, "Center");
    add(valPanel, "East");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setVisible(true);
  } // end ShortRoute