Пример #1
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);
  }
Пример #2
0
  public RadioButtonDemo() {
    // Create a new panel to hold check boxes
    JPanel jpRadioButtons = new JPanel();
    jpRadioButtons.setLayout(new GridLayout(3, 1));
    jpRadioButtons.add(jrbRed = new JRadioButton("Red"));
    jpRadioButtons.add(jrbGreen = new JRadioButton("Green"));
    jpRadioButtons.add(jrbBlue = new JRadioButton("Blue"));
    add(jpRadioButtons, BorderLayout.WEST);

    // Create a radio button group to group three buttons
    ButtonGroup group = new ButtonGroup();
    group.add(jrbRed);
    group.add(jrbGreen);
    group.add(jrbBlue);

    // Set keyboard mnemonics
    jrbRed.setMnemonic('E');
    jrbGreen.setMnemonic('G');
    jrbBlue.setMnemonic('U');

    // Register listeners for check boxes
    jrbRed.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            messagePanel.setForeground(Color.red);
          }
        });
    jrbGreen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            messagePanel.setForeground(Color.green);
          }
        });
    jrbBlue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            messagePanel.setForeground(Color.blue);
          }
        });

    // Set initial message color to blue
    jrbBlue.setSelected(true);
    messagePanel.setForeground(Color.blue);
  }
Пример #3
0
 public JRadioButton getRegexButton() {
   if (regexButton == null) {
     regexButton = new JRadioButton();
     regexButton.setText("Regular Expressions");
     regexButton.setMnemonic('x');
     regexButton.setDisplayedMnemonicIndex(9);
     regexButton.addActionListener(this);
   }
   return regexButton;
 }
Пример #4
0
 public JRadioButton getWildCardsButton() {
   if (wildCardsButton == null) {
     wildCardsButton = new JRadioButton();
     wildCardsButton.setText("Wild Cards");
     wildCardsButton.setMnemonic('i');
     wildCardsButton.setDisplayedMnemonicIndex(1);
     wildCardsButton.addActionListener(this);
   }
   return wildCardsButton;
 }
Пример #5
0
 public JRadioButton getLiteralButton() {
   if (literalButton == null) {
     literalButton = new JRadioButton();
     literalButton.setText("Literal");
     literalButton.setMnemonic('L');
     literalButton.setSelected(true);
     literalButton.addActionListener(this);
   }
   return literalButton;
 }
Пример #6
0
  /** Creates the setup panel with no initial experiment. */
  public SetupModePanel() {

    m_simplePanel.setModePanel(this);

    m_SimpleSetupRBut.setMnemonic('S');
    m_SimpleSetupRBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            switchToSimple(null);
          }
        });

    m_AdvancedSetupRBut.setMnemonic('A');
    m_AdvancedSetupRBut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            switchToAdvanced(null);
          }
        });

    ButtonGroup modeBG = new ButtonGroup();
    modeBG.add(m_SimpleSetupRBut);
    modeBG.add(m_AdvancedSetupRBut);
    m_SimpleSetupRBut.setSelected(true);

    JPanel modeButtons = new JPanel();
    modeButtons.setLayout(new GridLayout(1, 0));
    modeButtons.add(m_SimpleSetupRBut);
    modeButtons.add(m_AdvancedSetupRBut);

    JPanel switchPanel = new JPanel();
    switchPanel.setLayout(new GridLayout(1, 0));
    switchPanel.add(new JLabel("Experiment Configuration Mode:"));
    switchPanel.add(modeButtons);

    setLayout(new BorderLayout());
    add(switchPanel, BorderLayout.NORTH);
    add(m_simplePanel, BorderLayout.CENTER);
  }
Пример #7
0
  public MakeReservation() {
    new BorderLayout();

    standardRoom.setMnemonic(KeyEvent.VK_K);
    standardRoom.setActionCommand("Standard Room");
    standardRoom.setSelected(true);

    familyRoom.setMnemonic(KeyEvent.VK_F);
    familyRoom.setActionCommand("Family Room");

    suiteRoom.setMnemonic(KeyEvent.VK_S);
    suiteRoom.setActionCommand("Suite");

    // Add Booking Button
    ImageIcon bookRoomIcon = createImageIcon("images/book.png");
    bookRoom = new JButton("Book Room", bookRoomIcon);
    bookRoom.setVerticalTextPosition(AbstractButton.BOTTOM);
    bookRoom.setHorizontalTextPosition(AbstractButton.CENTER);
    bookRoom.setMnemonic(KeyEvent.VK_M);
    bookRoom.addActionListener(this);
    bookRoom.setActionCommand("book");

    // Group the radio buttons.
    group.add(standardRoom);
    group.add(familyRoom);
    group.add(suiteRoom);

    // Create the labels.
    nameLabel = new JLabel("Name: ");
    amountroomsLabel = new JLabel("How many rooms? ");
    checkoutdateLabel = new JLabel("Check-Out Date: ");
    checkindateLabel = new JLabel("Check-In Date: ");

    // Create the text fields and set them up.
    nameField = new JFormattedTextField();
    nameField.setColumns(10);

    amountroomsField = new JFormattedTextField(new Integer(1));
    amountroomsField.setValue(new Integer(1));
    amountroomsField.setColumns(10);

    // java.util.Date dt_checkin = new java.util.Date();
    LocalDate today = LocalDate.now();
    // java.text.SimpleDateFormat sdf_checkin = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkin = today.toString();
    checkindateField = new JFormattedTextField(currentDate_checkin);
    checkindateField.setColumns(10);

    // java.util.Date dt_checkout = new java.util.Date();
    LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
    // java.text.SimpleDateFormat sdf_checkout = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkout = tomorrow.toString();
    checkoutdateField = new JFormattedTextField(currentDate_checkout);
    checkoutdateField.setColumns(10);

    // Tell accessibility tools about label/textfield pairs.
    nameLabel.setLabelFor(nameField);
    amountroomsLabel.setLabelFor(amountroomsField);
    checkoutdateLabel.setLabelFor(checkoutdateField);
    checkindateLabel.setLabelFor(checkindateField);

    // Lay out the labels in a panel.
    JPanel labelPane1 = new JPanel(new GridLayout(0, 1));

    labelPane1.add(amountroomsLabel);

    JPanel labelPane3 = new JPanel(new GridLayout(0, 1));
    labelPane3.add(checkindateLabel);

    JPanel labelPane2 = new JPanel(new GridLayout(0, 1));
    labelPane2.add(checkoutdateLabel);

    JPanel labelPane4 = new JPanel(new GridLayout(0, 1));
    labelPane4.add(nameLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane1 = new JPanel(new GridLayout(0, 1));
    fieldPane1.add(amountroomsField);

    JPanel fieldPane3 = new JPanel(new GridLayout(0, 1));
    fieldPane3.add(checkindateField);

    JPanel fieldPane2 = new JPanel(new GridLayout(0, 1));
    fieldPane2.add(checkoutdateField);

    JPanel fieldPane4 = new JPanel(new GridLayout(0, 1));
    fieldPane4.add(nameField);

    // Put the radio buttons in a column in a panel.
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(standardRoom);
    radioPanel.add(familyRoom);
    radioPanel.add(suiteRoom);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane1, BorderLayout.LINE_START);
    add(fieldPane1, BorderLayout.LINE_END);
    add(labelPane3, BorderLayout.LINE_START);
    add(fieldPane3, BorderLayout.LINE_END);
    add(labelPane2, BorderLayout.LINE_START);
    add(fieldPane2, BorderLayout.LINE_END);
    add(labelPane4, BorderLayout.LINE_START);
    add(fieldPane4, BorderLayout.LINE_END);

    add(radioPanel, BorderLayout.LINE_END);
    add(bookRoom);
  }
Пример #8
0
  protected void initGuiComponents() {

    selectButtonGroup = new javax.swing.ButtonGroup();

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

    messagePanel = new IpssMessagePanel();
    getContentPane().add(messagePanel);
    messagePanel.setPreferredSize(new Dimension(0, 30));

    messagePanel.setBorder(new EmptyBorder(0, 5, 0, 0));
    messagePanel.getMessageLabel().setPreferredSize(new Dimension(0, 30));

    getContentPane().add(Box.createVerticalStrut(10));

    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.setBorder(new EmptyBorder(0, 5, 0, 5));
    getContentPane().add(mainPanel);

    mainPanel.add(Box.createVerticalStrut(10));

    selectpanel = new JPanel();
    mainPanel.add(selectpanel);
    final GridLayout gridLayout = new GridLayout(0, 1);
    selectpanel.setLayout(gridLayout);
    selectpanel.setBorder(
        new TitledBorder(
            null,
            "Contents",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_POSITION,
            null,
            null));

    newRadioButton = new JRadioButton();
    selectpanel.add(newRadioButton);
    newRadioButton.setSelected(true);
    newRadioButton.setMnemonic('N');
    newRadioButton.setText("Create a new graphic project");
    selectButtonGroup.add(newRadioButton);

    fromRadioButton = new JRadioButton();
    selectpanel.add(fromRadioButton);
    fromRadioButton.setMnemonic('x');
    fromRadioButton.setText("Import a graphic project from existing source");

    browsePanel = new JPanel();
    selectpanel.add(browsePanel);
    browsePanel.setLayout(new BorderLayout());

    dirTextField = new JTextField();
    dirTextField.setEditable(false);
    dirTextField.setFocusAccelerator('f');
    browsePanel.add(dirTextField);

    dirLabel = new JLabel();
    dirLabel.setDisplayedMnemonic(KeyEvent.VK_F);
    browsePanel.add(dirLabel, BorderLayout.WEST);
    dirLabel.setText("File:  ");

    browseButton = new JButton();

    browseButton.setMnemonic('B');
    browseButton.setText("Browse...");
    browsePanel.add(browseButton, BorderLayout.EAST);
    selectButtonGroup.add(fromRadioButton);

    final JPanel panel = new JPanel();
    mainPanel.add(panel, BorderLayout.NORTH);
    panel.setLayout(new BorderLayout());

    nameLabel = new JLabel();
    panel.add(nameLabel, BorderLayout.WEST);
    nameLabel.setDisplayedMnemonic(KeyEvent.VK_G);
    nameLabel.setText("Graphic Project File Name:");

    nameTextField = new JTextField();
    panel.add(nameTextField, BorderLayout.CENTER);

    nameTextField.setFocusAccelerator('g');

    buttonPanel = new JPanel();
    getContentPane().add(buttonPanel);

    okButton = new JButton();

    okButton.setMnemonic('O');
    buttonPanel.add(okButton);
    okButton.setText("OK");

    cancelButton = new JButton();

    buttonPanel.add(cancelButton);
    cancelButton.setMnemonic('C');
    cancelButton.setText("Cancel");

    // selectpanel.setVisible(false);
  }
  /**
   * Cria uma instância da janela de cadastro de funcionário do sistema BVB
   *
   * @param janelaPai <code>Window</code> com a janela pai da caixa de diálogo <code>
   *     IgCadFuncionario</code>
   * @param funcionario <code>Funcionario</code> referênte ao objeto onde os dados serão salvos
   * @see Window
   * @see Funcionario
   */
  public IgCadFuncionario(Window janelaPai, Funcionario funcionario) {
    setModal(true);
    Color nephritis = new Color(39, 174, 96);

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setResizable(false);
    setTitle("BVB - Cadastro de Funcion\u00E1rio");
    setBounds(100, 100, 523, (int) (506 * 0.85));
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JSeparator separatorBtn = new JSeparator();
    separatorBtn.setBounds(0, 348, 517, 2);
    contentPane.add(separatorBtn);

    JSeparator separatorTitulo = new JSeparator();
    separatorTitulo.setBounds(0, 69, 517, 2);
    contentPane.add(separatorTitulo);

    JTextPane txtpnSubTitulo = new JTextPane();
    txtpnSubTitulo.setEditable(false);
    txtpnSubTitulo.setForeground(Color.WHITE);
    txtpnSubTitulo.setBackground(nephritis);
    txtpnSubTitulo.setText("Insira o login e a senha do novo funcion\u00E1rio.");
    txtpnSubTitulo.setFont(new Font("Tahoma", Font.PLAIN, 12));
    txtpnSubTitulo.setBounds(20, 36, 290, 22);
    contentPane.add(txtpnSubTitulo);

    JTextPane txtpnTitulo = new JTextPane();
    txtpnTitulo.setEditable(false);
    txtpnTitulo.setForeground(Color.WHITE);
    txtpnTitulo.setBackground(nephritis);
    txtpnTitulo.setText("Cadastro de Funcion\u00E1rio");
    txtpnTitulo.setFont(new Font("Tahoma", Font.BOLD, 13));
    txtpnTitulo.setBounds(10, 11, 210, 22);
    contentPane.add(txtpnTitulo);

    JLabel lblImg = new JLabel("Label Img");
    lblImg.setBorder(new LineBorder(Color.WHITE, 1, true));
    lblImg.setIcon(
        new ImageIcon(
            IgCadFuncionario.class.getResource("/tsi/too/bvb/recursos/imagens/User-48.png")));
    lblImg.setBounds(459, 11, 48, 48);
    contentPane.add(lblImg);

    JEditorPane dtrpnCampoTitulo = new JEditorPane();
    dtrpnCampoTitulo.setBackground(nephritis);
    dtrpnCampoTitulo.setEditable(false);
    dtrpnCampoTitulo.setBounds(0, 0, 517, 70);
    contentPane.add(dtrpnCampoTitulo);

    JPanel Btnpanel = new JPanel();
    Btnpanel.setBounds(0, 359, 517, 43);
    contentPane.add(Btnpanel);
    Btnpanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    btnFinalizar = new JButton("Finalizar");
    btnFinalizar.addActionListener(new TEActionCadastrarFuncionario(this, funcionario));
    btnFinalizar.setMnemonic(KeyEvent.VK_F);
    Btnpanel.add(btnFinalizar);

    btnLimpar = new JButton("Limpar");
    btnLimpar.addActionListener(new TEActionCadastrarFuncionario(this, funcionario));
    btnLimpar.setMnemonic(KeyEvent.VK_L);
    Btnpanel.add(btnLimpar);

    btnCancelar = new JButton("Cancelar");
    btnCancelar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            IgCadFuncionario.this.dispose();
          }
        });
    btnCancelar.setMnemonic(KeyEvent.VK_C);
    Btnpanel.add(btnCancelar);

    verificacaoPanel = new JPanel();
    verificacaoPanel.setLayout(null);
    verificacaoPanel.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "N\u00E3o Verificado",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 255)));
    verificacaoPanel.setBounds(100, 95, 407, 58);
    contentPane.add(verificacaoPanel);

    loginTextField = new JTextField();
    loginTextField.setToolTipText(
        "este campo \u00E9 de preenchimento obrigat\u00F3rio, deve conter no m\u00EDnimo 6 e no m\u00E1ximo 20 caracteres (letras, d\u00EDgitos e os s\u00EDmbolos underscore (_) ou ponto (.)) e deve ser \u00FAnico");
    loginTextField.setColumns(10);
    loginTextField.setBounds(10, 20, 288, 20);
    verificacaoPanel.add(loginTextField);

    passwordField = new JPasswordField();
    passwordField.setToolTipText(
        "este campo \u00E9 de preenchimento obrigat\u00F3rio e deve conter no m\u00EDnimo 6 e no m\u00E1ximo 10 caracteres");
    passwordField.setBounds(100, 172, 308, 20);
    contentPane.add(passwordField);

    JPanel tipoUsuarioPanel = new JPanel();
    tipoUsuarioPanel.setLayout(null);
    tipoUsuarioPanel.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "Tipo do Usu\u00E1rio",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(51, 153, 255)));
    tipoUsuarioPanel.setBounds(10, 235, 497, 58);
    contentPane.add(tipoUsuarioPanel);

    rdbtnAdministrador = new JRadioButton("Administrador");
    rdbtnAdministrador.setToolTipText("selecione se o funcion\u00E1rio for um administrador");
    buttonGroup.add(rdbtnAdministrador);
    rdbtnAdministrador.setSelected(true);
    rdbtnAdministrador.setMnemonic(KeyEvent.VK_A);
    rdbtnAdministrador.setBounds(10, 20, 108, 23);
    tipoUsuarioPanel.add(rdbtnAdministrador);

    rdbtnCaixa = new JRadioButton("Caixa");
    rdbtnCaixa.setToolTipText("selecione se o funcion\u00E1rio for um caixa");
    buttonGroup.add(rdbtnCaixa);
    rdbtnCaixa.setMnemonic(KeyEvent.VK_I);
    rdbtnCaixa.setBounds(120, 20, 58, 23);
    tipoUsuarioPanel.add(rdbtnCaixa);

    rdbtnGerente = new JRadioButton("Gerente");
    rdbtnGerente.setToolTipText("selecione se o funcion\u00E1rio for um gerente");
    buttonGroup.add(rdbtnGerente);
    rdbtnGerente.setMnemonic(KeyEvent.VK_G);
    rdbtnGerente.setBounds(220, 20, 72, 23);
    tipoUsuarioPanel.add(rdbtnGerente);

    JLabel lblLogin = new JLabel("Login:"******"Verificar");
    btnVerificar.addActionListener(new TEActionCadastrarFuncionario(this, funcionario));
    btnVerificar.setMnemonic(KeyEvent.VK_V);
    btnVerificar.setBounds(308, 19, 89, 23);
    verificacaoPanel.add(btnVerificar);
    lblLogin.setDisplayedMnemonic(KeyEvent.VK_O);
    lblLogin.setBounds(10, 115, 60, 14);
    contentPane.add(lblLogin);

    JLabel lblSenha = new JLabel("Senha:");
    lblSenha.setLabelFor(passwordField);
    lblSenha.setDisplayedMnemonic(KeyEvent.VK_S);
    lblSenha.setBounds(10, 175, 60, 14);
    contentPane.add(lblSenha);

    lblCamposErrados =
        new JLabel("* Os campos destacados de vermelho n\u00E3o foram preenchidos corretamente!");
    lblCamposErrados.setVisible(false);
    lblCamposErrados.setForeground(Color.RED);
    lblCamposErrados.setBounds(10, 323, 497, 14);
    contentPane.add(lblCamposErrados);

    JLabel lblRepetirSenha = new JLabel("Repita a Senha:");
    lblRepetirSenha.setDisplayedMnemonic(KeyEvent.VK_R);
    lblRepetirSenha.setBounds(10, 205, 90, 14);
    contentPane.add(lblRepetirSenha);

    rPasswordField = new JPasswordField();
    lblRepetirSenha.setLabelFor(rPasswordField);
    rPasswordField.setToolTipText(
        "este campo \u00E9 de preenchimento obrigat\u00F3rio e as senhas devem conferir");
    rPasswordField.setBounds(100, 204, 308, 20);
    contentPane.add(rPasswordField);

    setLocationRelativeTo(janelaPai);
    setVisible(true);
  }
Пример #10
0
  private static JPanel initOptionsPane() {
    JPanel pane = null;
    ActionAdapter buttonListener = null;

    // Create an options pane
    JPanel optionsPane = new JPanel(new GridLayout(4, 1));

    // IP address input
    pane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    pane.add(new JLabel("Host IP:"));
    ipField = new JTextField(10);
    ipField.setText(hostIP);
    ipField.setEnabled(false);
    ipField.addFocusListener(
        new FocusAdapter() {
          public void focusLost(FocusEvent e) {
            ipField.selectAll();
            // Should be editable only when disconnected
            if (connectionStatus != DISCONNECTED) {
              changeStatusNTS(NULL, true);
            } else {
              hostIP = ipField.getText();
            }
          }
        });
    pane.add(ipField);
    optionsPane.add(pane);

    // Port input
    pane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    pane.add(new JLabel("Port:"));
    portField = new JTextField(10);
    portField.setEditable(true);
    portField.setText((new Integer(port)).toString());
    portField.addFocusListener(
        new FocusAdapter() {
          public void focusLost(FocusEvent e) {
            // should be editable only when disconnected
            if (connectionStatus != DISCONNECTED) {
              changeStatusNTS(NULL, true);
            } else {
              int temp;
              try {
                temp = Integer.parseInt(portField.getText());
                port = temp;
              } catch (NumberFormatException nfe) {
                portField.setText((new Integer(port)).toString());
                mainFrame.repaint();
              }
            }
          }
        });
    pane.add(portField);
    optionsPane.add(pane);

    // Host/guest option
    buttonListener =
        new ActionAdapter() {
          public void actionPerformed(ActionEvent e) {
            if (connectionStatus != DISCONNECTED) {
              changeStatusNTS(NULL, true);
            } else {
              isHost = e.getActionCommand().equals("host");

              // Cannot supply host IP if host option is chosen
              if (isHost) {
                ipField.setEnabled(false);
                ipField.setText("localhost");
                hostIP = "localhost";
              } else {
                ipField.setEnabled(true);
              }
            }
          }
        };
    ButtonGroup bg = new ButtonGroup();
    hostOption = new JRadioButton("Host", true);
    hostOption.setMnemonic(KeyEvent.VK_H);
    hostOption.setActionCommand("host");
    hostOption.addActionListener(buttonListener);
    guestOption = new JRadioButton("Guest", false);
    guestOption.setMnemonic(KeyEvent.VK_G);
    guestOption.setActionCommand("guest");
    guestOption.addActionListener(buttonListener);
    bg.add(hostOption);
    bg.add(guestOption);
    pane = new JPanel(new GridLayout(1, 2));
    pane.add(hostOption);
    pane.add(guestOption);
    optionsPane.add(pane);

    // Connect/disconnect buttons
    JPanel buttonPane = new JPanel(new GridLayout(1, 2));
    buttonListener =
        new ActionAdapter() {
          public void actionPerformed(ActionEvent e) {
            // Request a connection initiation
            if (e.getActionCommand().equals("connect")) {
              changeStatusNTS(BEGIN_CONNECT, true);
            }
            // Disconnect
            else {
              changeStatusNTS(DISCONNECTING, true);
            }
          }
        };
    connectButton = new JButton("Connect");
    connectButton.setMnemonic(KeyEvent.VK_C);
    connectButton.setActionCommand("connect");
    connectButton.addActionListener(buttonListener);
    connectButton.setEnabled(true);
    disconnectButton = new JButton("Disconnect");
    disconnectButton.setMnemonic(KeyEvent.VK_D);
    disconnectButton.setActionCommand("disconnect");
    disconnectButton.addActionListener(buttonListener);
    disconnectButton.setEnabled(false);
    buttonPane.add(connectButton);
    buttonPane.add(disconnectButton);
    optionsPane.add(buttonPane);

    return optionsPane;
  }
 /**
  * Initializes the dialog by displaying all labels and sliders, setting title, creating buttons
  * and assigning an ActionListener. To arrange the elements of the dialog box, a GridLayout is
  * used.
  */
 private void initWebCrawlingDialog() {
   this.setTitle("Meta-Data-Related Web Crawling - Configuration");
   // assign text to buttons, set name and assign action listener
   btnStartWebCrawl.setMnemonic(KeyEvent.VK_S);
   // set "Crawl"-button as default
   this.getRootPane().setDefaultButton(btnStartWebCrawl);
   btnStartWebCrawl.setText("Start Crawling");
   btnStartWebCrawl.addActionListener(this);
   btnCancel.setText("Cancel");
   btnCancel.setMnemonic(KeyEvent.VK_C);
   btnCancel.addActionListener(this);
   // set default values for text fields
   tfSearchEngineURL.setText("http://www.google.com");
   tfAdditionalKeywords.setText("+music+review");
   tfPathExternalCrawler.setText("wget");
   // create and initialize sliders
   sliderNumberOfRetries.setMinorTickSpacing(1);
   sliderIntervalBetweenRetries.setMinorTickSpacing(1);
   // initialize labels for slider values
   currentNumberOfRetries =
       new JLabel(Integer.toString(sliderNumberOfRetries.getValue()), JLabel.CENTER);
   currentIntervalBetweenRetries =
       new JLabel(Integer.toString(sliderIntervalBetweenRetries.getValue()), JLabel.CENTER);
   // initialize button group for placement of additional keywords in search string
   panelAdditionalKeywordsPlacement.add(rbBeforeSearchString);
   panelAdditionalKeywordsPlacement.add(rbAfterSearchString);
   bgAdditionalKeywordsPlacement.add(rbBeforeSearchString);
   bgAdditionalKeywordsPlacement.add(rbAfterSearchString);
   rbBeforeSearchString.setMnemonic(KeyEvent.VK_B);
   rbAfterSearchString.setMnemonic(KeyEvent.VK_A);
   // assign change listeners
   sliderNumberOfRetries.addChangeListener(this);
   sliderIntervalBetweenRetries.addChangeListener(this);
   // init grid layout
   gridLayout.setRows(10);
   gridLayout.setVgap(0);
   // assign layout
   panel.setLayout(gridLayout);
   panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
   // add UI-elements
   getContentPane().add(panel);
   panel.add(new JLabel("URL of Search Engine"));
   panel.add(tfSearchEngineURL);
   panel.add(new JLabel());
   panel.add(new JLabel("Number of Retries"));
   panel.add(sliderNumberOfRetries);
   panel.add(currentNumberOfRetries);
   panel.add(new JLabel("Interval between Retries (sec)"));
   panel.add(sliderIntervalBetweenRetries);
   panel.add(currentIntervalBetweenRetries);
   panel.add(new JLabel("Additional Keywords"));
   panel.add(tfAdditionalKeywords);
   panel.add(panelAdditionalKeywordsPlacement);
   panel.add(new JLabel("Maximum Number of Retrieved Pages per Query"));
   panel.add(jsNumberOfPages);
   panel.add(new JLabel());
   panel.add(new JLabel("Storage Path for Retrieved Pages"));
   panel.add(tfPathStoreRetrievedPages);
   panel.add(new JLabel());
   panel.add(new JLabel("Command for External Crawler"));
   panel.add(tfPathExternalCrawler);
   panel.add(new JLabel());
   panel.add(new JLabel());
   panel.add(cbStoreURLList);
   panel.add(new JLabel());
   panel.add(new JLabel());
   panel.add(new JLabel());
   panel.add(new JLabel());
   panel.add(btnStartWebCrawl);
   panel.add(new JLabel());
   panel.add(btnCancel);
   // set default look and feel
   this.setUndecorated(true);
   this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
   this.setResizable(false);
 }
Пример #12
0
  private void setupShapeRadioButtons(JFrame frame) {
    JRadioButton rectangleButton = new JRadioButton(rectangleString);
    rectangleButton.setMnemonic(KeyEvent.VK_R);
    rectangleButton.setActionCommand(rectangleString);
    rectangleButton.setSelected(true);

    JRadioButton ellipseButton = new JRadioButton(ellipseString);
    ellipseButton.setMnemonic(KeyEvent.VK_L);
    ellipseButton.setActionCommand(ellipseString);

    JRadioButton crossButton = new JRadioButton(crossString);
    crossButton.setMnemonic(KeyEvent.VK_S);
    crossButton.setActionCommand(crossString);

    ButtonGroup group = new ButtonGroup();
    group.add(rectangleButton);
    group.add(ellipseButton);
    group.add(crossButton);

    ActionListener shapeChangeListener =
        new ActionListener() {

          public void actionPerformed(ActionEvent event) {
            String currentShapeString = event.getActionCommand();
            if (rectangleString.equals(currentShapeString)) {
              currentShape = Imgproc.CV_SHAPE_RECT;
            } else if (ellipseString.equals(currentShapeString)) {
              currentShape = Imgproc.CV_SHAPE_ELLIPSE;
            } else if (crossString.equals(currentShapeString)) {
              currentShape = Imgproc.CV_SHAPE_CROSS;
            }
            processOperation();
          }
        };

    rectangleButton.addActionListener(shapeChangeListener);
    ellipseButton.addActionListener(shapeChangeListener);
    crossButton.addActionListener(shapeChangeListener);

    GridLayout gridRowLayout = new GridLayout(1, 0);
    JPanel shapeRadioPanel = new JPanel(gridRowLayout);

    JLabel shapeLabel = new JLabel("Shape:");

    shapeRadioPanel.add(rectangleButton);
    shapeRadioPanel.add(ellipseButton);
    shapeRadioPanel.add(crossButton);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    c.gridx = 0;
    c.gridy = 2;

    frame.add(shapeLabel, c);

    c.gridx = 1;
    c.gridy = 2;

    frame.add(shapeRadioPanel, c);
  }
Пример #13
0
  private void setupOperationRadioButtons(JFrame frame) {
    JRadioButton erodeButton = new JRadioButton(erodeString);
    erodeButton.setMnemonic(KeyEvent.VK_E);
    erodeButton.setActionCommand(erodeString);
    erodeButton.setSelected(true);

    JRadioButton dilateButton = new JRadioButton(dilateString);
    dilateButton.setMnemonic(KeyEvent.VK_D);
    dilateButton.setActionCommand(dilateString);

    JRadioButton openButton = new JRadioButton(openString);
    openButton.setMnemonic(KeyEvent.VK_O);
    openButton.setActionCommand(openString);

    JRadioButton closeButton = new JRadioButton(closeString);
    closeButton.setMnemonic(KeyEvent.VK_C);
    closeButton.setActionCommand(closeString);

    ButtonGroup group = new ButtonGroup();
    group.add(erodeButton);
    group.add(dilateButton);
    group.add(openButton);
    group.add(closeButton);

    ActionListener operationChangeListener =
        new ActionListener() {

          public void actionPerformed(ActionEvent event) {
            currentOperation = event.getActionCommand();
            processOperation();
          }
        };

    erodeButton.addActionListener(operationChangeListener);
    dilateButton.addActionListener(operationChangeListener);
    openButton.addActionListener(operationChangeListener);
    closeButton.addActionListener(operationChangeListener);

    GridLayout gridRowLayout = new GridLayout(1, 0);
    JPanel radioOperationPanel = new JPanel(gridRowLayout);

    JLabel operationLabel = new JLabel("Operation:");

    radioOperationPanel.add(erodeButton);
    radioOperationPanel.add(dilateButton);
    radioOperationPanel.add(openButton);
    radioOperationPanel.add(closeButton);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    c.gridx = 0;
    c.gridy = 0;

    frame.add(operationLabel, c);

    c.gridx = 1;
    c.gridy = 0;

    frame.add(radioOperationPanel, c);
  }
Пример #14
0
  /** Creates the GUI. */
  public void majorLayout() {
    //
    // Setup Menu
    //
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu(ResourceHandler.getMessage("menu.file"));
    file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file"));

    file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit")));
    exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit"));
    exitMenuItem.addActionListener(this);
    menuBar.add(file);

    JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit"));
    edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit"));

    edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option")));
    optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option"));
    optionMenuItem.addActionListener(this);
    menuBar.add(edit);

    JMenu help = new JMenu(ResourceHandler.getMessage("menu.help"));
    help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help")));
    helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(new JSeparator());
    help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about")));
    aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about"));
    helpMenuItem.addActionListener(this);
    aboutMenuItem.addActionListener(this);
    menuBar.add(help);

    setJMenuBar(menuBar);

    //
    // Setup main GUI
    //

    dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0"));
    dirTF = new JTextField();
    dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir"));
    dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir"));

    matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1"));
    matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2"));
    recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3"));
    recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3"));

    backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5"));
    backupTF = new JTextField();
    backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup"));
    backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup"));

    templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7"));
    templateCh = new TemplateFileChoice();

    staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label"));
    String version = System.getProperty("java.version");
    if (version.indexOf("-") > 0) {
      version = version.substring(0, version.indexOf("-"));
    }
    int dotIndex = version.indexOf(".");
    dotIndex = version.indexOf(".", dotIndex + 1);
    String familyVersion = version.substring(0, dotIndex);

    MessageFormat formatter =
        new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button"));
    staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version}));
    staticVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("static.versioning.radio.button"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button"));
    dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion}));
    dynamicVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button"));

    staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text"));
    dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion}));

    ButtonGroup versioningButtonGroup = new ButtonGroup();
    versioningButtonGroup.add(staticVersioningRadioButton);
    versioningButtonGroup.add(dynamicVersioningRadioButton);

    runBttn = new JButton(ResourceHandler.getMessage("button.convert"));
    runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert"));

    recursiveCheckBox.setOpaque(false);
    staticVersioningRadioButton.setOpaque(false);
    dynamicVersioningRadioButton.setOpaque(false);

    staticVersioningTextArea.setEditable(false);
    staticVersioningTextArea.setLineWrap(true);
    staticVersioningTextArea.setWrapStyleWord(true);
    dynamicVersioningTextArea.setEditable(false);
    dynamicVersioningTextArea.setLineWrap(true);
    dynamicVersioningTextArea.setWrapStyleWord(true);

    staticVersioningPanel.setLayout(new BorderLayout());
    staticVersioningPanel.add(staticVersioningTextArea, "Center");
    staticVersioningPanel.setBorder(new LineBorder(Color.black));

    dynamicVersioningPanel.setLayout(new BorderLayout());
    dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center");
    dynamicVersioningPanel.setBorder(new LineBorder(Color.black));

    if (converter.isStaticVersioning()) {
      staticVersioningRadioButton.setSelected(true);
    } else {
      dynamicVersioningRadioButton.setSelected(true);
    }

    addListeners();

    final int buf = 10, // Buffer (between components and form)
        sp = 10, // Space between components
        vsp = 5, // Vertical space
        indent = 20; // Indent between form (left edge) and component

    GridBagConstraints gbc = new GridBagConstraints();
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);

    //
    // Setup top panel
    //
    GridBagLayout topLayout = new GridBagLayout();
    JPanel topPanel = new JPanel();
    topPanel.setOpaque(false);
    topPanel.setLayout(topLayout);

    topLayout.setConstraints(
        dirLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirTF,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirBttn,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingTF,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        recursiveCheckBox,
        new GridBagConstraints(
            2,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupLabel,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupTF,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupBttn,
        new GridBagConstraints(
            2,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateLabel,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateCh,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep1,
        new GridBagConstraints(
            0,
            5,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 10, 10),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningLabel,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningRadioButton,
        new GridBagConstraints(
            0,
            7,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningPanel,
        new GridBagConstraints(
            0,
            8,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 10, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningRadioButton,
        new GridBagConstraints(
            0,
            9,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningPanel,
        new GridBagConstraints(
            0,
            10,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep2,
        new GridBagConstraints(
            0,
            11,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 0, 10),
            0,
            0));

    invisibleBttn = new JButton();
    invisibleBttn.setVisible(false);
    topLayout.setConstraints(
        invisibleBttn,
        new GridBagConstraints(
            2,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.CENTER,
            new Insets(indent, sp, 0, 0),
            0,
            0));

    topPanel.add(dirLabel);
    topPanel.add(dirTF);
    topPanel.add(dirBttn);
    topPanel.add(matchingLabel);
    topPanel.add(matchingTF);
    topPanel.add(recursiveCheckBox);
    topPanel.add(backupLabel);
    topPanel.add(backupTF);
    topPanel.add(backupBttn);
    topPanel.add(templateLabel);
    topPanel.add(templateCh);
    topPanel.add(sep1);
    topPanel.add(staticVersioningLabel);
    topPanel.add(staticVersioningRadioButton);
    topPanel.add(staticVersioningPanel);
    topPanel.add(dynamicVersioningRadioButton);
    topPanel.add(dynamicVersioningPanel);
    topPanel.add(sep2);
    topPanel.add(invisibleBttn);

    //
    // Setup bottom panel
    //
    GridBagLayout buttomLayout = new GridBagLayout();
    JPanel buttomPanel = new JPanel();
    buttomPanel.setOpaque(false);
    buttomPanel.setLayout(buttomLayout);

    buttomLayout.setConstraints(
        runBttn,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(sp, 0, 0, 0),
            0,
            0));
    buttomPanel.add(runBttn);

    //
    // Setup main panel
    //
    GridBagLayout mainLayout = new GridBagLayout();
    JPanel mainPanel = new JPanel();

    mainPanel.setOpaque(false);
    mainPanel.setLayout(mainLayout);

    mainLayout.setConstraints(
        topPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(buf, buf, 0, buf),
            0,
            0));
    mainLayout.setConstraints(
        buttomPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.SOUTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, buf, buf, buf),
            0,
            0));
    mainPanel.add(topPanel);
    mainPanel.add(buttomPanel);

    Border border = BorderFactory.createEtchedBorder();
    mainPanel.setBorder(border);

    GridBagLayout layout = new GridBagLayout();
    getContentPane().setLayout(layout);

    layout.setConstraints(
        mainPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    getContentPane().add(mainPanel);

    pack();
    setResizable(false);
  }
Пример #15
0
  CatenaSetting() {
    super(PeaFactory.getFrame());
    setting = this;
    // setting.setUndecorated(true);
    setting.setAlwaysOnTop(true);

    this.setIconImage(MainView.getImage());

    JPanel scryptPane = (JPanel) setting.getContentPane(); // new JPanel();
    scryptPane.setBorder(new LineBorder(Color.GRAY, 2));
    scryptPane.setLayout(new BoxLayout(scryptPane, BoxLayout.Y_AXIS));

    JLabel scryptLabel = new JLabel("Settings for CATENA:");
    scryptLabel.setPreferredSize(new Dimension(250, 30));

    JLabel tipLabel1 = new JLabel("Settings for this session only");
    tipLabel1.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    tipLabel1.setPreferredSize(new Dimension(250, 20));
    scryptPane.add(scryptLabel);
    scryptPane.add(tipLabel1);

    JLabel instanceLabel = new JLabel("Select an instance of Catena:");
    instanceLabel.setPreferredSize(new Dimension(250, 40));
    scryptPane.add(instanceLabel);

    JLabel instanceRecommendedLabel = new JLabel("recommended: Dragonfly-Full");
    instanceRecommendedLabel.setPreferredSize(new Dimension(250, 20));
    instanceRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    scryptPane.add(instanceRecommendedLabel);

    JRadioButton dragonflyFullButton = new JRadioButton("Dragonfly-Full");
    dragonflyFullButton.setMnemonic(KeyEvent.VK_U);
    dragonflyFullButton.addActionListener(this);
    dragonflyFullButton.setActionCommand("Dragonfly-Full");
    scryptPane.add(dragonflyFullButton);

    JRadioButton butterflyFullButton = new JRadioButton("Butterfly-Full");
    butterflyFullButton.setMnemonic(KeyEvent.VK_U);
    butterflyFullButton.addActionListener(this);
    butterflyFullButton.setActionCommand("Butterfly-Full");
    scryptPane.add(butterflyFullButton);

    JRadioButton dragonflyButton = new JRadioButton("Dragonfly");
    dragonflyButton.setMnemonic(KeyEvent.VK_B);
    dragonflyButton.addActionListener(this);
    dragonflyButton.setActionCommand("Dragonfly");
    scryptPane.add(dragonflyButton);

    JRadioButton butterflyButton = new JRadioButton("Butterfly");
    butterflyButton.setMnemonic(KeyEvent.VK_B);
    butterflyButton.addActionListener(this);
    butterflyButton.setActionCommand("Butterfly");
    scryptPane.add(butterflyButton);

    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(dragonflyButton);
    group.add(dragonflyFullButton);
    group.add(butterflyButton);
    group.add(butterflyFullButton);

    group.setSelected(dragonflyFullButton.getModel(), true);

    scryptPane.add(Box.createVerticalStrut(20));

    JLabel memoryLabel = new JLabel("Memory cost parameter GARLIC: ");
    memoryLabel.setPreferredSize(new Dimension(220, 40));
    scryptPane.add(memoryLabel);
    memoryField =
        new JTextField() {
          private static final long serialVersionUID = 1L;

          public void processKeyEvent(KeyEvent ev) {
            char c = ev.getKeyChar();
            try {
              // printable characters
              if (c > 31 && c < 65535 && c != 127) {
                Integer.parseInt(c + ""); // parse
              }
              super.processKeyEvent(ev);
            } catch (NumberFormatException nfe) {
              // if not a number: ignore
            }
          }
        };
    memoryField.setText("18");
    memoryField.setColumns(2);
    memoryField.setDragEnabled(true);

    memoryField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                warn();
              }

              public void removeUpdate(DocumentEvent e) {
                warn();
              }

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

              public void warn() {
                int garlic = 0;
                try {
                  garlic = Integer.parseInt(memoryField.getText());
                } catch (Exception nfe) {
                  errorLabel.setText("Invalid input");
                  return;
                }
                if (garlic == 0) {
                  errorLabel.setText("Invalid value");
                } else if (garlic < 14) {
                  errorLabel.setText("Warning: Weak parameter");
                } else if (garlic > 22 && garlic < 64) {
                  errorLabel.setText("Warning: Long execution time");
                } else if (garlic > 63) {
                  errorLabel.setText("Invalid value: must be < 64");
                } else {
                  errorLabel.setText("");
                }
              }
            });

    memoryRecommendedLabel = new JLabel("recommended >= 18");
    memoryRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    JPanel memoryPanel = new JPanel();
    memoryPanel.add(memoryField);
    memoryPanel.add(memoryRecommendedLabel);
    scryptPane.add(memoryPanel);

    scryptPane.add(Box.createVerticalStrut(10));

    JLabel timeLabel = new JLabel("Time cost parameter LAMBDA: ");
    timeLabel.setPreferredSize(new Dimension(220, 40));
    scryptPane.add(timeLabel);
    timeField =
        new JTextField() {
          private static final long serialVersionUID = 1L;

          public void processKeyEvent(KeyEvent ev) {
            char c = ev.getKeyChar();
            try {
              // printable characters
              if (c > 31 && c < 65535 && c != 127) {
                Integer.parseInt(c + ""); // parse
              }
              super.processKeyEvent(ev);
            } catch (NumberFormatException nfe) {
              // if not a number: ignore
            }
          }
        };
    timeField.setText("2");
    timeField.setColumns(3);
    timeField.setDragEnabled(true);

    timeField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                warn();
              }

              public void removeUpdate(DocumentEvent e) {
                warn();
              }

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

              public void warn() {
                int lambda = 0;
                try {
                  lambda = Integer.parseInt(timeField.getText());
                } catch (Exception nfe) {
                  errorLabel.setText("Invalid input");
                  return;
                }
                if (lambda == 0) {
                  errorLabel.setText("Invalid value");
                } else if (lambda == 1) {
                  errorLabel.setText("Warning: Weak parameter");
                } else if (lambda > 4) {
                  errorLabel.setText("Warning: Long execution time");
                } else {
                  errorLabel.setText("");
                }
              }
            });

    timeRecommendedLabel = new JLabel("recommended 2");
    timeRecommendedLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    JPanel timePanel = new JPanel();
    timePanel.add(timeField);
    timePanel.add(timeRecommendedLabel);
    scryptPane.add(timePanel);

    scryptPane.add(Box.createVerticalStrut(10));

    errorLabel = new JLabel("");
    errorLabel.setForeground(Color.RED);
    scryptPane.add(errorLabel);

    JButton scryptOkButton = new JButton("ok");
    scryptOkButton.setActionCommand("newSetting");
    scryptOkButton.addActionListener(this);
    scryptPane.add(scryptOkButton);
    setting.pack();
    setting.setLocation(100, 100);
    setting.setVisible(true);
  }
Пример #16
0
        @SuppressWarnings("unchecked")
	public JPanel makeChoicePanel(JPanel p, int []_y) {
		int y=_y[0];
		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.NONE;
		
		c.anchor = GridBagConstraints.EAST;
		c.gridx = 0; c.gridy = y++;		
		TranslatedLabel label_choice = new TranslatedLabel("Vote");
		p.add(label_choice, c);
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		choices = getChoices();
		p.add(vote_choice_field = new JComboBox(choices),c);
		vote_choice_field.addItemListener(this);
		
		vote_nojust_field = new JRadioButton(_("No Justification"));
		vote_oldjust_field = new JRadioButton(_("Old Justification"));
		vote_newjust_field = new JRadioButton(_("New Justification"));
		vote_nojust_field.setMnemonic(KeyEvent.VK_N);
		vote_oldjust_field.setMnemonic(KeyEvent.VK_O);
		vote_newjust_field.setMnemonic(KeyEvent.VK_W);
		vote_nojust_field.setActionCommand("j_none");
		vote_oldjust_field.setActionCommand("j_old");
		vote_newjust_field.setActionCommand("j_new");
		vote_nojust_field.setSelected(true);
		vote_oldjust_field.setSelected(false);
		vote_newjust_field.setSelected(false);
		ButtonGroup vote_j_group = new ButtonGroup();
		vote_j_group.add(vote_nojust_field);
		vote_j_group.add(vote_oldjust_field);
		vote_j_group.add(vote_newjust_field);		
		JPanel vj_panel=new JPanel();
		vj_panel.setLayout(new BoxLayout(vj_panel, BoxLayout.Y_AXIS));
		vj_panel.add(vote_nojust_field);
		vj_panel.add(vote_oldjust_field);
		vj_panel.add(vote_newjust_field);		
		vote_nojust_field.addActionListener(this);
		vote_oldjust_field.addActionListener(this);
		vote_newjust_field.addActionListener(this);
		
		c.anchor = GridBagConstraints.EAST;
		c.gridx = 0; c.gridy = y++;
		TranslatedLabel label_type = new TranslatedLabel("Type");
		p.add(label_type, c);
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		p.add(vj_panel,c);
		
		c.anchor = GridBagConstraints.EAST;
		c.gridx = 0; c.gridy = y++;		
		TranslatedLabel label_old_just = new TranslatedLabel("Old Justification");
		p.add(label_old_just, c);
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		p.add(just_old_just_field = new JComboBox(combo_answerTo),c);
		//p.add(just_answer_field = new JTextField(TITLE_LEN),c);
		//just_answer_field.getDocument().addDocumentListener(this);
		just_old_just_field.setEnabled(false);
		just_old_just_field.addItemListener(this);

		String creation_date = Util.getGeneralizedTime();
		vote_date_field = new JTextField(creation_date);
		vote_date_field.setColumns(creation_date.length());
		
		c.gridx = 0; c.gridy = y++;		
		c.anchor = GridBagConstraints.EAST;
		TranslatedLabel label_date = new TranslatedLabel("Creation Date");
		p.add(label_date, c);
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		//hash_org.creation_date = creation_date;
		p.add(vote_date_field,c);
		vote_date_field.setForeground(Color.GREEN);
		//name_field.addActionListener(this); //name_field.addFocusListener(this);
		vote_date_field.getDocument().addDocumentListener(this);
		
		c.gridx = 0; c.gridy = y++;		
		c.gridx = 1;
		c.anchor = GridBagConstraints.WEST;
		p.add(vote_dategen_field = new JButton(_("Set Current Date")),c);
		vote_dategen_field.addActionListener(this);

		if (SUBMIT) {
			c.anchor = GridBagConstraints.EAST;
			c.gridx = 0; c.gridy = y++;		
			c.gridx = 1;
			c.anchor = GridBagConstraints.WEST;
			p.add(just_submit_field = new JButton(_("Submit Vote")),c);
			just_submit_field.addActionListener(this);
		}
		_y[0] = y;
		return p;
	}	
  @Override
  protected JComponent createCenterPanel() {
    myTitledSeparator.setText(myAnalysisNoon);

    // include test option
    myInspectTestSource.setSelected(myAnalysisOptions.ANALYZE_TEST_SOURCES);

    // module scope if applicable
    myModuleButton.setText(
        AnalysisScopeBundle.message("scope.option.module.with.mnemonic", myModuleName));
    boolean useModuleScope = false;
    if (myModuleName != null) {
      useModuleScope = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.MODULE;
      myModuleButton.setSelected(myRememberScope && useModuleScope);
    }

    myModuleButton.setVisible(
        myModuleName != null && ModuleManager.getInstance(myProject).getModules().length > 1);

    boolean useUncommitedFiles = false;
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    final boolean hasVCS = !changeListManager.getAffectedFiles().isEmpty();
    if (hasVCS) {
      useUncommitedFiles = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.UNCOMMITTED_FILES;
      myUncommitedFilesButton.setSelected(myRememberScope && useUncommitedFiles);
    }
    myUncommitedFilesButton.setVisible(hasVCS);

    DefaultComboBoxModel model = new DefaultComboBoxModel();
    model.addElement(ALL);
    final List<? extends ChangeList> changeLists = changeListManager.getChangeListsCopy();
    for (ChangeList changeList : changeLists) {
      model.addElement(changeList.getName());
    }
    myChangeLists.setModel(model);
    myChangeLists.setEnabled(myUncommitedFilesButton.isSelected());
    myChangeLists.setVisible(hasVCS);

    // file/package/directory/module scope
    if (myFileName != null) {
      myFileButton.setText(myFileName);
      myFileButton.setMnemonic(myFileName.charAt(getSelectedScopeMnemonic()));
    } else {
      myFileButton.setVisible(false);
    }

    VirtualFile file = PsiUtilBase.getVirtualFile(myContext);
    ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
    boolean searchInLib =
        file != null && (fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file));

    String preselect =
        StringUtil.isEmptyOrSpaces(myAnalysisOptions.CUSTOM_SCOPE_NAME)
            ? FindSettings.getInstance().getDefaultScopeName()
            : myAnalysisOptions.CUSTOM_SCOPE_NAME;
    if (searchInLib
        && GlobalSearchScope.projectScope(myProject).getDisplayName().equals(preselect)) {
      preselect = GlobalSearchScope.allScope(myProject).getDisplayName();
    }
    if (GlobalSearchScope.allScope(myProject).getDisplayName().equals(preselect)
        && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM) {
      myAnalysisOptions.CUSTOM_SCOPE_NAME = preselect;
      searchInLib = true;
    }

    // custom scope
    myCustomScopeButton.setSelected(
        myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM);

    myScopeCombo.init(myProject, searchInLib, true, preselect);

    // correct selection
    myProjectButton.setSelected(
        myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.PROJECT
            || myFileName == null);
    myFileButton.setSelected(
        myFileName != null
            && (!myRememberScope
                || myAnalysisOptions.SCOPE_TYPE != AnalysisScope.PROJECT
                    && !useModuleScope
                    && myAnalysisOptions.SCOPE_TYPE != AnalysisScope.CUSTOM
                    && !useUncommitedFiles));

    myScopeCombo.setEnabled(myCustomScopeButton.isSelected());

    final ActionListener radioButtonPressed =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            onScopeRadioButtonPressed();
          }
        };
    final Enumeration<AbstractButton> enumeration = myGroup.getElements();
    while (enumeration.hasMoreElements()) {
      enumeration.nextElement().addActionListener(radioButtonPressed);
    }

    // additional panel - inspection profile chooser
    JPanel wholePanel = new JPanel(new BorderLayout());
    wholePanel.add(myPanel, BorderLayout.NORTH);
    final JComponent additionalPanel = getAdditionalActionSettings(myProject);
    if (additionalPanel != null) {
      wholePanel.add(additionalPanel, BorderLayout.CENTER);
    }
    new RadioUpDownListener(
        myProjectButton,
        myModuleButton,
        myUncommitedFilesButton,
        myFileButton,
        myCustomScopeButton);
    return wholePanel;
  }