public DelegationPanel() {
   final BoxLayout boxLayout = new BoxLayout(this, BoxLayout.X_AXIS);
   setLayout(boxLayout);
   add(new JLabel(RefactoringBundle.message("delegation.panel.method.calls.label")));
   myRbModifyCalls = new JRadioButton();
   myRbModifyCalls.setText(RefactoringBundle.message("delegation.panel.modify.radio"));
   add(myRbModifyCalls);
   myRbGenerateDelegate = new JRadioButton();
   myRbGenerateDelegate.setText(
       RefactoringBundle.message("delegation.panel.delegate.via.overloading.method"));
   add(myRbGenerateDelegate);
   myRbModifyCalls.setSelected(true);
   final ButtonGroup bg = new ButtonGroup();
   bg.add(myRbModifyCalls);
   bg.add(myRbGenerateDelegate);
   add(Box.createHorizontalGlue());
   myRbModifyCalls.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           stateModified();
         }
       });
   myRbGenerateDelegate.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           stateModified();
         }
       });
 }
示例#2
0
  private JComponent createControls() {
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    dateOption = new JRadioButton(messageResources.getString("results.byDate"), true);
    teamOption = new JRadioButton(messageResources.getString("results.byTeam"), false);
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(dateOption);
    buttonGroup.add(teamOption);

    datesCombo.setRenderer(
        new DefaultListCellRenderer() {

          @Override
          public Component getListCellRendererComponent(
              JList list, Object item, int row, boolean isSelected, boolean hasFocus) {
            return super.getListCellRendererComponent(
                list, dateFormat.format(item), row, isSelected, hasFocus);
          }
        });

    venueCombo = new EnumComboBox<VenueType>(VenueType.class, messageResources);
    teamsCombo.setEnabled(false);
    venueCombo.setEnabled(false);

    ItemListener itemListener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
              if (itemEvent.getSource() == dateOption) {
                datesCombo.setEnabled(true);
                venueCombo.setEnabled(false);
                teamsCombo.setEnabled(false);
              } else if (itemEvent.getSource() == teamOption) {
                datesCombo.setEnabled(false);
                venueCombo.setEnabled(true);
                teamsCombo.setEnabled(true);
              }
              changeTables();
            }
          }
        };

    dateOption.addItemListener(itemListener);
    teamOption.addItemListener(itemListener);
    datesCombo.addItemListener(itemListener);
    teamsCombo.addItemListener(itemListener);
    venueCombo.addItemListener(itemListener);

    panel.add(dateOption);
    panel.add(datesCombo);
    panel.add(teamOption);
    panel.add(teamsCombo);
    panel.add(venueCombo);

    return panel;
  }
示例#3
0
  /** Initializes this {@code FileCrypter} and shows it. */
  private void init() {
    cipherOptionPane.init();
    ItemListener changeListener = new DetailsEnablerAndDisabler();
    otherDirectoryRadioButton.addItemListener(changeListener);
    suffixRadioButton.addItemListener(changeListener);
    chooseDirectoryButton.addActionListener(new DirectoryChooser());
    cryptButton.addActionListener(new Crypter());

    pack();
    GUIUtilities.loadGeometry(this, "cipher.file-crypter");
    setVisible(true);
  }
示例#4
0
  void jbInit() throws Exception {

    setLayout(new AlignLayout(2, 5, 5));

    all = new JRadioButton("All");

    all.setSelected(true);

    select = new JRadioButton("User Data");
    select.setSelected(false);
    select.addItemListener(
        new java.awt.event.ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            select_itemStateChanged(e);
          }
        });

    userData = new JTextField(15);
    //      userData.setEnabled(false);
    ToggleDocument td = new ToggleDocument();
    td.addToggleDocumentListener(this);
    userData.setDocument(td);

    ButtonGroup bg = new ButtonGroup();
    bg.add(all);
    bg.add(select);

    add(all);
    add(new JLabel(""));
    add(select);
    add(userData);

    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  }
示例#5
0
 private JRadioButton getSmoothRB() {
   if (SmoothRB == null) {
     SmoothRB = new JRadioButton();
     SmoothRB.setText("Smooth");
     SmoothRB.addItemListener(this);
   }
   return SmoothRB;
 }
示例#6
0
 private JRadioButton getRawAndSmoothRB() {
   if (RawAndSmoothRB == null) {
     RawAndSmoothRB = new JRadioButton();
     RawAndSmoothRB.setText("Raw & Smooth");
     RawAndSmoothRB.addItemListener(this);
   }
   return RawAndSmoothRB;
 }
示例#7
0
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   if (value == null) return null;
   boolean val = (Boolean) value;
   btn.setSelected(val);
   btn.addItemListener(this);
   return btn;
 }
示例#8
0
 private JRadioButton getRawRB() {
   if (RawRB == null) {
     RawRB = new JRadioButton();
     RawRB.setText("Raw");
     RawRB.setSelected(true);
     RawRB.addItemListener(this);
   }
   return RawRB;
 }
示例#9
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();
          }
        });
  }
  @Override
  protected void init() {
    super.init();

    if (myTextSelected == Boolean.TRUE) {
      myRbSelectedText.setSelected(true);
    } else {
      if (myFile != null) {
        myRbFile.setSelected(true);
      } else {
        myRbDirectory.setSelected(true);
      }
    }

    myCbIncludeSubdirs.setSelected(true);
    // Loading previous state
    myCbOptimizeImports.setSelected(
        PropertiesComponent.getInstance()
            .getBoolean(LayoutCodeConstants.OPTIMIZE_IMPORTS_KEY, false));
    myCbArrangeEntries.setSelected(
        PropertiesComponent.getInstance()
            .getBoolean(LayoutCodeConstants.REARRANGE_ENTRIES_KEY, false));
    myCbOnlyVcsChangedRegions.setSelected(
        PropertiesComponent.getInstance()
            .getBoolean(LayoutCodeConstants.PROCESS_CHANGED_TEXT_KEY, false));

    ItemListener listener =
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            updateState();
          }
        };
    myRbFile.addItemListener(listener);
    myRbSelectedText.addItemListener(listener);
    myRbDirectory.addItemListener(listener);
    myCbIncludeSubdirs.addItemListener(listener);

    updateState();
  }
  protected JComponent createCenterPanel() {
    JPanel optionsPanel = new JPanel();
    optionsPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
    optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));

    myRbInlineAll = new JRadioButton();
    myRbInlineAll.setText(getInlineAllText());
    myRbInlineAll.setSelected(true);
    myRbInlineThisOnly = new JRadioButton();
    myRbInlineThisOnly.setText(getInlineThisText());

    optionsPanel.add(myRbInlineAll);
    optionsPanel.add(myRbInlineThisOnly);
    ButtonGroup bg = new ButtonGroup();
    bg.add(myRbInlineAll);
    bg.add(myRbInlineThisOnly);
    new RadioUpDownListener(myRbInlineAll, myRbInlineThisOnly);

    myRbInlineThisOnly.setEnabled(myInvokedOnReference);
    final boolean writable = myElement.isWritable();
    myRbInlineAll.setEnabled(writable);
    if (myInvokedOnReference) {
      if (canInlineThisOnly()) {
        myRbInlineAll.setSelected(false);
        myRbInlineAll.setEnabled(false);
        myRbInlineThisOnly.setSelected(true);
      } else {
        if (writable) {
          final boolean inlineThis = isInlineThis();
          myRbInlineThisOnly.setSelected(inlineThis);
          myRbInlineAll.setSelected(!inlineThis);
        } else {
          myRbInlineAll.setSelected(false);
          myRbInlineThisOnly.setSelected(true);
        }
      }
    } else {
      myRbInlineAll.setSelected(true);
      myRbInlineThisOnly.setSelected(false);
    }

    getPreviewAction().setEnabled(myRbInlineAll.isSelected());
    myRbInlineAll.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean enabled = myRbInlineAll.isSelected();
            getPreviewAction().setEnabled(enabled);
          }
        });
    return optionsPanel;
  }
  public ChangeListChooserPanel(
      final Project project, @NotNull final NullableConsumer<String> okEnabledListener) {
    super(new BorderLayout());
    myProject = project;
    myOkEnabledListener = okEnabledListener;
    add(myPanel, BorderLayout.CENTER);

    myRbExisting.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            updateEnabledItems();
          }
        });
  }
  public HSQLSettings() {
    super(HSQLDB.class);
    CPSModule.debug("HSQLSettings", "using pref node:" + HSQLDB.class.toString());

    rdoUseGlobalDir = new JRadioButton("Use global output directory", false);
    rdoUseGlobalDir.addItemListener(this);
    rdoUseCustomDir = new JRadioButton("Use other directory:", false);
    rdoUseCustomDir.addItemListener(this);
    ButtonGroup bg = new ButtonGroup();
    bg.add(rdoUseCustomDir);
    bg.add(rdoUseGlobalDir);

    lblCustomOutDir = new JLabel();

    flchCustomDir = new JFileChooser();
    flchCustomDir.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    btnCustomDir = new JButton("Choose Output Directory");
    btnCustomDir.addActionListener(this);

    buildConfigPanel();
    rdoUseGlobalDir.doClick();
  }
 public ConstraintsOptionsPanel(WorkbenchContext workbenchContext) {
   this.workbenchContext = workbenchContext;
   try {
     this.jbInit();
     this.init();
   } catch (Exception e) {
     Assert.shouldNeverReachHere(e.toString());
   }
   relativeAngleRadioButton.addItemListener(
       new ItemListener() {
         @Override
         public void itemStateChanged(ItemEvent e) {
           if (start) {
             SettingOptionsDialog.page.fireButtonEvent(
                 ButtonEvent.ENABLE_BUTTON, ButtonNames.APPLY);
           }
         }
       });
   lengthCheckBox.addItemListener(
       new ItemListener() {
         @Override
         public void itemStateChanged(ItemEvent e) {
           updateEnabled();
         }
       });
   constrainIncrementalAngleCheckBox.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           updateEnabled();
         }
       });
   constrainAngleCheckBox.addItemListener(
       new ItemListener() {
         public void itemStateChanged(ItemEvent e) {
           updateEnabled();
         }
       });
   numPartsTextField.addFocusListener(
       new myFocusListener() {
         public void focusLost(FocusEvent e) {
           double newAngle = 360.0 / Double.parseDouble(numPartsTextField.getText());
           // constrainIncrementalAngleCheckBox.setText("Constrain angle to " + newAngle + " degree
           // increments");
           // [sstein: 16.10.2005]
           constrainIncrementalAngleCheckBox.setText(
               constrainAngleByStepsOf + " " + newAngle + " " + degree);
         }
       });
 }
  private void buildChooserComponentEnabler(JRadioButton radioButton, JComponent widgets) {
    final SimplePropertyValueModel booleanHolder =
        new SimplePropertyValueModel(Boolean.valueOf(radioButton.isSelected()));

    radioButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            JRadioButton radioButton = (JRadioButton) e.getSource();
            Object value = Boolean.valueOf(radioButton.isSelected());
            booleanHolder.setValue(value);
          }
        });

    new ComponentEnabler(booleanHolder, Collections.singleton(widgets));
  }
示例#16
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);
  }
  public Component getTableCellEditorComponent(
      JTable table, Object value, boolean isSelected, int row, int column) {

    if (value == null) return null;
    boolean valuesAsBoolean = false;
    if (value instanceof Boolean) {
      Boolean b = (Boolean) value;
      valuesAsBoolean = b.booleanValue();
    } else if (value instanceof Object) {
      valuesAsBoolean = value.equals(valueTrue);
    }
    //        btn = new JRadioButton("");
    //        group.add(btn);
    btn.addItemListener(this);
    if (valuesAsBoolean) btn.setSelected(true);
    else btn.setSelected(false);
    btn.setHorizontalAlignment(SwingConstants.CENTER);
    return btn;
  }
示例#18
0
 /**
  * Creates a panel with components for controlling the route-finding strategy.
  *
  * @param distances Data used by the strategy in order to calculate shortest routes.
  */
 StrategyPanel(DistanceLookup distances) {
   super(new BorderLayout());
   this.distances = distances;
   evolutionOption = new JRadioButton("Evolution", true);
   bruteForceOption = new JRadioButton("Brute Force", false);
   evolutionOption.addItemListener(
       new ItemListener() {
         @Override
         public void itemStateChanged(ItemEvent itemEvent) {
           evolutionPanel.setEnabled(evolutionOption.isSelected());
         }
       });
   ButtonGroup strategyGroup = new ButtonGroup();
   strategyGroup.add(evolutionOption);
   strategyGroup.add(bruteForceOption);
   evolutionPanel = new EvolutionPanel();
   add(evolutionOption, BorderLayout.NORTH);
   add(evolutionPanel, BorderLayout.CENTER);
   add(bruteForceOption, BorderLayout.SOUTH);
   setBorder(BorderFactory.createTitledBorder("Route-Finding Strategy"));
 }
示例#19
0
  @Override
  public void setComboData(final String cmbLabelText, List cmbData) {
    cmbCombo = new JComboBoxEx(cmbData.toArray());
    ((DefaultComboBoxModel) cmbCombo.getModel()).insertElementAt("(" + Constants.NONE + ")", 0);
    cmbCombo.setSelectedIndex(0);
    cmbCombo.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            //
            // If just made a selection from the combo,
            // then make sure it's associated
            // radio button is selected
            //
            if ((e.getStateChange() == ItemEvent.SELECTED) && (cmbCombo.getSelectedIndex() > 0)) {
              lblCombo.setSelected(true);
            }
          }
        });

    lblCombo = new JRadioButton(cmbLabelText);
    lblCombo.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            // If associated radio button becomes not
            // selected, then set the selected
            // in the combo box to "(None)".
            // If select the radio button instead of a
            // selection from the combobox, then set
            // the combo selection to the 1st type
            //
            if (!lblCombo.isSelected()) {
              cmbCombo.setSelectedIndex(0);
            } else if (cmbCombo.getSelectedIndex() == 0) {
              cmbCombo.setSelectedIndex(1);
            }
          }
        });
  }
示例#20
0
  public ModuleTypeStep(boolean createNewProject) {
    myPanel = new JPanel(new GridBagLayout());
    myPanel.setBorder(BorderFactory.createEtchedBorder());

    myModuleDescriptionPane = new JEditorPane();
    myModuleDescriptionPane.setContentType(UIUtil.HTML_MIME);
    myModuleDescriptionPane.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                BrowserUtil.launchBrowser(e.getURL().toString());
              } catch (IllegalThreadStateException ex) {
                // it's nnot a problem
              }
            }
          }
        });
    myModuleDescriptionPane.setEditable(false);

    final ModuleType[] allModuleTypes = ModuleTypeManager.getInstance().getRegisteredTypes();

    myTypesList = new JList(allModuleTypes);
    myTypesList.setSelectionModel(new PermanentSingleSelectionModel());
    myTypesList.setCellRenderer(new ModuleTypesListCellRenderer());
    myTypesList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
              return;
            }
            final ModuleType typeSelected = (ModuleType) myTypesList.getSelectedValue();
            myModuleType = typeSelected;
            //noinspection HardCodedStringLiteral
            myModuleDescriptionPane.setText(
                "<html><body><font face=\"verdana\" size=\"-1\">"
                    + typeSelected.getDescription()
                    + "</font></body></html>");
            myEventDispatcher.getMulticaster().moduleTypeSelected(typeSelected);
          }
        });
    myTypesList.setSelectedIndex(0);
    myTypesList.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              if (myDoubleClickAction != null) {
                if (myTypesList.getSelectedValue() != null) {
                  myDoubleClickAction.run();
                }
              }
            }
          }
        });

    myRbCreateNewModule = new JRadioButton(IdeBundle.message("radio.create.new.module"), true);
    myRbImportModule = new JRadioButton(IdeBundle.message("radio.import.existing.module"));
    myButtonGroup = new ButtonGroup();
    myButtonGroup.add(myRbCreateNewModule);
    myButtonGroup.add(myRbImportModule);
    ModulesRbListener listener = new ModulesRbListener();
    myRbCreateNewModule.addItemListener(listener);
    myRbImportModule.addItemListener(listener);

    JTextField tfModuleFilePath = new JTextField();
    final String productName = ApplicationNamesInfo.getInstance().getProductName();
    myModulePathFieldPanel =
        createFieldPanel(
            tfModuleFilePath,
            IdeBundle.message("label.path.to.module.file", productName),
            new BrowseFilesListener(
                tfModuleFilePath,
                IdeBundle.message("prompt.select.module.file.to.import", productName),
                null,
                new ModuleFileChooserDescriptor()));
    myModulePathFieldPanel.setEnabled(false);

    if (createNewProject) {
      final JLabel moduleTypeLabel = new JLabel(IdeBundle.message("label.select.module.type"));
      moduleTypeLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
      myPanel.add(moduleTypeLabel, LABEL_CONSTRAINT);
    } else {
      myPanel.add(
          myRbCreateNewModule,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.NONE,
              new Insets(8, 10, 8, 10),
              0,
              0));
    }
    final JLabel descriptionLabel = new JLabel(IdeBundle.message("label.description"));
    descriptionLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
    myPanel.add(
        descriptionLabel,
        new GridBagConstraints(
            1,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    final JScrollPane typesListScrollPane = ScrollPaneFactory.createScrollPane(myTypesList);
    final Dimension preferredSize = calcTypeListPreferredSize(allModuleTypes);
    typesListScrollPane.setPreferredSize(preferredSize);
    typesListScrollPane.setMinimumSize(preferredSize);
    myPanel.add(
        typesListScrollPane,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.2,
            (createNewProject ? 1.0 : 0.0),
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, createNewProject ? 10 : 30, 0, 10),
            0,
            0));

    final JScrollPane descriptionScrollPane =
        ScrollPaneFactory.createScrollPane(myModuleDescriptionPane);
    descriptionScrollPane.setPreferredSize(
        new Dimension(preferredSize.width * 3, preferredSize.height));
    myPanel.add(
        descriptionScrollPane,
        new GridBagConstraints(
            1,
            GridBagConstraints.RELATIVE,
            1,
            1,
            0.8,
            (createNewProject ? 1.0 : 0.0),
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 10),
            0,
            0));

    if (!createNewProject) {
      myPanel.add(
          myRbImportModule,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              2,
              1,
              1.0,
              0.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.NONE,
              new Insets(16, 10, 0, 10),
              0,
              0));
      myPanel.add(
          myModulePathFieldPanel,
          new GridBagConstraints(
              0,
              GridBagConstraints.RELATIVE,
              2,
              1,
              1.0,
              1.0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(8, 30, 0, 10),
              0,
              0));
    }
  }
示例#21
0
  /*
   * Constructor
   *
   * Create the dialog but don't display it (gets displayed when user selects "Settings..." menu item)
   *
   */
  public CTsettings(JFrame parentI) {

    super(parentI, "CTtext Settings", true);

    parent = parentI;

    setFont(new Font("Dialog", Font.PLAIN, 12));
    GridBagLayout gbl = new GridBagLayout();
    JPanel guiPanel = new JPanel(gbl);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;

    // Create GUI components
    outputDirTF = new JTextField(25);
    chanNameTF = new JTextField(10);
    bUseFTPCheckB = new JCheckBox("Use FTP");
    bUseFTPCheckB.addItemListener(this);
    ftpHostLabel = new JLabel("Host", SwingConstants.LEFT);
    ftpHostTF = new JTextField(20);
    ftpUserLabel = new JLabel("Username", SwingConstants.LEFT);
    ftpUserTF = new JTextField(15);
    ftpPasswordLabel = new JLabel("Password", SwingConstants.LEFT);
    ftpPasswordTF = new JPasswordField(15);
    autoFlushRB = new JRadioButton("Automatic flush at interval");
    autoFlushRB.addItemListener(this);
    manualFlushRB = new JRadioButton("Manual flush on button click");
    flushButtonGroup = new ButtonGroup();
    flushButtonGroup.add(autoFlushRB);
    flushButtonGroup.add(manualFlushRB);
    flushIntervalLabel = new JLabel("Flush interval", SwingConstants.LEFT);
    flushIntervalComboB = new JComboBox<String>(flushIntervalStrings);
    flushIntervalComboB.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXX");
    flushIntervalComboB.setEditable(false);
    okButton = new JButton("OK");
    okButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);

    // Add components to the guiPanel
    int row = 0;

    // ROW 1
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    JLabel tempLabel = new JLabel("Output folder", SwingConstants.LEFT);
    gbc.insets = new Insets(15, 15, 0, 10);
    Utility.add(guiPanel, tempLabel, gbl, gbc, 0, row, 1, 1);
    gbc.insets = new Insets(15, 0, 0, 15);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 100;
    gbc.weighty = 0;
    Utility.add(guiPanel, outputDirTF, gbl, gbc, 1, row, 1, 1);
    row++;

    // ROW 2
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    tempLabel = new JLabel("Channel name", SwingConstants.LEFT);
    gbc.insets = new Insets(10, 15, 0, 10);
    Utility.add(guiPanel, tempLabel, gbl, gbc, 0, row, 1, 1);
    gbc.insets = new Insets(10, 0, 0, 15);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    Utility.add(guiPanel, chanNameTF, gbl, gbc, 1, row, 1, 1);
    row++;

    // ROW 3
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.insets = new Insets(10, 15, 0, 15);
    Utility.add(guiPanel, bUseFTPCheckB, gbl, gbc, 0, row, 2, 1);
    row++;

    // ROW 4: A panel containing the FTP parameters (host, username, password)
    GridBagLayout panel_gbl = new GridBagLayout();
    JPanel ftpPanel = new JPanel(panel_gbl);
    GridBagConstraints panel_gbc = new GridBagConstraints();
    panel_gbc.anchor = GridBagConstraints.WEST;
    panel_gbc.fill = GridBagConstraints.NONE;
    panel_gbc.weightx = 0;
    panel_gbc.weighty = 0;
    int panel_row = 0;
    // Panel row 1: host
    panel_gbc.insets = new Insets(0, 0, 0, 10);
    Utility.add(ftpPanel, ftpHostLabel, panel_gbl, panel_gbc, 0, panel_row, 1, 1);
    panel_gbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(ftpPanel, ftpHostTF, panel_gbl, panel_gbc, 1, panel_row, 1, 1);
    panel_row++;
    // Panel row 2: username
    panel_gbc.insets = new Insets(2, 0, 0, 10);
    Utility.add(ftpPanel, ftpUserLabel, panel_gbl, panel_gbc, 0, panel_row, 1, 1);
    panel_gbc.insets = new Insets(2, 0, 0, 0);
    Utility.add(ftpPanel, ftpUserTF, panel_gbl, panel_gbc, 1, panel_row, 1, 1);
    panel_row++;
    // Panel row 3: password
    panel_gbc.insets = new Insets(2, 0, 0, 10);
    Utility.add(ftpPanel, ftpPasswordLabel, panel_gbl, panel_gbc, 0, panel_row, 1, 1);
    panel_gbc.insets = new Insets(2, 0, 0, 0);
    Utility.add(ftpPanel, ftpPasswordTF, panel_gbl, panel_gbc, 1, panel_row, 1, 1);
    // Add the panel to guiPanel
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.insets = new Insets(2, 50, 0, 15);
    Utility.add(guiPanel, ftpPanel, gbl, gbc, 0, row, 2, 1);
    row++;

    // ROW 5
    JPanel rbPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
    rbPanel.add(autoFlushRB);
    rbPanel.add(manualFlushRB);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.insets = new Insets(10, 5, 0, 15);
    Utility.add(guiPanel, rbPanel, gbl, gbc, 0, row, 2, 1);
    row++;

    // ROW 6
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.insets = new Insets(10, 15, 0, 10);
    Utility.add(guiPanel, flushIntervalLabel, gbl, gbc, 0, row, 1, 1);
    gbc.insets = new Insets(10, 0, 0, 15);
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    Utility.add(guiPanel, flushIntervalComboB, gbl, gbc, 1, row, 1, 1);
    row++;

    // ROW 7
    // Put the command buttons in a JPanel so they are all the same size
    JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 15, 0));
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    // Don't have the buttons resize if the dialog is resized
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.ipadx = 20;
    gbc.insets = new Insets(15, 25, 15, 25);
    gbc.anchor = GridBagConstraints.CENTER;
    Utility.add(guiPanel, buttonPanel, gbl, gbc, 0, row, 2, 1);

    // Add guiPanel to the content pane of the parent JFrame
    gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 100;
    gbc.weighty = 100;
    gbc.insets = new Insets(0, 0, 0, 0);
    Utility.add(getContentPane(), guiPanel, gbl, gbc, 0, 0, 1, 1);

    pack();

    // Handle the close operation in the windowClosing() method of the
    // registered WindowListener object.  This will get around
    // JFrame's default behavior of automatically hiding the window when
    // the user clicks on the '[x]' button.
    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            cancelAction();
          }
        });
  }
  public CtrlMenuItemNodeEditPanel() {
    super();

    addTargetURLPanel();

    JRadioButton h_button, v_button;

    {
      final JComboBox reponsor = new JComboBox();
      reponsor.setVisible(false);
      final String jruby_script = "JRuby script responsor";
      reponsor.addItem(jruby_script);

      reponsor.addActionListener(
          new HCActionListener(
              new Runnable() {
                @Override
                public void run() {
                  script_panel.setVisible(reponsor.getSelectedItem().equals(jruby_script));
                }
              },
              threadPoolToken));

      final JButton search = new JButton("search responsor");
      search.setVisible(false);
      search.setToolTipText(
          "<html>search responsor class(es) in current project jar files, "
              + "<BR>responsor is a class to do response biz at server side when some key is pressed. "
              + "<BR>which is a sub class of '"
              + CtrlResponse.class.getName()
              + "'</html>");
      search.addActionListener(
          new HCActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
              System.out.println("do search...");
            }
          });

      cmd_url_panel.add(search);
      cmd_url_panel.add(reponsor);

      {
        final ButtonGroup bg = new ButtonGroup();
        h_button = new JRadioButton("Horizontal"); // , Designer.loadImg("horizontal.png")
        bg.add(h_button);
        v_button = new JRadioButton("Vertical"); // , Designer.loadImg("vertical.png")
        bg.add(v_button);
        h_button.addItemListener(
            new ItemListener() {
              @Override
              public void itemStateChanged(final ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                  ctrl_panel.buildSplitPanel(JSplitPane.HORIZONTAL_SPLIT);
                  ctrl_panel.updateUI();
                  PropertiesManager.setValue(PropertiesManager.p_DesignerCtrlHOrV, IConstant.TRUE);
                  PropertiesManager.saveFile();
                }
              }
            });
        v_button.addItemListener(
            new ItemListener() {
              @Override
              public void itemStateChanged(final ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                  ctrl_panel.buildSplitPanel(JSplitPane.VERTICAL_SPLIT);
                  ctrl_panel.updateUI();
                  PropertiesManager.setValue(PropertiesManager.p_DesignerCtrlHOrV, IConstant.FALSE);
                  PropertiesManager.saveFile();
                }
              }
            });
        hv_panel.add(h_button);
        hv_panel.add(v_button);
        hv_panel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

        cmd_url_panel.add(hv_panel);
      }
    }

    design_panel.setLayout(new BorderLayout());
    {
      script_panel.setLayout(new BorderLayout());
      final JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
      btnPanel.add(testBtn);
      btnPanel.add(formatBtn);
      btnPanel.add(scriptBtn);
      script_panel.add(btnPanel, BorderLayout.NORTH);
      script_panel.add(jtascriptPanel, BorderLayout.CENTER);
      script_panel.setBorder(new TitledBorder(""));

      ctrl_panel = new CtrlTotalPanel(script_panel, this, h_button, v_button);

      design_panel.add(ctrl_panel, BorderLayout.CENTER);
    }

    setLayout(new BorderLayout());
    add(iconPanel, BorderLayout.NORTH);
    add(design_panel, BorderLayout.CENTER);

    final String isV =
        PropertiesManager.getValue(PropertiesManager.p_DesignerCtrlHOrV, IConstant.TRUE);
    if (isV.equals(IConstant.TRUE)) {
      h_button.setSelected(true);
    } else {
      v_button.setSelected(true);
    }
  }
  public JComponent createComponent() {
    final JPanel panel = new JPanel(new GridBagLayout());
    myClassNameField =
        new TextFieldWithBrowseButton(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                PsiClass psiClass =
                    DebuggerUtils.getInstance()
                        .chooseClassDialog(
                            DebuggerBundle.message(
                                "title.compound.renderer.configurable.choose.renderer.reference.type"),
                            myProject);
                if (psiClass != null) {
                  myClassNameField.setText(JVMNameUtil.getNonAnonymousClassName(psiClass));
                }
              }
            });
    myClassNameField
        .getTextField()
        .addFocusListener(
            new FocusAdapter() {
              public void focusLost(FocusEvent e) {
                final String qName = myClassNameField.getText();
                updateContext(qName);
              }
            });

    myRbDefaultLabel =
        new JRadioButton(
            DebuggerBundle.message("label.compound.renderer.configurable.use.default.renderer"));
    myRbExpressionLabel =
        new JRadioButton(
            DebuggerBundle.message("label.compound.renderer.configurable.use.expression"));
    final ButtonGroup labelButtonsGroup = new ButtonGroup();
    labelButtonsGroup.add(myRbDefaultLabel);
    labelButtonsGroup.add(myRbExpressionLabel);

    myRbDefaultChildrenRenderer =
        new JRadioButton(
            DebuggerBundle.message("label.compound.renderer.configurable.use.default.renderer"));
    myRbExpressionChildrenRenderer =
        new JRadioButton(
            DebuggerBundle.message("label.compound.renderer.configurable.use.expression"));
    myRbListChildrenRenderer =
        new JRadioButton(
            DebuggerBundle.message("label.compound.renderer.configurable.use.expression.list"));
    final ButtonGroup childrenButtonGroup = new ButtonGroup();
    childrenButtonGroup.add(myRbDefaultChildrenRenderer);
    childrenButtonGroup.add(myRbExpressionChildrenRenderer);
    childrenButtonGroup.add(myRbListChildrenRenderer);

    myLabelEditor = new DebuggerExpressionTextField(myProject, null, "ClassLabelExpression");
    myChildrenEditor = new DebuggerExpressionTextField(myProject, null, "ClassChildrenExpression");
    myChildrenExpandedEditor =
        new DebuggerExpressionTextField(myProject, null, "ClassChildrenExpression");
    myChildrenListEditor = createChildrenListEditor();

    final ItemListener updateListener =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            updateEnabledState();
          }
        };
    myRbExpressionLabel.addItemListener(updateListener);
    myRbListChildrenRenderer.addItemListener(updateListener);
    myRbExpressionChildrenRenderer.addItemListener(updateListener);

    panel.add(
        new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.apply.to")),
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    panel.add(
        myClassNameField,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(4, 0, 0, 0),
            0,
            0));

    panel.add(
        new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.when.rendering")),
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(20, 0, 0, 0),
            0,
            0));
    panel.add(
        myRbDefaultLabel,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    panel.add(
        myRbExpressionLabel,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    panel.add(
        myLabelEditor,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 30, 0, 0),
            0,
            0));

    panel.add(
        new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.when.expanding")),
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(20, 0, 0, 0),
            0,
            0));
    panel.add(
        myRbDefaultChildrenRenderer,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    panel.add(
        myRbExpressionChildrenRenderer,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    panel.add(
        myChildrenEditor,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 30, 0, 0),
            0,
            0));
    myExpandedLabel =
        new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.test.can.expand"));
    panel.add(
        myExpandedLabel,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(4, 30, 0, 0),
            0,
            0));
    panel.add(
        myChildrenExpandedEditor,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 30, 0, 0),
            0,
            0));
    panel.add(
        myRbListChildrenRenderer,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 10, 0, 0),
            0,
            0));
    panel.add(
        myChildrenListEditor,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(4, 30, 0, 0),
            0,
            0));

    myMainPanel = new JPanel(new CardLayout());
    myMainPanel.add(new JPanel(), EMPTY_PANEL_ID);
    myMainPanel.add(panel, DATA_PANEL_ID);
    return myMainPanel;
  }
  public TrimConverterField(
      JComponent parent,
      String param,
      String label,
      String defaultValue,
      ChangedConfigurationListener listener) {
    this.userLabel = label;
    JPanel filler = new JPanel();
    filler.setMinimumSize(new Dimension(40, 20));
    enable = new JCheckBox("Enable");
    radioCut = new JRadioButton();
    radioLeave = new JRadioButton();
    radioCut.setSelected(true);
    radioLeave.setSelected(false);
    group = new ButtonGroup();
    group.add(radioCut);
    group.add(radioLeave);
    cutNumber = new JSpinner(new SpinnerNumberModel(0, 0, 1000, 1));
    leaveNumber = new JSpinner(new SpinnerNumberModel(0, 0, 1000, 1));

    enable.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent arg0) {
            if (enable.isSelected()) {
              radioCut.setEnabled(true);
              radioLeave.setEnabled(true);
              if (radioCut.isSelected()) {
                cutNumber.setEnabled(true);
                labelCut.setEnabled(true);
                labelCut1.setEnabled(true);
                labelLeave.setEnabled(false);
                labelLeave1.setEnabled(false);
              } else {
                leaveNumber.setEnabled(true);
                labelCut.setEnabled(false);
                labelCut1.setEnabled(false);
                labelLeave.setEnabled(true);
                labelLeave1.setEnabled(true);
              }
            } else {
              radioCut.setEnabled(false);
              radioLeave.setEnabled(false);
              cutNumber.setEnabled(false);
              leaveNumber.setEnabled(false);
              labelCut.setEnabled(false);
              labelCut1.setEnabled(false);
              labelLeave.setEnabled(false);
              labelLeave1.setEnabled(false);
            }
          }
        });
    radioCut.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (radioCut.isSelected()) {
              leaveNumber.setEnabled(false);
              cutNumber.setEnabled(true);
              labelCut.setEnabled(true);
              labelCut1.setEnabled(true);
              labelLeave.setEnabled(false);
              labelLeave1.setEnabled(false);
            }
          }
        });
    radioLeave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (radioLeave.isSelected()) {
              leaveNumber.setEnabled(true);
              cutNumber.setEnabled(false);
              labelCut.setEnabled(false);
              labelCut1.setEnabled(false);
              labelLeave.setEnabled(true);
              labelLeave1.setEnabled(true);
            }
          }
        });

    paramName = new JLabel(label);
    // paramName.setPreferredSize(new Dimension(200,
    // (int)paramName.getPreferredSize().getHeight()));

    panel = new JPanel();
    panel.setLayout(new FlowLayout());
    // panel.add(paramName);
    panel.add(enable);
    panel.add(filler);
    panel.add(radioCut);
    panel.add(labelCut);
    panel.add(cutNumber);
    panel.add(labelCut1);
    panel.add(filler);
    panel.add(radioLeave);
    panel.add(labelLeave);
    panel.add(leaveNumber);
    panel.add(labelLeave1);
    setValue(defaultValue);

    if (listener != null) {
      radioCut.addItemListener(new ItemListenerProxy(listener));
      radioLeave.addItemListener(new ItemListenerProxy(listener));
      leaveNumber.addChangeListener(new ChangeListenerProxy(listener));
      cutNumber.addChangeListener(new ChangeListenerProxy(listener));
      enable.addActionListener(new ActionListenerProxy(listener));
    }
  }
示例#25
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame("FVS ALGORITHM GURNIAK JEDYNAK");
    frame.setBounds(350, 150, 1215, 798);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new GridLayout(1, 0, 0, 0));

    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.setLayout(new GridLayout(1, 0, 0, 0));

    textArea = new JTextArea();
    // panel.add( textArea );

    textArea.setEditable(false);
    JScrollPane scroll = new JScrollPane(textArea);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    panel.add(scroll);

    JPanel panel_1 = new JPanel();
    panel.add(panel_1);
    panel_1.setLayout(new GridLayout(3, 1));

    JPanel panel_3 = new JPanel();
    panel_1.add(panel_3);
    panel_3.setLayout(new GridLayout(2, 1));

    JPanel panel_3a = new JPanel();
    panel_3a.setLayout(new GridLayout(3, 1));
    panel_3.add(panel_3a);

    JLabel lbChooseAlgorithm = new JLabel("Wybór algorytmu");
    lbChooseAlgorithm.setFont(new Font("Tahoma", Font.BOLD, 11));
    lbChooseAlgorithm.setHorizontalAlignment(SwingConstants.CENTER);
    panel_3a.add(lbChooseAlgorithm);

    chkBoxBruteForceAlgorithm = new JCheckBox("Algorytm Brute-force");
    chkBoxBruteForceAlgorithm.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent arg0) {
            if (chkBoxBruteForceAlgorithm.isSelected()) {
              // textArea.setText( "Wybrano algorytm Brute Force" );
              CommonVariables.getInstance().GENERUJ_ALGORYTM_BRUTE_FORCE = true;
            } else {
              // textArea.setText( "Nie wybrano algorytm Brute Force" );
              CommonVariables.getInstance().GENERUJ_ALGORYTM_BRUTE_FORCE = false;
            }
          }
        });

    /*        chkBoxBruteForceAlgorithm.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            if(chkBoxBruteForceAlgorithm.isSelected())
            {
                textArea.setText( "Wybrano algorytm Brute Force" );
            }else
            {
                textArea.setText( "Nie wybrano algorytm Brute Force" );
            }
        }
    });*/
    chkBoxBruteForceAlgorithm.setSelected(true);
    panel_3a.add(chkBoxBruteForceAlgorithm);

    chkBoxLayerAlgorithm = new JCheckBox("Algorytm warstwowy");
    chkBoxLayerAlgorithm.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (chkBoxLayerAlgorithm.isSelected()) {
              // textArea.setText( "Wybrano algorytm Warstwowy" );
              CommonVariables.getInstance().GENERUJ_ALGORYTM_WARSTWOWY = true;
            } else {
              // textArea.setText( "Nie wybrano algorytm Warstwowy" );
              CommonVariables.getInstance().GENERUJ_ALGORYTM_WARSTWOWY = false;
            }
          }
        });
    /*        chkBoxLayerAlgorithm.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if(chkBoxLayerAlgorithm.isSelected())
            {
                textArea.setText( "Wybrano algorytm Warstwowy" );
            }else
            {
                textArea.setText( "Nie wybrano algorytm Warstwowy" );
            }
        }
    });*/

    chkBoxLayerAlgorithm.setSelected(true);
    panel_3a.add(chkBoxLayerAlgorithm);

    JPanel panel_3b = new JPanel();
    panel_3.add(panel_3b);
    panel_3b.setLayout(new GridLayout(3, 1));

    JLabel lblNewLabel_1 = new JLabel("Typ pomiaru");
    lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 11));
    lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
    panel_3b.add(lblNewLabel_1);

    chkBoxComputeComplexity = new JCheckBox("Czas wykonania");
    chkBoxComputeComplexity.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (chkBoxComputeComplexity.isSelected()) {
              // textArea.setText(
              // "Wybrano pomiar z³o¿onoœci obliczeniowej" );
              CommonVariables.getInstance().GENERUJ_POMIAR_ZLOZONOSCI_OBLICZENIOWEJ = true;
            } else {
              // textArea.setText(
              // "Nie wybrano pomiar z³o¿onoœci obliczeniowej" );
              CommonVariables.getInstance().GENERUJ_POMIAR_ZLOZONOSCI_OBLICZENIOWEJ = false;
            }
          }
        });

    chkBoxComputeComplexity.setSelected(true);
    panel_3b.add(chkBoxComputeComplexity);

    chkBoxComputeMemory = new JCheckBox("Z³o¿onoœæ pamiêciowa");
    chkBoxComputeMemory.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (chkBoxComputeMemory.isSelected()) {
              CommonVariables.getInstance().GENERUJ_POMIAR_ZLOZONOSCI_PAMIECIOWEJ = true;
            } else {
              CommonVariables.getInstance().GENERUJ_POMIAR_ZLOZONOSCI_PAMIECIOWEJ = false;
            }
          }
        });
    chkBoxComputeMemory.setEnabled(false);
    panel_3b.add(chkBoxComputeMemory);

    JPanel panel_10 = new JPanel();
    panel_10.setLayout(new GridLayout(4, 1));
    panel_1.add(panel_10);

    JPanel panel_5 = new JPanel();
    panel_10.add(panel_5);
    panel_5.setBounds(0, 2, 392, 45);

    JLabel lblNewLabel_2 = new JLabel("Ustawienia generatora");
    panel_5.add(lblNewLabel_2);
    lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
    lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 11));

    JPanel panel_7 = new JPanel();
    panel_10.add(panel_7);
    panel_7.setBounds(0, 137, 392, 45);
    panel_7.setLayout(null);

    JLabel label_1 = new JLabel("Liczba generowanych grafów");
    label_1.setBounds(206, 8, 183, 14);
    panel_7.add(label_1);

    tfNumberOfGraphs = new JTextField();
    tfNumberOfGraphs.setColumns(10);
    tfNumberOfGraphs.setBounds(10, 8, 48, 20);
    panel_7.add(tfNumberOfGraphs);
    tfNumberOfGraphs.setText(CommonVariables.getInstance().LICZBA_GENEROWANYCH_GRAFOW_W_SERII + "");

    JPanel panel_8 = new JPanel();
    panel_10.add(panel_8);
    panel_8.setLayout(new GridLayout(1, 3));

    rbRandomWeight = new JRadioButton("wagi losowe bez powtórzeñ");
    rbRandomWeight.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (rbRandomWeight.isSelected()) {
              // textArea.setText( "Wybrano wagê losow¹" );
              // CommonVariables.getInstance().CZY_WAGOWY = true;
              CommonVariables.getInstance().WAGI_ROWNE_JEDEN = false;
              CommonVariables.getInstance().WAGI_LOSOWE_BEZ_POWTORZEN = true;
              CommonVariables.getInstance().WAGI_LOSOWE_Z_POWTORZENIAMI = false;
            }
          }
        });
    panel_8.add(rbRandomWeight);
    rbRandomWeight.setSelected(true);
    rbRandomWeight.setHorizontalAlignment(SwingConstants.LEFT);

    rbStateWeight = new JRadioButton("wagi sta³e");
    rbStateWeight.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (rbStateWeight.isSelected()) {
              // textArea.setText( "Wybrano sta³¹ wagê" );
              CommonVariables.getInstance().WAGI_ROWNE_JEDEN = true;
              CommonVariables.getInstance().WAGI_LOSOWE_BEZ_POWTORZEN = false;
              CommonVariables.getInstance().WAGI_LOSOWE_Z_POWTORZENIAMI = false;
            }
          }
        });

    rdbtnWagiLosoweZ = new JRadioButton("wagi losowe z powtórzeniami");
    rdbtnWagiLosoweZ.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent arg0) {
            if (rdbtnWagiLosoweZ.isSelected()) {
              CommonVariables.getInstance().WAGI_ROWNE_JEDEN = false;
              CommonVariables.getInstance().WAGI_LOSOWE_BEZ_POWTORZEN = false;
              CommonVariables.getInstance().WAGI_LOSOWE_Z_POWTORZENIAMI = true;
            }
          }
        });
    panel_8.add(rdbtnWagiLosoweZ);
    panel_8.add(rbStateWeight);
    rbStateWeight.setHorizontalAlignment(SwingConstants.LEFT);

    ButtonGroup btButtonGroup = new ButtonGroup();
    btButtonGroup.add(rbRandomWeight);
    btButtonGroup.add(rbStateWeight);
    btButtonGroup.add(rdbtnWagiLosoweZ);

    JPanel panel_9 = new JPanel();
    panel_10.add(panel_9);
    panel_9.setLayout(new GridLayout(2, 1));

    lblNewLabel_4 = new JLabel("Gêstoœæ grafu [ 0.00 ]");
    lblNewLabel_4.setHorizontalAlignment(SwingConstants.CENTER);
    panel_9.add(lblNewLabel_4);

    sliderDensityGraph = new JSlider();
    sliderDensityGraph.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            int value = sliderDensityGraph.getValue();
            double setValue = value / 100.0;
            lblNewLabel_4.setText("Gêstoœæ grafu [ " + setValue + " ]");
            // textArea.setText( "Slider value = " + setValue );
            CommonVariables.getInstance().GESTOSC_GRAFU = setValue;
          }
        });
    sliderDensityGraph.setToolTipText("Ustaw gêstoœæ grafu z zakresu 0,01 - 1,00");
    sliderDensityGraph.setSnapToTicks(true);
    sliderDensityGraph.setPaintTicks(true);
    sliderDensityGraph.setPaintLabels(true);
    sliderDensityGraph.setMinorTickSpacing(1);
    sliderDensityGraph.setValue(0);
    panel_9.add(sliderDensityGraph);

    JPanel panel_2 = new JPanel();
    panel_1.add(panel_2);
    panel_2.setLayout(new GridLayout(4, 1));

    JPanel panel_4 = new JPanel();
    panel_2.add(panel_4);
    panel_4.setBounds(0, 92, 392, 45);
    panel_4.setLayout(null);

    JLabel label = new JLabel("Zakres wierzcho³ków w serii");
    label.setBounds(202, 14, 187, 14);
    panel_4.add(label);

    spinnerVertexFrom = new JSpinner();
    spinnerVertexFrom.setModel(new SpinnerNumberModel(3, 3, 16, 1));
    spinnerVertexFrom.setBounds(36, 11, 39, 20);
    panel_4.add(spinnerVertexFrom);

    spinnerVertextTo = new JSpinner();
    spinnerVertextTo.setModel(new SpinnerNumberModel(3, 3, 16, 1));
    spinnerVertextTo.setBounds(119, 11, 39, 20);
    panel_4.add(spinnerVertextTo);

    JLabel lblOd = new JLabel("od");
    lblOd.setBounds(10, 14, 16, 14);
    panel_4.add(lblOd);

    JLabel lblDo = new JLabel("do");
    lblDo.setBounds(93, 14, 16, 14);
    panel_4.add(lblDo);

    JPanel panel_6 = new JPanel();
    panel_6.setBounds(0, 47, 392, 45);
    panel_2.add(panel_6);
    panel_6.setLayout(null);

    tfNumberOfMeasurements = new JTextField();
    tfNumberOfMeasurements.setBounds(10, 11, 48, 20);
    panel_6.add(tfNumberOfMeasurements);
    tfNumberOfMeasurements.setColumns(10);

    tfNumberOfMeasurements.setText(
        CommonVariables.getInstance().LICZBA_SERII_POMIAROW_DLA_JEDNEGO_ZADANIA + "");

    JLabel lblNewLabel_3 = new JLabel("Iloœæ pomiarów dla zadania");
    lblNewLabel_3.setBounds(204, 14, 185, 14);
    panel_6.add(lblNewLabel_3);

    JPanel panel_11 = new JPanel();
    panel_2.add(panel_11);

    JLabel lblRozpocznijSymulacj = new JLabel("Rozpocznij symulacjê");
    lblRozpocznijSymulacj.setFont(new Font("Tahoma", Font.BOLD, 11));
    panel_11.add(lblRozpocznijSymulacj);

    JPanel panel_12 = new JPanel();
    panel_2.add(panel_12);

    JButton btnStart = new JButton("Start");

    btnStart.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            // textArea.setText( "Wciœniêto Start i rozpoczêto symulacjê\n"
            // );
            // textArea.append( "Liczba generowanych grafów = " +
            // tfNumberOfGraphs.getText() + "\n" );
            // textArea.append( "Iloœæ pomiarów dla zadania = " +
            // tfNumberOfMeasurements.getText() + "\n" );
            // textArea.append( "Od = " + spinnerVertexFrom.getValue() +
            // "\n" );
            // textArea.append( "Do = " + spinnerVertextTo.getValue() + "\n"
            // );

            if (
            /* !tfNumberOfGraphs.getText().toString().trim().isEmpty() && */ !tfNumberOfGraphs
                .getText()
                .equals(new String(""))) {
              CommonVariables.getInstance().LICZBA_GENEROWANYCH_GRAFOW_W_SERII =
                  Integer.valueOf(tfNumberOfGraphs.getText());
            } else {
              System.out.println("Podaj liczbê w iloœci generowanych grafów!");
            }
            if (
            /*!tfNumberOfMeasurements.getText().trim().isEmpty() && */ !tfNumberOfMeasurements
                .getText()
                .equals(new String(""))) {
              CommonVariables.getInstance().LICZBA_SERII_POMIAROW_DLA_JEDNEGO_ZADANIA =
                  Integer.valueOf(tfNumberOfMeasurements.getText());
            } else {
              System.out.println("Podaj liczbê w iloœæ pomiarów dla zadania!");
            }
            // CommonVariables.getInstance().LICZBA_SERII_POMIAROW_DLA_JEDNEGO_ZADANIA
            // = Integer.valueOf( tfNumberOfMeasurements.getText().trim() );
            CommonVariables.getInstance().SERIA_POMIAROW_OD = (int) spinnerVertexFrom.getValue();
            CommonVariables.getInstance().SERIA_POMIAROW_DO = (int) spinnerVertextTo.getValue();

            setDisableComponents();

            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    // JOptionPane.showMessageDialog(frame, "Proszê czekaæ...");
                    runAlgorithms();
                  }
                });

            // runAlgorithms();
            setEnableComponents();
          }
        });
    btnStart.setForeground(new Color(0, 0, 0));
    panel_12.add(btnStart);
  }
示例#26
0
 /**
  * Constructor for an option button controlled collapsable panel. This is useful when a group of
  * options each have unique sub contents. The radio buttons should be created, grouped, and then
  * used to construct their own collapsable panels. This way choosing a different option in the
  * same option group will collapse all unselected options. Expanded panels draw a border around
  * the contents and through the radio button in the fashion of a titled border.
  *
  * @param component Radio button that expands and collapses the panel based on if it is selected
  *     or not
  */
 public CollapsablePanel(JRadioButton component) {
   component.addItemListener(new CollapsablePanel.ExpandAndCollapseAction());
   titleComponent = component;
   collapsed = !component.isSelected();
   commonConstructor();
 }
示例#27
0
  @Override
  public void installUI(final JComponent c) {
    super.installUI(c);

    radioButton = (JRadioButton) c;

    // Default settings
    SwingUtils.setOrientation(c);
    radioButton.setOpaque(false);

    // Initial check state
    checkIcon = radioButton.isSelected() ? CHECK_STATES.size() - 1 : 0;

    // Updating border and icon
    updateBorder();
    updateIcon(radioButton);

    // Background fade animation
    bgTimer =
        new WebTimer(
            "WebRadioButtonUI.bgUpdater",
            40,
            new ActionListener() {
              @Override
              public void actionPerformed(final ActionEvent e) {
                if (rollover && bgDarkness < MAX_DARKNESS) {
                  bgDarkness++;
                  c.repaint();
                } else if (!rollover && bgDarkness > 0) {
                  bgDarkness--;
                  c.repaint();
                } else {
                  bgTimer.stop();
                }
              }
            });
    mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mouseEntered(final MouseEvent e) {
            rollover = true;
            if (isAnimated()) {
              bgTimer.start();
            } else {
              bgDarkness = MAX_DARKNESS;
              c.repaint();
            }
          }

          @Override
          public void mouseExited(final MouseEvent e) {
            rollover = false;
            if (isAnimated()) {
              bgTimer.start();
            } else {
              bgDarkness = 0;
              c.repaint();
            }
          }
        };
    radioButton.addMouseListener(mouseAdapter);

    // Selection changes animation
    checkTimer =
        new WebTimer(
            "WebRadioButtonUI.iconUpdater",
            40,
            new ActionListener() {
              @Override
              public void actionPerformed(final ActionEvent e) {
                if (checking && checkIcon < CHECK_STATES.size() - 1) {
                  checkIcon++;
                  c.repaint();
                } else if (!checking && checkIcon > 0) {
                  checkIcon--;
                  c.repaint();
                } else {
                  checkTimer.stop();
                }
              }
            });
    itemListener =
        new ItemListener() {
          @Override
          public void itemStateChanged(final ItemEvent e) {
            if (animated) {
              if (radioButton.isSelected()) {
                checking = true;
                checkTimer.start();
              } else {
                checking = false;
                checkTimer.start();
              }
            } else {
              checkTimer.stop();
              checkIcon = radioButton.isSelected() ? CHECK_STATES.size() - 1 : 0;
              c.repaint();
            }
          }
        };
    radioButton.addItemListener(itemListener);
  }
示例#28
0
  public SearchManager2(JabRefFrame frame, SidePaneManager manager) {
    super(manager, GUIGlobals.getIconUrl("search"), Globals.lang("Search"));

    this.frame = frame;
    incSearcher = new IncrementalSearcher(Globals.prefs);

    // setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.magenta));

    searchReq =
        new JCheckBoxMenuItem(
            Globals.lang("Search required fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_REQ));
    searchOpt =
        new JCheckBoxMenuItem(
            Globals.lang("Search optional fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_OPT));
    searchGen =
        new JCheckBoxMenuItem(
            Globals.lang("Search general fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_GEN));
    searchAll =
        new JCheckBoxMenuItem(
            Globals.lang("Search all fields"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL));
    regExpSearch =
        new JCheckBoxMenuItem(
            Globals.lang("Use regular expressions"),
            Globals.prefs.getBoolean(JabRefPreferences.REG_EXP_SEARCH));

    increment = new JRadioButton(Globals.lang("Incremental"), false);
    floatSearch = new JRadioButton(Globals.lang("Float"), true);
    hideSearch = new JRadioButton(Globals.lang("Filter"), true);
    showResultsInDialog = new JRadioButton(Globals.lang("Show results in dialog"), true);
    searchAllBases =
        new JRadioButton(
            Globals.lang("Global search"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL_BASES));
    ButtonGroup types = new ButtonGroup();
    types.add(increment);
    types.add(floatSearch);
    types.add(hideSearch);
    types.add(showResultsInDialog);
    types.add(searchAllBases);

    select = new JCheckBoxMenuItem(Globals.lang("Select matches"), false);
    increment.setToolTipText(Globals.lang("Incremental search"));
    floatSearch.setToolTipText(Globals.lang("Gray out non-matching entries"));
    hideSearch.setToolTipText(Globals.lang("Hide non-matching entries"));
    showResultsInDialog.setToolTipText(Globals.lang("Show search results in a window"));

    // Add an item listener that makes sure we only listen for key events
    // when incremental search is turned on.
    increment.addItemListener(this);
    floatSearch.addItemListener(this);
    hideSearch.addItemListener(this);
    showResultsInDialog.addItemListener(this);
    // Add the global focus listener, so a menu item can see if this field was focused when
    // an action was called.
    searchField.addFocusListener(Globals.focusListener);

    if (searchAll.isSelected()) {
      searchReq.setEnabled(false);
      searchOpt.setEnabled(false);
      searchGen.setEnabled(false);
    }
    searchAll.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent event) {
            boolean state = !searchAll.isSelected();
            searchReq.setEnabled(state);
            searchOpt.setEnabled(state);
            searchGen.setEnabled(state);
          }
        });

    caseSensitive =
        new JCheckBoxMenuItem(
            Globals.lang("Case sensitive"),
            Globals.prefs.getBoolean(JabRefPreferences.CASE_SENSITIVE_SEARCH));

    highLightWords =
        new JCheckBoxMenuItem(
            Globals.lang("Highlight Words"),
            Globals.prefs.getBoolean(JabRefPreferences.HIGH_LIGHT_WORDS));

    searchAutoComplete =
        new JCheckBoxMenuItem(
            Globals.lang("Autocomplete names"),
            Globals.prefs.getBoolean(JabRefPreferences.SEARCH_AUTO_COMPLETE));
    settings.add(select);

    // 2005.03.29, trying to remove field category searches, to simplify
    // search usability.
    // settings.addSeparator();
    // settings.add(searchReq);
    // settings.add(searchOpt);
    // settings.add(searchGen);
    // settings.addSeparator();
    // settings.add(searchAll);
    // ---------------------------------------------------------------
    settings.addSeparator();
    settings.add(caseSensitive);
    settings.add(regExpSearch);
    settings.addSeparator();
    settings.add(highLightWords);
    settings.addSeparator();
    settings.add(searchAutoComplete);

    searchField.addActionListener(this);
    searchField.addCaretListener(this);
    search.addActionListener(this);
    searchField.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent e) {
            if (increment.isSelected()) {
              searchField.setText("");
            }
          }

          @Override
          public void focusLost(FocusEvent e) {
            incSearch = false;
            incSearchPos = -1; // Reset incremental
            // search. This makes the
            // incremental search reset
            // once the user moves focus to
            // somewhere else.
            if (increment.isSelected()) {
              // searchField.setText("");
              // System.out.println("focuslistener");
            }
          }
        });
    escape.addActionListener(this);
    escape.setEnabled(false); // enabled after searching

    openset.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (settings.isVisible()) {
              // System.out.println("oee");
              // settings.setVisible(false);
            } else {
              JButton src = (JButton) e.getSource();
              settings.show(src, 0, openset.getHeight());
            }
          }
        });

    searchAutoComplete.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            Globals.prefs.putBoolean(
                JabRefPreferences.SEARCH_AUTO_COMPLETE, searchAutoComplete.isSelected());
            if (SearchManager2.this.frame.basePanel() != null) {
              SearchManager2.this.frame.basePanel().updateSearchManager();
            }
          }
        });
    Insets margin = new Insets(0, 2, 0, 2);
    // search.setMargin(margin);
    escape.setMargin(margin);
    openset.setMargin(margin);
    JButton help = new JButton(GUIGlobals.getImage("help"));
    int butSize = help.getIcon().getIconHeight() + 5;
    Dimension butDim = new Dimension(butSize, butSize);
    help.setPreferredSize(butDim);
    help.setMinimumSize(butDim);
    help.setMargin(margin);
    help.addActionListener(new HelpAction(Globals.helpDiag, GUIGlobals.searchHelp, "Help"));

    // Select the last used mode of search:
    if (Globals.prefs.getBoolean(JabRefPreferences.INCREMENT_S)) {
      increment.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.FLOAT_SEARCH)) {
      floatSearch.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.SHOW_SEARCH_IN_DIALOG)) {
      showResultsInDialog.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.SEARCH_ALL_BASES)) {
      searchAllBases.setSelected(true);
    } else {
      hideSearch.setSelected(true);
    }

    JPanel main = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    main.setLayout(gbl);
    GridBagConstraints con = new GridBagConstraints();
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.fill = GridBagConstraints.BOTH;
    con.weightx = 1;

    gbl.setConstraints(searchField, con);
    main.add(searchField);
    // con.gridwidth = 1;
    gbl.setConstraints(search, con);
    main.add(search);
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(escape, con);
    main.add(escape);
    con.insets = new Insets(0, 2, 0, 0);
    gbl.setConstraints(increment, con);
    main.add(increment);
    gbl.setConstraints(floatSearch, con);
    main.add(floatSearch);
    gbl.setConstraints(hideSearch, con);
    main.add(hideSearch);
    gbl.setConstraints(showResultsInDialog, con);
    main.add(showResultsInDialog);
    gbl.setConstraints(searchAllBases, con);
    main.add(searchAllBases);
    con.insets = new Insets(0, 0, 0, 0);
    JPanel pan = new JPanel();
    GridBagLayout gb = new GridBagLayout();
    gbl.setConstraints(pan, con);
    pan.setLayout(gb);
    con.weightx = 1;
    con.gridwidth = 1;
    gb.setConstraints(openset, con);
    pan.add(openset);
    con.weightx = 0;
    gb.setConstraints(help, con);
    pan.add(help);
    main.add(pan);
    main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));

    setContentContainer(main);

    searchField.getInputMap().put(Globals.prefs.getKey("Repeat incremental search"), "repeat");

    searchField
        .getActionMap()
        .put(
            "repeat",
            new AbstractAction() {

              @Override
              public void actionPerformed(ActionEvent e) {
                if (increment.isSelected()) {
                  repeatIncremental();
                }
              }
            });
    searchField.getInputMap().put(Globals.prefs.getKey("Clear search"), "escape");
    searchField
        .getActionMap()
        .put(
            "escape",
            new AbstractAction() {

              @Override
              public void actionPerformed(ActionEvent e) {
                hideAway();
                // SearchManager2.this.actionPerformed(new ActionEvent(escape, 0, ""));
              }
            });
    setSearchButtonSizes();
    updateSearchButtonText();
  }
示例#29
0
  /** Create the frame. */
  public mainframe_test() {
    setTitle("EXAM SYSTEM");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 709, 472);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new CardLayout(0, 0));

    login = new JPanel();
    contentPane.add(login, "login");
    login.setLayout(null);

    JButton button = new JButton("STUDENT");
    button.setFont(new Font("SimSun", Font.PLAIN, 22));
    button.setBounds(425, 133, 146, 45);
    login.add(button);
    button.addActionListener(new PersonAction());

    JButton btnInstructor = new JButton("INSTRUCTOR");
    btnInstructor.setFont(new Font("SimSun", Font.PLAIN, 22));
    btnInstructor.setBounds(425, 233, 146, 45);
    login.add(btnInstructor);
    btnInstructor.addActionListener(new teacherAction());

    JLabel lblUcid = new JLabel("UCID");
    lblUcid.setFont(new Font("SimSun", Font.PLAIN, 30));
    lblUcid.setBounds(39, 101, 146, 32);
    login.add(lblUcid);

    textField = new JTextField();
    textField.setFont(new Font("SimSun", Font.PLAIN, 30));
    textField.setColumns(10);
    textField.setBounds(39, 146, 206, 32);
    login.add(textField);

    JLabel label_1 = new JLabel("OR");
    label_1.setFont(new Font("SimSun", Font.PLAIN, 34));
    label_1.setBounds(486, 191, 81, 32);
    login.add(label_1);

    JLabel label_2 = new JLabel("Password");
    label_2.setFont(new Font("SimSun", Font.PLAIN, 30));
    label_2.setBounds(39, 191, 146, 32);
    login.add(label_2);

    button_2 = new JButton("EXIT SYSTEM");
    button_2.setFont(new Font("SimSun", Font.PLAIN, 30));
    button_2.addActionListener(new button2());
    button_2.setBounds(224, 329, 213, 45);
    login.add(button_2);

    JLabel label_3 = new JLabel("     Welcome to online exam system");
    label_3.setFont(new Font("Arial", Font.BOLD, 38));
    label_3.setBounds(0, 13, 677, 68);
    login.add(label_3);

    passwordField = new JPasswordField();
    passwordField.setFont(new Font("SimSun", Font.PLAIN, 30));
    passwordField.setBounds(39, 246, 206, 32);
    login.add(passwordField);

    student = new JPanel();
    contentPane.add(student, "student");
    student.setLayout(null);

    JDesktopPane desktopPane = new JDesktopPane();
    desktopPane.setBackground(Color.WHITE);
    desktopPane.setBounds(0, 0, 681, 417);
    student.add(desktopPane);

    JLabel lblStudentId = new JLabel("UCID:");
    lblStudentId.setHorizontalAlignment(SwingConstants.CENTER);
    lblStudentId.setFont(new Font("SimSun", Font.PLAIN, 24));
    lblStudentId.setBounds(14, 0, 153, 40);
    desktopPane.add(lblStudentId);

    JPanel tree = new JPanel();
    tree.setBackground(Color.WHITE);
    tree.setBounds(0, 36, 131, 381);
    desktopPane.add(tree);
    tree.setLayout(null);

    tree_1 = new JTree();
    tree_1.setModel(
        new DefaultTreeModel(
            new DefaultMutableTreeNode("Index") {
              {
                DefaultMutableTreeNode node_1;
                node_1 = new DefaultMutableTreeNode("Questions");
                node_1.add(new DefaultMutableTreeNode("1"));
                node_1.add(new DefaultMutableTreeNode("2"));
                node_1.add(new DefaultMutableTreeNode("3"));
                node_1.add(new DefaultMutableTreeNode("4"));
                node_1.add(new DefaultMutableTreeNode("5"));
                node_1.add(new DefaultMutableTreeNode("6"));
                node_1.add(new DefaultMutableTreeNode("7"));
                node_1.add(new DefaultMutableTreeNode("8"));
                node_1.add(new DefaultMutableTreeNode("9"));
                node_1.add(new DefaultMutableTreeNode("10"));
                getContentPane().add(node_1);
                getContentPane().add(new DefaultMutableTreeNode("Submit"));
              }
            }));
    tree_1.setBounds(14, 13, 103, 322);
    tree_1.addTreeSelectionListener(
        new javax.swing.event.TreeSelectionListener() {
          public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
            treeValueChanged(evt);
          }
        });
    tree.add(tree_1);

    content = new JPanel();
    content.setBounds(134, 36, 547, 381);
    desktopPane.add(content);
    content.setLayout(new CardLayout(0, 0));

    ready = new JPanel();
    content.add(ready, "ready");
    ready.setLayout(null);

    JLabel lblTheExamsTotal = new JLabel("The exam's total time is 3 H.");
    lblTheExamsTotal.setHorizontalAlignment(SwingConstants.CENTER);
    lblTheExamsTotal.setFont(new Font("SimSun", Font.BOLD, 30));
    lblTheExamsTotal.setBounds(25, 24, 508, 67);
    ready.add(lblTheExamsTotal);

    JLabel lblWishYouAll = new JLabel("Wish you all the best.");
    lblWishYouAll.setFont(new Font("SimSun", Font.BOLD, 30));
    lblWishYouAll.setHorizontalAlignment(SwingConstants.CENTER);
    lblWishYouAll.setBounds(25, 106, 508, 67);
    ready.add(lblWishYouAll);

    JLabel lblReady = new JLabel("Ready?");
    lblReady.setHorizontalAlignment(SwingConstants.CENTER);
    lblReady.setFont(new Font("SimSun", Font.BOLD, 30));
    lblReady.setBounds(112, 186, 313, 67);
    ready.add(lblReady);

    JButton btnNewButton = new JButton("Go");
    btnNewButton.setFont(new Font("SimSun", Font.PLAIN, 20));
    btnNewButton.setBounds(197, 266, 130, 42);
    btnNewButton.addActionListener(new Go());
    ready.add(btnNewButton);

    Question_T = new JPanel();
    content.add(Question_T, "Question_T");
    Question_T.setLayout(null);

    textPane = new JTextPane();
    textPane.setBounds(33, 13, 489, 225);
    Question_T.add(textPane);

    True = new JRadioButton("True");
    True.setBounds(48, 278, 157, 27);
    True.addItemListener(new TFRadio());
    Question_T.add(True);

    False = new JRadioButton("False");
    False.setBounds(319, 278, 157, 27);
    False.addItemListener(new TFRadio());
    Question_T.add(False);
    BG1 = new ButtonGroup();
    BG1.add(True);
    BG1.add(False);

    BG2 = new ButtonGroup();

    Question_M = new JPanel();
    content.add(Question_M, "Question_M");
    Question_M.setLayout(null);

    textPane_1 = new JTextPane();
    textPane_1.setBounds(27, 13, 489, 225);
    Question_M.add(textPane_1);

    rdbtnNewRadioButton = new JRadioButton("A");
    rdbtnNewRadioButton.setHorizontalAlignment(SwingConstants.CENTER);
    rdbtnNewRadioButton.setBounds(26, 257, 81, 27);
    rdbtnNewRadioButton.addItemListener(new TFRadio());
    Question_M.add(rdbtnNewRadioButton);

    rdbtnB = new JRadioButton("B");
    rdbtnB.setHorizontalAlignment(SwingConstants.CENTER);
    rdbtnB.setBounds(275, 257, 81, 27);
    rdbtnB.addItemListener(new TFRadio());
    Question_M.add(rdbtnB);

    rdbtnC = new JRadioButton("C");
    rdbtnC.setHorizontalAlignment(SwingConstants.CENTER);
    rdbtnC.setBounds(27, 289, 81, 27);
    rdbtnC.addItemListener(new TFRadio());
    Question_M.add(rdbtnC);

    rdbtnD = new JRadioButton("D");
    rdbtnD.setHorizontalAlignment(SwingConstants.CENTER);
    rdbtnD.setBounds(275, 289, 81, 27);
    rdbtnD.addItemListener(new TFRadio());
    Question_M.add(rdbtnD);

    BG2.add(rdbtnNewRadioButton);
    BG2.add(rdbtnB);
    BG2.add(rdbtnC);
    BG2.add(rdbtnD);

    Submit = new JPanel();
    content.add(Submit, "Submit");
    Submit.setLayout(null);

    JLabel lblHaveYouFinished = new JLabel("Have you finished all the questions?");
    lblHaveYouFinished.setHorizontalAlignment(SwingConstants.CENTER);
    lblHaveYouFinished.setFont(new Font("SimSun", Font.BOLD, 22));
    lblHaveYouFinished.setBounds(14, 42, 508, 59);
    Submit.add(lblHaveYouFinished);

    JLabel lblOnceYouSubmitno = new JLabel("Once you submit,");
    lblOnceYouSubmitno.setHorizontalAlignment(SwingConstants.CENTER);
    lblOnceYouSubmitno.setFont(new Font("SimSun", Font.BOLD, 22));
    lblOnceYouSubmitno.setBounds(24, 111, 508, 59);
    Submit.add(lblOnceYouSubmitno);

    JLabel lblYouCantChange = new JLabel("there's no chance to change your answers.");
    lblYouCantChange.setHorizontalAlignment(SwingConstants.CENTER);
    lblYouCantChange.setFont(new Font("SimSun", Font.BOLD, 22));
    lblYouCantChange.setBounds(0, 183, 532, 59);
    Submit.add(lblYouCantChange);

    JButton btnSubmit = new JButton("Submit");
    btnSubmit.setFont(new Font("SimSun", Font.PLAIN, 24));
    btnSubmit.setBounds(222, 291, 124, 42);
    btnSubmit.addActionListener(new Submit());
    Submit.add(btnSubmit);

    Score = new JPanel();
    content.add(Score, "Score");
    Score.setLayout(null);

    JLabel lblNewLabel = new JLabel("Your final score is :");
    lblNewLabel.setFont(new Font("SimSun", Font.BOLD, 30));
    lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
    lblNewLabel.setBounds(14, 106, 357, 69);
    Score.add(lblNewLabel);

    lblNewLabel_1 = new JLabel(" ");
    lblNewLabel_1.setFont(new Font("SimSun", Font.BOLD, 30));
    lblNewLabel_1.setBounds(392, 106, 103, 69);

    Score.add(lblNewLabel_1);

    label = new JLabel(" ");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(new Font("SimSun", Font.PLAIN, 24));
    label.setText(" ");
    label.setBounds(164, 4, 83, 33);
    desktopPane.add(label);

    instructor = new JPanel();
    contentPane.add(instructor, "instructor");
    instructor.setLayout(null);

    JDesktopPane desktopPane_1 = new JDesktopPane();
    desktopPane_1.setBounds(0, 0, 681, 417);
    instructor.add(desktopPane_1);
    desktopPane_1.setBackground(Color.WHITE);

    teacher = new JPanel();
    teacher.setBounds(0, 80, 681, 337);
    desktopPane_1.add(teacher);
    teacher.setLayout(new CardLayout(0, 0));

    Index = new JPanel();
    teacher.add(Index, "Index");
    Index.setLayout(null);

    lblNewLabel_2 = new JLabel("If you want to add a question,please click add button.");
    lblNewLabel_2.setFont(new Font("SimSun", Font.PLAIN, 21));
    lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
    lblNewLabel_2.setBounds(0, 23, 681, 83);
    Index.add(lblNewLabel_2);

    lblIfYouWant = new JLabel("If you want to select a question,please click select button.");
    lblIfYouWant.setHorizontalAlignment(SwingConstants.CENTER);
    lblIfYouWant.setFont(new Font("SimSun", Font.PLAIN, 21));
    lblIfYouWant.setBounds(0, 102, 681, 83);
    Index.add(lblIfYouWant);

    Add = new JPanel();
    teacher.add(Add, "Add");
    Add.setLayout(null);

    qField = new JTextField();
    qField.setBounds(186, 13, 481, 178);
    Add.add(qField);
    qField.setColumns(10);

    lblQuestion = new JLabel("Question:");
    lblQuestion.setFont(new Font("SimSun", Font.PLAIN, 25));
    lblQuestion.setHorizontalAlignment(SwingConstants.CENTER);
    lblQuestion.setBounds(14, 13, 158, 51);
    Add.add(lblQuestion);

    aField = new JTextField();
    aField.setBounds(186, 207, 197, 72);
    Add.add(aField);
    aField.setColumns(10);

    lblAnswer = new JLabel("Answer:");
    lblAnswer.setHorizontalAlignment(SwingConstants.CENTER);
    lblAnswer.setFont(new Font("SimSun", Font.PLAIN, 25));
    lblAnswer.setBounds(14, 207, 158, 51);
    Add.add(lblAnswer);

    Insert = new JButton("Insert");
    Insert.setBounds(484, 223, 143, 40);
    Insert.addActionListener(new QuestionAction());
    Add.add(Insert);

    Select = new JPanel();
    teacher.add(Select, "Select");
    Select.setLayout(null);

    label_4 = new JLabel("UCID:");
    label_4.setHorizontalAlignment(SwingConstants.CENTER);
    label_4.setFont(new Font("SimSun", Font.PLAIN, 24));
    label_4.setBounds(0, 0, 153, 40);
    desktopPane_1.add(label_4);

    label_5 = new JLabel(" ");
    label_5.setHorizontalAlignment(SwingConstants.CENTER);
    label_5.setFont(new Font("SimSun", Font.PLAIN, 24));
    label_5.setText(" ");
    label_5.setBounds(167, 0, 100, 40);
    desktopPane_1.add(label_5);

    addquestion = new JButton("Add question");
    addquestion.setBounds(342, 4, 143, 40);
    addquestion.addActionListener(new Add());
    desktopPane_1.add(addquestion);

    selquestion = new JButton("Select question");
    selquestion.setBounds(499, 4, 168, 40);
    selquestion.addActionListener(new Select());
    desktopPane_1.add(selquestion);
  }
示例#30
0
  // constructor
  public TicTacToe() {
    super("tic-tac-toe");
    JPanel all = new JPanel(new BorderLayout());
    JPanel main = new JPanel(new GridLayout(3, 3));
    JPanel top = new JPanel();
    JPanel bottom = new JPanel();

    // make choice 1 player as default
    choice1 = new JRadioButton("1P", true);
    top.add(choice1);
    choice2 = new JRadioButton("2P", false);
    top.add(choice2);

    // grouping radio button
    choiceGroup = new ButtonGroup();
    choiceGroup.add(choice1);
    choiceGroup.add(choice2);

    // create handler for choice radio button
    ChoiceRBHandler choiceHandler = new ChoiceRBHandler();
    choice1.addItemListener(choiceHandler);
    choice2.addItemListener(choiceHandler);

    // reset handler for reset button
    ResetButtonHandler resetHandler = new ResetButtonHandler();
    resetButton.addActionListener(resetHandler);
    top.add(resetButton);

    // create handler for main button
    MainButtonHandler mainHandler = new MainButtonHandler();

    button1.addActionListener(mainHandler);
    main.add(button1);
    button2.addActionListener(mainHandler);
    main.add(button2);
    button3.addActionListener(mainHandler);
    main.add(button3);
    button4.addActionListener(mainHandler);
    main.add(button4);
    button5.addActionListener(mainHandler);
    main.add(button5);
    button6.addActionListener(mainHandler);
    main.add(button6);
    button7.addActionListener(mainHandler);
    main.add(button7);
    button8.addActionListener(mainHandler);
    main.add(button8);
    button9.addActionListener(mainHandler);
    main.add(button9);

    // create initial and add navigate text
    fontPlay = new Font("Serif", Font.PLAIN, 20);
    fontDone = new Font("Serif", Font.BOLD, 20);
    navigateText = new JLabel("   YOU VS AI   ");
    navigateText.setFont(fontPlay);
    bottom.add(navigateText);

    all.add(top, BorderLayout.NORTH);
    all.add(main, BorderLayout.CENTER);
    all.add(bottom, BorderLayout.SOUTH);
    getContentPane().add(all);
    pack();
  }