Esempio n. 1
0
  private void initComponents() {
    final TitledBorder border = BorderFactory.createTitledBorder(label);
    final Font titleFont = border.getTitleFont();
    if (titleFont != null) {
      border.setTitleFont(titleFont.deriveFont(Font.BOLD));
    }
    setBorder(border);

    jtext = new JTextField();
    // jtext.setText(defalt.getFile().getPath());
    jRelativneKProgramu = new JCheckBox("Relativně k umístění programu");
    jRelativneKProgramu.setEnabled(FConst.JAR_DIR_EXISTUJE);
    jActive = new JCheckBox("Aktivní");
    jActive.setEnabled(lzeDeaktivovat);
    jCurrVal = new JTextField();
    jCurrVal.setForeground(Color.BLUE);
    jCurrVal.setEditable(false);
    jCurrVal.setBorder(null);
    final JButton jbut = new JButton("...");
    // jtext.setText(defalt.getFile().getPath());
    jtext.setColumns(50);
    if (editovatelne) {
      final Box box2 = Box.createHorizontalBox();
      box2.setAlignmentX(LEFT_ALIGNMENT);
      box2.add(jtext);
      box2.add(jbut);
      final Box panel3 = Box.createHorizontalBox();
      if (FConst.JAR_DIR_EXISTUJE) {
        panel3.add(jRelativneKProgramu);
      }
      if (jActive.isEnabled()) {
        panel3.add(jActive);
      }
      if (panel3.getComponentCount() > 0) {
        add(panel3);
      }
      panel3.setAlignmentX(LEFT_ALIGNMENT);
      add(box2);
    }
    // panel.add(Box.createVerticalStrut(20));
    jCurrVal.setAlignmentX(LEFT_ALIGNMENT);
    add(jCurrVal);
    // add(panel);
    // add(Box.createVerticalStrut(20));
    jbut.addActionListener(
        new ActionListener() {
          private JFileChooser fc;

          @Override
          public void actionPerformed(final ActionEvent ae) {
            if (fc == null) { // dlouho to trvá, tak vytvoříme vždy nový
              fc = new JFileChooser();
            }
            fc.setCurrentDirectory(new File(jtext.getText()));
            if (jenAdresare) {
              fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            }
            final int result = fc.showDialog(JJedenSouborPanel.this, "Vybrat");
            if (result == JFileChooser.APPROVE_OPTION) {
              jtext.setText(fc.getSelectedFile().getPath());
            }
          }
        });

    prepocitej();
    jtext.getDocument().addDocumentListener(this);

    jRelativneKProgramu.addActionListener(e -> prepocitej());
    jActive.addActionListener(e -> prepocitej());
  }
Esempio n. 2
0
  public DisplayDetailsPanel(int dn) {

    setBackground(varsOrange);
    JLabel stimJL = new JLabel("Stimulus" + dn + ":", JLabel.RIGHT);
    stimJL.setFont(f12b);
    String[] stims = {"word", "picture", "sound", "video", "blank"};
    stimtypeJCB = new JComboBox(stims);
    stimtypeJCB.setSelectedIndex(0);

    stimJTF = new JTextField("", 10);
    stimJTF.setMaximumSize(new Dimension(stimJTF.getPreferredSize()));

    String[] locs = {"center", "random", "position"};
    stimlocJCB = new JComboBox(locs);
    stimlocJCB.setSelectedIndex(0);

    JLabel xJL = new JLabel("x:  ", JLabel.RIGHT);
    xJL.setFont(f12b);
    xJTF = new JTextField("", 3);
    xJTF.setMaximumSize(new Dimension(xJTF.getPreferredSize()));
    xJTF.setEditable(false);
    JLabel yJL = new JLabel("y:  ", JLabel.RIGHT);
    yJL.setFont(f12b);
    yJTF = new JTextField("", 3);
    yJTF.setMaximumSize(new Dimension(yJTF.getPreferredSize()));
    yJTF.setEditable(false);
    AbstractAction stimlocJCBaction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent ae) {
            if (stimlocJCB.getSelectedIndex() == 2) {
              xJTF.setEditable(true);
              yJTF.setEditable(true);
            } else {
              xJTF.setText("");
              yJTF.setText("");
              xJTF.setEditable(false);
              yJTF.setEditable(false);
            }
          }
        };
    stimlocJCB.addActionListener(stimlocJCBaction);

    JLabel durJL = new JLabel("Duration(sec):", JLabel.RIGHT);
    durJTF = new JTextField("", 3);
    durJTF.setMaximumSize(new Dimension(durJTF.getPreferredSize()));
    AbstractAction stimtypeJCBaction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent ae) {
            if (stimtypeJCB.getSelectedIndex() == 3) {
              stimJTF.setText("");
              stimJTF.setEditable(false);
              stimlocJCB.setEnabled(false);
              xJTF.setText("");
              xJTF.setEditable(false);
              yJTF.setText("");
              yJTF.setEditable(false);
              durJTF.setEditable(true);
            } else {
              if (stimtypeJCB.getSelectedIndex() == 2) {
                stimJTF.setEditable(true);
                stimlocJCB.setEnabled(false);
                xJTF.setText("");
                xJTF.setEditable(false);
                yJTF.setText("");
                yJTF.setEditable(false);
                durJTF.setText("");
                durJTF.setEditable(false);
              } else {
                stimJTF.setEditable(true);
                stimlocJCB.setEnabled(true);
                durJTF.setEditable(true);
              }
            }
          }
        };
    stimtypeJCB.addActionListener(stimtypeJCBaction);

    ddhbox = Box.createHorizontalBox();
    ddhbox.add(Box.createHorizontalStrut(10));
    ddhbox.add(stimtypeJCB);
    ddhbox.add(Box.createHorizontalStrut(10));
    ddhbox.add(stimJTF);
    ddhbox.add(Box.createHorizontalStrut(10));
    ddhbox.add(stimlocJCB);
    ddhbox.add(Box.createHorizontalStrut(5));
    ddhbox.add(xJL);
    ddhbox.add(xJTF);
    ddhbox.add(Box.createHorizontalStrut(5));
    ddhbox.add(yJL);
    ddhbox.add(yJTF);
    ddhbox.add(Box.createHorizontalStrut(10));
    ddhbox.add(durJL);
    ddhbox.add(durJTF);

    ddvbox = Box.createVerticalBox();
    ddvbox.add(stimJL);
    stimJL.setAlignmentX(Component.LEFT_ALIGNMENT);
    ddvbox.add(Box.createVerticalStrut(5));
    ddvbox.add(ddhbox);
    ddhbox.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(ddvbox);
  }