/** Initialisiert die Komponenten. */
  private void initComponents() {

    setBorder(border);

    phone.setMinimumSize(new Dimension(120, 20));
    phone.setPreferredSize(new Dimension(120, 20));

    fax.setMinimumSize(new Dimension(120, 20));
    fax.setPreferredSize(new Dimension(120, 20));

    email.setMinimumSize(new Dimension(120, 20));
    email.setPreferredSize(new Dimension(120, 20));
  }
 private JTextField createColorField(boolean hex) {
   final NumberDocument doc = new NumberDocument(hex);
   int lafFix = UIUtil.isUnderWindowsLookAndFeel() || UIUtil.isUnderDarcula() ? 1 : 0;
   UIManager.LookAndFeelInfo info = LafManager.getInstance().getCurrentLookAndFeel();
   if (info != null
       && (info.getName().startsWith("IDEA") || info.getName().equals("Windows Classic")))
     lafFix = 1;
   final JTextField field;
   if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
     field = new JTextField("");
     field.setDocument(doc);
     field.setPreferredSize(new Dimension(hex ? 60 : 40, 26));
   } else {
     field = new JTextField(doc, "", (hex ? 5 : 2) + lafFix);
     field.setSize(50, -1);
   }
   doc.setSource(field);
   field.getDocument().addDocumentListener(this);
   field.addFocusListener(
       new FocusAdapter() {
         @Override
         public void focusGained(final FocusEvent e) {
           field.selectAll();
         }
       });
   return field;
 }
  /**
   * Creates a new NewStringPopupDialog object.
   *
   * @param parent DOCUMENT ME!
   * @param title DOCUMENT ME!
   */
  public NewStringPopupDialog(Frame parent, String title) {
    super(parent, true);
    setTitle(title);
    textField = new JTextField();
    textField.setPreferredSize(new Dimension(200, 25));
    theString = null;

    JButton okButton = new JButton("OK");
    JButton cancelButton = new JButton("Cancel");
    okButton.addActionListener(new OkAction());
    cancelButton.addActionListener(new CancelAction());

    JPanel panel = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    panel.setLayout(gridbag);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    gridbag.setConstraints(textField, c);
    panel.add(textField);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    gridbag.setConstraints(okButton, c);
    panel.add(okButton);
    c.gridx = 1;
    c.gridy = 1;
    gridbag.setConstraints(cancelButton, c);
    panel.add(cancelButton);
    setContentPane(panel);
    pack();
    setLocationRelativeTo(parent);
    setVisible(true);
  }
  /**
   * Sets the panel in which the GUI should be implemented Any standard swing components can be used
   *
   * @param panel The GUI panel
   */
  public void setPanel(JPanel panel) {
    this.panel = panel;

    panel.setLayout(new BorderLayout());

    JLabel label =
        new JLabel("Produces an effect similar to thermal erosion", (int) JLabel.CENTER_ALIGNMENT);
    panel.add(label, BorderLayout.PAGE_START);

    JPanel iterations = new JPanel();
    iterations.setLayout(new FlowLayout());

    label = new JLabel("Iterations ");
    iterations.add(label);
    sldIterations = new JSlider(1, 100, 1);
    sldIterations.addChangeListener(this);
    iterations.add(sldIterations);
    txtIterations = new JTextField(Integer.toString((int) sldIterations.getValue()));
    txtIterations.setEditable(false);
    txtIterations.setPreferredSize(new Dimension(35, 25));
    iterations.add(txtIterations);

    panel.add(iterations, BorderLayout.CENTER);

    btnApply = new JButton("Apply Thermal Erosion");
    btnApply.addActionListener(this);
    panel.add(btnApply, BorderLayout.PAGE_END);

    if (preview) parent.refreshMiniView(apply(preview));
  }
  /** Affichage en mode GUI. */
  public void drawGUI() {
    panel.removeAll();
    // panel.updateUI();

    JLabel label = new JLabel("Choix pseudo joueurs");
    label.setFont(new Font("Serif", Font.BOLD, 22));
    panel.add(label);

    JLabel j1 = new JLabel("Joueur 1");
    j1.setFont(new Font("Serif", Font.PLAIN, 16));
    panel.add(j1);

    pseudoJ1 = new JTextField();
    pseudoJ1.setFont(new Font("Serif", Font.PLAIN, 16));
    pseudoJ1.setPreferredSize(new Dimension(150, 30));
    pseudoJ1.setForeground(Color.BLACK);

    panel.add(pseudoJ1);

    // Si on ne joue pas contre une IA, on demande au joueur 2 son pseudo aussi
    if (this.jeu.getTypeJeu() != Jeu.TYPE_JOUEUR_VS_IA) {
      JLabel j2 = new JLabel("Joueur 2");
      j2.setFont(new Font("Serif", Font.PLAIN, 16));
      panel.add(j2);

      pseudoJ2 = new JTextField();
      pseudoJ2.setFont(new Font("Serif", Font.PLAIN, 16));
      pseudoJ2.setPreferredSize(new Dimension(150, 30));
      pseudoJ2.setForeground(Color.BLACK);

      panel.add(pseudoJ2);
    }

    boutonOK = new JButton("Ok");
    boutonOK.addActionListener(this);
    panel.add(boutonOK);

    window.setContentPane(panel);
    window.pack();
    window.setVisible(true);
  }
  private void initialize() {
    setSize(300, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new FlowLayout(FlowLayout.LEFT));

    //
    // Create a combo box with four items and set it to editable so that user can
    // enter their own value.
    //
    final JComboBox comboBox = new JComboBox(new String[] {"One", "Two", "Three", "Four"});
    comboBox.setEditable(true);
    getContentPane().add(comboBox);

    //
    // Create two button that will set the selected item of the combo box. The
    // first button select "Two" and and second button select "Four".
    //
    JButton button1 = new JButton("Set Two");
    getContentPane().add(button1);
    button1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            comboBox.setSelectedItem("Two");
          }
        });

    JButton button2 = new JButton("Set Four");
    getContentPane().add(button2);
    button2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            comboBox.setSelectedItem("Four");
          }
        });

    //
    // Create a text field for displaying the selected item when we press the
    // Get Value button. When user enter their own value the selected item
    // returned is the string that entered by user.
    //
    final JTextField textField = new JTextField("");
    textField.setPreferredSize(new Dimension(150, 20));

    JButton button3 = new JButton("Get Value");
    getContentPane().add(button3);
    getContentPane().add(textField);
    button3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            textField.setText((String) comboBox.getSelectedItem());
          }
        });
  }
Beispiel #7
0
  public GalaxyViewer(Settings settings, boolean animatorFrame) throws Exception {
    super("Stars GalaxyViewer");
    this.settings = settings;
    this.animatorFrame = animatorFrame;
    if (settings.gameName.equals("")) throw new Exception("GameName not defined in settings.");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    File dir = new File(settings.directory);
    File map = new File(dir, settings.getGameName() + ".MAP");
    if (map.exists() == false) {
      File f = new File(dir.getParentFile(), settings.getGameName() + ".MAP");
      if (f.exists()) map = f;
      else {
        String error = "Could not find " + map.getAbsolutePath() + "\n";
        error += "Export this file from Stars! (Only needs to be done one time pr game)";
        throw new Exception(error);
      }
    }
    Vector<File> mFiles = new Vector<File>();
    Vector<File> hFiles = new Vector<File>();
    for (File f : dir.listFiles()) {
      if (f.getName().toUpperCase().endsWith("MAP")) continue;
      if (f.getName().toUpperCase().endsWith("HST")) continue;
      if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".M")) mFiles.addElement(f);
      else if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".H"))
        hFiles.addElement(f);
    }
    if (mFiles.size() == 0) throw new Exception("No M-files found matching game name.");
    if (hFiles.size() == 0) throw new Exception("No H-files found matching game name.");
    parseMapFile(map);
    Vector<File> files = new Vector<File>();
    files.addAll(mFiles);
    files.addAll(hFiles);
    p = new Parser(files);
    calculateColors();

    // UI:
    JPanel cp = (JPanel) getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(universe, BorderLayout.CENTER);
    JPanel south = createPanel(0, hw, new JLabel("Search: "), search, names, zoom, colorize);
    search.setPreferredSize(new Dimension(100, -1));
    cp.add(south, BorderLayout.SOUTH);
    hw.addActionListener(this);
    names.addActionListener(this);
    zoom.addChangeListener(this);
    search.addKeyListener(this);
    colorize.addActionListener(this);
    setSize(800, 600);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2);
    setVisible(animatorFrame == false);
    if (animatorFrame) names.setSelected(false);
  }
  public StringFieldPanel(
      Field field, Object defaultVal, String displayName, Integer order, Boolean editable) {
    super(field, displayName, order, editable);

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 1;
    textField = new JTextField();
    if (defaultVal != null) {
      textField.setText(defaultVal.toString());
    }
    textField.setEnabled(editable);
    textField.setPreferredSize(new Dimension(200, 20));
    add(textField, c);
  }
Beispiel #9
0
 protected JTextField getValueTextField() {
   if (valueTextField == null) {
     valueTextField = new JTextField();
     valueTextField.setPreferredSize(new Dimension(150, 18));
     if (isRequestFocus()) {
       SwingUtilities.invokeLater(
           new Runnable() {
             public void run() {
               valueTextField.requestFocus();
             }
           });
     }
   }
   return valueTextField;
 }
Beispiel #10
0
  private void initComponents() {

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

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

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

    tfUsername.addKeyListener(btEnabler); // A figyelő hozzáadása a felhasználónév mezőhőz
    pfPassword.addKeyListener(btEnabler); // A figyelő hozzáadása a jelszó mezőhőz
  }
Beispiel #11
0
  // constructor of TextFrame
  public TextFrame() {
    // this.message = message;
    message = "Click to Edit Text";
    messageFont = new Font("Arial", Font.PLAIN, 30);
    foreground = Color.black;
    background = Color.white;

    // custom dialog (it's a private class inside TextFrame)
    cd = new CustomDialog(this);

    messageField = new JTextField();
    messageField.setPreferredSize(new Dimension(300, 200));
    messageField.setEditable(false);
    messageField.setHorizontalAlignment(SwingConstants.CENTER);
    messageField.setAlignmentX(Component.CENTER_ALIGNMENT);
    updateMessage();

    customize = new JButton("Customize");
    customize.setMaximumSize(customize.getPreferredSize());
    customize.setAlignmentX(Component.CENTER_ALIGNMENT);

    apply = new JButton("Apply");
    apply.setMaximumSize(customize.getPreferredSize());
    apply.setAlignmentX(Component.CENTER_ALIGNMENT);

    /*add the listeners*/
    customize.addActionListener(this);
    apply.addActionListener(this);
    messageField.addMouseListener(new PopUpClass());

    // customize
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(customize);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(messageField);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(apply);
    p.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));

    // make panel this JFrame's content pane

    this.setContentPane(p);
  }
Beispiel #12
0
  public WalletSumPanel(BigInteger balance) {

    this.setBackground(Color.WHITE);
    double width = this.getSize().getWidth();
    this.setPreferredSize(new Dimension(500, 50));
    Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
    Border empty = new EmptyBorder(5, 8, 5, 8);
    CompoundBorder border = new CompoundBorder(line, empty);

    JLabel addressField = new JLabel();
    addressField.setPreferredSize(new Dimension(300, 35));
    this.add(addressField);

    JTextField amount = new JTextField();
    amount.setBorder(border);
    amount.setEnabled(true);
    amount.setEditable(false);
    amount.setText(Utils.getValueShortString(balance));

    amount.setPreferredSize(new Dimension(100, 35));
    amount.setForeground(new Color(143, 170, 220));
    amount.setHorizontalAlignment(SwingConstants.RIGHT);
    amount.setFont(new Font("Monospaced", 0, 13));
    amount.setBackground(Color.WHITE);
    this.add(amount);

    URL payoutIconURL = ClassLoader.getSystemResource("buttons/wallet-pay.png");
    ImageIcon payOutIcon = new ImageIcon(payoutIconURL);
    JLabel payOutLabel = new JLabel(payOutIcon);
    payOutLabel.setToolTipText("Payout for all address list");
    payOutLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    payOutLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            JOptionPane.showMessageDialog(null, "Under construction");
          }
        });

    this.add(payOutLabel);
  }
Beispiel #13
0
 public MemoryMonitor() {
   setLayout(new BorderLayout());
   setBorder(new TitledBorder(new EtchedBorder(), "Memory Monitor"));
   add(surf = new Surface());
   controls = new JPanel();
   controls.setPreferredSize(new Dimension(135, 80));
   Font font = new Font("serif", Font.PLAIN, 10);
   JLabel label = new JLabel("Sample Rate");
   label.setFont(font);
   label.setForeground(BLACK);
   controls.add(label);
   tf = new JTextField("1000");
   tf.setPreferredSize(new Dimension(45, 20));
   controls.add(tf);
   controls.add(label = new JLabel("ms"));
   label.setFont(font);
   label.setForeground(BLACK);
   controls.add(dateStampCB);
   dateStampCB.setFont(font);
   addMouseListener(
       new MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           removeAll();
           if ((doControls = !doControls)) {
             surf.stop();
             add(controls);
           } else {
             try {
               surf.sleepAmount = Long.parseLong(tf.getText().trim());
             } catch (Exception ex) {
             }
             surf.start();
             add(surf);
           }
           revalidate();
           repaint();
         }
       });
 }
  public AddAdapterSupportDialog(
      @NotNull Project project,
      @NotNull PsiFile psiFileRequestor,
      @NotNull String assertionFrameworkName,
      @NotNull List<VirtualFile> adapterSourceFiles,
      @Nullable String adapterHomePageUrl) {
    super(project);
    myProject = project;
    myAssertFrameworkName = assertionFrameworkName;
    myAdapterSourceFiles = adapterSourceFiles;
    myFileRequestor = psiFileRequestor.getVirtualFile();

    setModal(true);
    setTitle("Add " + getAssertFrameworkAdapterName());

    myDirectoryTextField = new JTextField();
    VirtualFile initialDir = findInitialDir(psiFileRequestor);
    if (initialDir != null) {
      myDirectoryTextField.setText(FileUtil.toSystemDependentName(initialDir.getPath()));
    }
    // widen preferred size to fit dialog's title
    myDirectoryTextField.setPreferredSize(
        new Dimension(350, myDirectoryTextField.getPreferredSize().height));

    List<Component> components = Lists.newArrayList();
    components.add(createFilesViewPanel(adapterSourceFiles));
    components.add(Box.createVerticalStrut(10));
    components.add(createSelectDirectoryPanel(project, myDirectoryTextField));
    if (adapterHomePageUrl != null) {
      components.add(Box.createVerticalStrut(10));
      components.add(createInformationPanel(adapterHomePageUrl));
    }
    myContent = SwingHelper.newLeftAlignedVerticalPanel(components);

    setOKButtonText("Add");
    super.init();
  }
Beispiel #15
0
 void jbInit() throws Exception {
   border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5);
   panel1.setLayout(borderLayout1);
   jPanel1.setLayout(borderLayout2);
   jScrollPane1.getViewport().setBackground(Color.white);
   jPanel2.setLayout(gridBagLayout1);
   jLabel1.setText("Profile Name : ");
   nameTextField.setMinimumSize(new Dimension(4, 18));
   nameTextField.setPreferredSize(new Dimension(63, 18));
   jLabel2.setText("Profile Type : ");
   openButton.setMaximumSize(new Dimension(73, 24));
   openButton.setMinimumSize(new Dimension(73, 24));
   openButton.setPreferredSize(new Dimension(73, 24));
   openButton.setText("Open");
   openButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           openButton_actionPerformed(e);
         }
       });
   cancelButton.setMaximumSize(new Dimension(73, 24));
   cancelButton.setMinimumSize(new Dimension(73, 24));
   cancelButton.setPreferredSize(new Dimension(73, 24));
   cancelButton.setMargin(new Insets(0, 5, 0, 5));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           cancelButton_actionPerformed(e);
         }
       });
   profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   profileList.addMouseListener(
       new java.awt.event.MouseAdapter() {
         public void mouseClicked(MouseEvent e) {
           profileList_mouseClicked(e);
         }
       });
   jPanel2.setBorder(border1);
   typeComboBox.setMaximumSize(new Dimension(32767, 18));
   typeComboBox.setMinimumSize(new Dimension(122, 18));
   typeComboBox.setPreferredSize(new Dimension(176, 18));
   getContentPane().add(panel1);
   panel1.add(jPanel1, BorderLayout.CENTER);
   jPanel1.add(jScrollPane1, BorderLayout.CENTER);
   panel1.add(jPanel2, BorderLayout.SOUTH);
   jPanel2.add(
       jLabel1,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 7, 0),
           0,
           0));
   jPanel2.add(
       nameTextField,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 7, 0),
           0,
           0));
   jPanel2.add(
       jLabel2,
       new GridBagConstraints(
           0,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 0, 17, 0),
           0,
           0));
   jScrollPane1.getViewport().add(profileList, null);
   jPanel2.add(
       openButton,
       new GridBagConstraints(
           3,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 2, 10),
           0,
           0));
   jPanel2.add(
       cancelButton,
       new GridBagConstraints(
           3,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 11, 9, 10),
           0,
           0));
   jPanel2.add(
       typeComboBox,
       new GridBagConstraints(
           1,
           1,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.HORIZONTAL,
           new Insets(0, 11, 17, 0),
           0,
           0));
 }
  public ParametricFunctionLabel(Function function) {
    super(function);

    // GUI representation
    GridBagLayout gbl_fLabel = new GridBagLayout();
    gbl_fLabel.columnWidths = new int[] {0, 0, 150, 30, 0, 0};
    gbl_fLabel.rowHeights = new int[] {5, 0, 0, 0, 0, 0, 0};
    gbl_fLabel.columnWeights = new double[] {0.0, 0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_fLabel.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    this.setLayout(gbl_fLabel);

    lblX = new JLabel("x =");
    GridBagConstraints gbc_lblX = new GridBagConstraints();
    gbc_lblX.insets = new Insets(0, 0, 5, 5);
    gbc_lblX.anchor = GridBagConstraints.EAST;
    gbc_lblX.gridx = 1;
    gbc_lblX.gridy = 1;
    add(lblX, gbc_lblX);

    exprFieldX = new JTextField(function.getExpression()[0]);
    GridBagConstraints gbc_list = new GridBagConstraints();
    gbc_list.insets = new Insets(0, 0, 5, 5);
    gbc_list.fill = GridBagConstraints.HORIZONTAL;
    gbc_list.gridx = 2;
    gbc_list.gridy = 1;
    this.add(exprFieldX, gbc_list);

    toggleButton =
        new ToggleButton(
            new ImageIcon("Icons/selected.png"), new ImageIcon("Icons/notSelected.png"));
    GridBagConstraints gbc_chckbxTest = new GridBagConstraints();
    gbc_chckbxTest.gridheight = 2;
    gbc_chckbxTest.insets = new Insets(0, 0, 5, 5);
    gbc_chckbxTest.gridx = 3;
    gbc_chckbxTest.gridy = 1;
    this.add(toggleButton, gbc_chckbxTest);

    lblY = new JLabel("y =");
    GridBagConstraints gbc_lblY = new GridBagConstraints();
    gbc_lblY.gridheight = 2;
    gbc_lblY.insets = new Insets(0, 0, 5, 5);
    gbc_lblY.anchor = GridBagConstraints.EAST;
    gbc_lblY.gridx = 1;
    gbc_lblY.gridy = 2;
    add(lblY, gbc_lblY);

    exprFieldY = new JTextField(function.getExpression()[1]);
    GridBagConstraints gbc_textField = new GridBagConstraints();
    gbc_textField.gridheight = 2;
    gbc_textField.insets = new Insets(0, 0, 5, 5);
    gbc_textField.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField.gridx = 2;
    gbc_textField.gridy = 2;
    add(exprFieldY, gbc_textField);
    exprFieldY.setColumns(10);

    lblZ = new JLabel("z =");
    GridBagConstraints gbc_lblZ = new GridBagConstraints();
    gbc_lblZ.insets = new Insets(0, 0, 5, 5);
    gbc_lblZ.anchor = GridBagConstraints.EAST;
    gbc_lblZ.gridx = 1;
    gbc_lblZ.gridy = 4;
    add(lblZ, gbc_lblZ);

    exprFieldZ = new JTextField(function.getExpression()[2]);
    GridBagConstraints gbc_textField_1 = new GridBagConstraints();
    gbc_textField_1.insets = new Insets(0, 0, 5, 5);
    gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_1.gridx = 2;
    gbc_textField_1.gridy = 4;
    add(exprFieldZ, gbc_textField_1);
    exprFieldZ.setColumns(10);

    // Don't f**k up layout, when text string becomes too long.
    exprFieldX.setPreferredSize(new Dimension(100, 20));
    exprFieldY.setPreferredSize(new Dimension(100, 20));
    exprFieldZ.setPreferredSize(new Dimension(100, 20));

    btnDelete = new JButton(new ImageIcon("Icons/delete.png"));
    GridBagConstraints gbc_btnDelete = new GridBagConstraints();
    gbc_btnDelete.gridheight = 2;
    gbc_btnDelete.insets = new Insets(0, 0, 5, 5);
    gbc_btnDelete.gridx = 3;
    gbc_btnDelete.gridy = 3;
    add(btnDelete, gbc_btnDelete);

    // Add listeners;
    addTextChangeListener();
    addToggleButtonListener();
    addDeleteListener();

    this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

    GuiUtil.setupUndoListener(exprFieldX);
    GuiUtil.setupUndoListener(exprFieldY);
    GuiUtil.setupUndoListener(exprFieldZ);
  }
  private void makeUi() {
    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    JPanel loginPane = createPane();
    loginPane.setLayout(new BoxLayout(loginPane, BoxLayout.Y_AXIS));
    add(loginPane);
    JLabel label = new JLabel("Login");
    loginPane.add(label);
    login = new JTextField();
    login.setAlignmentX(LEFT_ALIGNMENT);
    login.setPreferredSize(new Dimension(225, 25));
    loginPane.add(login);

    JPanel passwordPane = createPane();
    passwordPane.setLayout(new BoxLayout(passwordPane, BoxLayout.Y_AXIS));
    add(passwordPane);
    passwordPane.add(new JLabel("Password"));
    password = new JTextField();
    password.setAlignmentX(LEFT_ALIGNMENT);
    ;
    password.setPreferredSize(new Dimension(225, 25));
    passwordPane.add(password);

    JPanel dirPane = createPane();
    add(dirPane);
    dirPane.add(new JLabel("Directory"));
    JPanel dirSelectPane = new JPanel();
    dirSelectPane.setAlignmentX(LEFT_ALIGNMENT);
    dirPane.add(dirSelectPane);
    dirSelectPane.setLayout(new BoxLayout(dirSelectPane, BoxLayout.X_AXIS));
    directory = new JTextField();
    dirSelectPane.add(directory);
    JButton dirSelBtn = new JButton("...");
    dirSelectPane.add(dirSelBtn);

    final JDialog self = this;
    dirSelBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog(self);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              directory.setText(chooser.getSelectedFile().getAbsolutePath());
            }
          }
        });

    JPanel buttonsPane = new JPanel();
    buttonsPane.setLayout(new BoxLayout(buttonsPane, BoxLayout.X_AXIS));
    buttonsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    buttonsPane.setAlignmentX(LEFT_ALIGNMENT);
    buttonsPane.add(Box.createHorizontalGlue());

    JButton okBtn = new JButton("OK");
    okBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            isOk = true;
            setVisible(false);
          }
        });
    buttonsPane.add(okBtn);

    JButton cancelBtn = new JButton("Cancel");
    cancelBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            isOk = false;
            setVisible(false);
          }
        });
    buttonsPane.add(cancelBtn);
    add(buttonsPane);
  }
Beispiel #18
0
  /**
   * This method represents the window in which the preferred parameters for the obix components can
   * be chosen.
   *
   * @param chosenComponents The list of {@link ObixObject} which have been chosen in the previous
   *     window.
   * @return The container in which the preferred parameters for the obix components can be chosen.
   */
  private Container chooseParameters(List<ObixObject> chosenComponents) {
    Container pane = new Container();
    pane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    pane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    Font titelF = new Font("Courier", Font.BOLD, 30);
    title = new JLabel("Please choose the appropriate Parameters for the datapoints");
    title.setFont(titelF);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 10;
    c.gridx = 0;
    c.gridy = 0;
    pane.add(title, c);

    List<String> parametersList = Configurator.getInstance().getAvailableParameterTypes();
    String[] parameterTypes = new String[parametersList.size()];
    parameterTypes = parametersList.toArray(parameterTypes);

    for (ObixObject o : chosenComponents) {
      c.gridy++;
      c.insets = new Insets(30, 10, 0, 0);

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

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

      JLabel parameter1Label = new JLabel("Parameter 1 Type:");
      c.gridy++;
      pane.add(parameter1Label, c);

      JLabel parameter1ObixUnitLabel = new JLabel("OBIX unit: " + o.getObixUnitUri());
      c.gridx++;
      pane.add(parameter1ObixUnitLabel, c);

      JComboBox parameter1comboBox = new JComboBox(parameterTypes);
      c.gridx++;
      pane.add(parameter1comboBox, c);

      JButton param1AddStateButton = new JButton("Add State");
      Box vBox1 = Box.createVerticalBox();
      vBox1.setBorder(BorderFactory.createLineBorder(Color.black));

      JLabel parameter1UnitLabel = new JLabel("Set Parameter 1 Unit:");
      c.gridx++;
      pane.add(parameter1UnitLabel, c);

      JTextField parameter1UnitTextField = new JTextField(o.getParameter1().getParameterUnit());
      parameter1UnitTextField.setPreferredSize(new Dimension(500, 20));
      parameter1UnitTextField.setMinimumSize(new Dimension(500, 20));
      c.gridx++;
      pane.add(parameter1UnitTextField, c);

      JLabel parameter1ValueTypeLabel =
          new JLabel("valueType: " + o.getParameter1().getValueType());
      c.gridx++;
      pane.add(parameter1ValueTypeLabel, c);

      int param1UnitLabelxPosition = c.gridx;
      int param1UnitLabelyPosition = c.gridy;

      for (StateDescription s : o.getParameter1().getStateDescriptions()) {
        JLabel stateNameLabel = new JLabel("State Name: ");
        JTextField stateNameTextfield = new JTextField(20);
        stateNameTextfield.setText(s.getName().getName());
        vBox1.add(stateNameLabel);
        vBox1.add(stateNameTextfield);

        JLabel stateValueLabel = new JLabel("State Value: ");
        JTextField stateValueTextfield = new JTextField(20);
        stateValueTextfield.setText(s.getValue().getValue());
        vBox1.add(stateValueLabel);
        vBox1.add(stateValueTextfield);

        JLabel stateURILabel = new JLabel("State URI: ");
        JTextField stateURITextfield = new JTextField(20);
        stateURITextfield.setText(s.getStateDescriptionUri());
        vBox1.add(stateURILabel);
        vBox1.add(stateURITextfield);

        JButton deleteStateButton = new JButton("Delete State");
        vBox1.add(deleteStateButton);

        JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
        vBox1.add(horizontalLine);
        vBox1.add(horizontalLine);

        StateRepresentation stateRepresentation =
            (new StateRepresentation(
                param1AddStateButton,
                deleteStateButton,
                stateNameLabel,
                stateNameTextfield,
                stateValueLabel,
                stateValueTextfield,
                stateURILabel,
                stateURITextfield,
                horizontalLine,
                vBox1,
                o.getParameter1()));

        addDeleteStateListener(stateRepresentation);
        listOfStateRepresentations.add(stateRepresentation);

        pane.revalidate();
        pane.repaint();
      }

      addParameterBoxListener(
          parameter1comboBox,
          param1UnitLabelxPosition,
          param1UnitLabelyPosition,
          parameter1UnitLabel,
          parameter1UnitTextField,
          pane,
          param1AddStateButton,
          vBox1);

      /** Add state to parameter 1 function listener */
      param1AddStateButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              JLabel stateNameLabel = new JLabel("State Name: ");
              JTextField stateNameTextfield = new JTextField(20);
              vBox1.add(stateNameLabel);
              vBox1.add(stateNameTextfield);
              JLabel stateValueLabel = new JLabel("State Value: ");

              JTextField stateValueTextfield = new JTextField(20);
              vBox1.add(stateValueLabel);
              vBox1.add(stateValueTextfield);

              JLabel stateURILabel = new JLabel("State URI: ");
              JTextField stateURITextfield = new JTextField(20);
              vBox1.add(stateURILabel);
              vBox1.add(stateURITextfield);

              JButton deleteStateButton = new JButton("Delete State");
              vBox1.add(deleteStateButton);

              JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
              vBox1.add(horizontalLine);
              vBox1.add(horizontalLine);

              StateRepresentation stateRepresentation =
                  (new StateRepresentation(
                      param1AddStateButton,
                      deleteStateButton,
                      stateNameLabel,
                      stateNameTextfield,
                      stateValueLabel,
                      stateValueTextfield,
                      stateURILabel,
                      stateURITextfield,
                      horizontalLine,
                      vBox1,
                      o.getParameter1()));

              addDeleteStateListener(stateRepresentation);
              listOfStateRepresentations.add(stateRepresentation);
              pane.revalidate();
              pane.repaint();
            }
          });

      c.gridy++;
      c.gridx = 0;
      JLabel parameter2Label = new JLabel("Parameter 2 Type:");
      pane.add(parameter2Label, c);

      JComboBox parameter2comboBox = new JComboBox(parameterTypes);
      c.gridx++;
      c.gridx++;
      pane.add(parameter2comboBox, c);

      JLabel parameter2UnitLabel = new JLabel("Set Parameter 2 Unit: ");
      c.gridx++;
      pane.add(parameter2UnitLabel, c);

      JTextField parameter2UnitTextField = new JTextField(o.getParameter2().getParameterUnit());
      parameter2UnitTextField.setPreferredSize(new Dimension(500, 20));
      parameter2UnitTextField.setMinimumSize(new Dimension(500, 20));
      c.gridx++;
      pane.add(parameter2UnitTextField, c);

      JLabel parameter2ValueTypeLabel =
          new JLabel("valueType: " + o.getParameter2().getValueType());
      c.gridx++;
      pane.add(parameter2ValueTypeLabel, c);

      JButton param2AddStateButton = new JButton("Add State");
      Box vBox2 = Box.createVerticalBox();
      vBox2.setBorder(BorderFactory.createLineBorder(Color.black));

      int param2UnitLabelxPosition = c.gridx;
      int param2UnitLabelyPosition = c.gridy;

      addParameterBoxListener(
          parameter2comboBox,
          param2UnitLabelxPosition,
          param2UnitLabelyPosition,
          parameter2UnitLabel,
          parameter2UnitTextField,
          pane,
          param2AddStateButton,
          vBox2);

      /** Add state to parameter 2 function listener */
      param2AddStateButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              JLabel stateNameLabel = new JLabel("State Name: ");
              JTextField stateNameTextfield = new JTextField(20);
              vBox2.add(stateNameLabel);
              vBox2.add(stateNameTextfield);
              JLabel stateValueLabel = new JLabel("State Value: ");

              JTextField stateValueTextfield = new JTextField(20);
              vBox2.add(stateValueLabel);
              vBox2.add(stateValueTextfield);

              JLabel stateURILabel = new JLabel("State URI: ");
              JTextField stateURITextfield = new JTextField(20);
              vBox2.add(stateURILabel);
              vBox2.add(stateURITextfield);

              JButton deleteStateButton = new JButton("Delete State");
              vBox2.add(deleteStateButton);

              JSeparator horizontalLine = new JSeparator(JSeparator.HORIZONTAL);
              vBox2.add(horizontalLine);
              vBox2.add(horizontalLine);

              StateRepresentation stateRepresentation =
                  (new StateRepresentation(
                      param2AddStateButton,
                      deleteStateButton,
                      stateNameLabel,
                      stateNameTextfield,
                      stateValueLabel,
                      stateValueTextfield,
                      stateURILabel,
                      stateURITextfield,
                      horizontalLine,
                      vBox2,
                      o.getParameter2()));

              addDeleteStateListener(stateRepresentation);
              listOfStateRepresentations.add(stateRepresentation);

              pane.revalidate();
              pane.repaint();
            }
          });

      parameter1comboBox.setSelectedItem(o.getParameter1().getParameterType());
      parameter2comboBox.setSelectedItem(o.getParameter2().getParameterType());

      representationRows.add(
          new RepresentationRow(
              o,
              parameter1comboBox,
              parameter2comboBox,
              parameter1UnitTextField,
              parameter2UnitTextField));
    }

    JButton acceptButton = new JButton("Accept");
    c.insets = new Insets(50, 0, 0, 0);
    c.gridwidth = 10;
    c.gridx = 0;
    c.gridy++;
    pane.add(acceptButton, c);

    /** Accept button listener */
    Action acceptAction =
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (StateRepresentation s : listOfStateRepresentations) {
              if (s.getStateNameTextField().getText().isEmpty()
                  || s.getStateUriTextField().getText().isEmpty()
                  || s.getStateValueTextField().getText().isEmpty()) {
                JOptionPane.showMessageDialog(
                    null,
                    "Each state parameter field must contain a text! "
                        + "There are some empty parameter fields, please change them before proceeding.");
                return;
              }
            }

            for (ObixObject o : chosenComponents) {
              o.getParameter1().getStateDescriptions().clear();
              o.getParameter2().getStateDescriptions().clear();
            }

            for (StateRepresentation s : listOfStateRepresentations) {
              // Save created State
              ArrayList<String> types = new ArrayList<String>();
              types.add("&colibri;AbsoluteState");
              types.add("&colibri;DiscreteState");

              Value val = new Value();
              val.setValue(s.getStateValueTextField().getText());
              val.setDatatype(s.getParameter().getValueType());

              Name name = new Name();
              name.setName(s.getStateNameTextField().getText());

              StateDescription state =
                  new StateDescription(s.getStateUriTextField().getText(), types, val, name);

              s.getParameter().addStateDescription(state);
            }
            List<ObixObject> chosenObjects = Collections.synchronizedList(new ArrayList<>());
            for (RepresentationRow r : GuiUtility.this.getRepresentationRows()) {
              r.getObixObject()
                  .getParameter1()
                  .setParameterType((String) r.getParam1TypeComboBox().getSelectedItem());
              r.getObixObject()
                  .getParameter2()
                  .setParameterType((String) r.getParam2TypeComboBox().getSelectedItem());
              chosenObjects.add(r.getObixObject());
              if (!r.getParam1UnitTextField().getText().isEmpty()) {
                r.getObixObject()
                    .getParameter1()
                    .setParameterUnit(r.getParam1UnitTextField().getText());
              }
              if (!r.getParam2UnitTextField().getText().isEmpty()) {
                r.getObixObject()
                    .getParameter2()
                    .setParameterUnit(r.getParam2UnitTextField().getText());
              }
            }
            representationRows.clear();
            cards.removeAll();
            JScrollPane scrollPane = new JScrollPane(interactionWindow(chosenObjects));
            scrollPane.getVerticalScrollBar().setUnitIncrement(16);
            scrollPane.setBorder(new EmptyBorder(20, 20, 20, 20));
            cards.add(scrollPane);
            // Display the window.
            mainFrame.pack();
          }
        };
    acceptButton.addActionListener(acceptAction);

    return pane;
  }
  private void jbInit() throws Exception {
    border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border2 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    border3 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder1 = new TitledBorder(border3, "Subject");
    border4 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder2 = new TitledBorder(border4, "Message");
    border5 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder3 = new TitledBorder(border5, "Subject");
    border6 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder4 = new TitledBorder(border6, "Message");
    border7 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder5 = new TitledBorder(border7, "Messages");
    border8 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(165, 163, 151));
    titledBorder6 = new TitledBorder(border8, "Online Users");
    border9 = new EtchedBorder(EtchedBorder.RAISED, Color.white, new Color(178, 178, 178));
    titledBorder7 = new TitledBorder(border9, "Send Message");
    this.getContentPane().setLayout(borderLayout1);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setBorder(border1);
    jSplitPane1.setLastDividerLocation(250);
    jSplitPane1.setResizeWeight(1.0);
    jLabelServer.setRequestFocusEnabled(true);
    jLabelServer.setText("Server");
    jLabelUserId.setText("User Id");
    jTextFieldServer.setPreferredSize(new Dimension(75, 20));
    jTextFieldServer.setText("");
    jTextFieldUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldUser.setText("");
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setJMenuBar(jMenuBarMain);
    this.setTitle("Message Client");
    jLabeltargetUser.setText("Target");
    jTextFieldTargetUser.setPreferredSize(new Dimension(75, 20));
    jTextFieldTargetUser.setText("");
    jPanelSendMessages.setBorder(border2);
    jPanelSendMessages.setMaximumSize(new Dimension(32767, 32767));
    jPanelSendMessages.setOpaque(false);
    jPanelSendMessages.setPreferredSize(new Dimension(96, 107));
    jPanelSendMessages.setRequestFocusEnabled(true);
    jPanelSendMessages.setToolTipText("");
    jPanelSendMessages.setLayout(verticalFlowLayout1);
    jTextFieldSendSubject.setBorder(titledBorder3);
    jTextFieldSendSubject.setText("");
    jTextFieldSendSubject.addKeyListener(new Client_jTextFieldSendSubject_keyAdapter(this));
    jSplitPane2.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
    jScrollPane1.setBorder(titledBorder5);
    jScrollPane2.setBorder(titledBorder6);
    jToggleButtonRegister.setText("Register");
    jToggleButtonRegister.addActionListener(new Client_jToggleButtonRegister_actionAdapter(this));
    jButtonMultiConnect.setText("Multi-Connect");
    jButtonMultiConnect.addActionListener(new Client_jButtonMultiConnect_actionAdapter(this));
    jListOnlineUsers.addMouseListener(new Client_jListOnlineUsers_mouseAdapter(this));
    jToggleButtonConnect.setText("Connect");
    jToggleButtonConnect.addActionListener(new Client_jToggleButtonConnect_actionAdapter(this));
    jTextPaneDisplayMessages.setEditable(false);
    jTextPaneDisplayMessages.addMouseListener(
        new Client_jTextPaneDisplayMessages_mouseAdapter(this));
    jTextFieldSendMessages.setBorder(titledBorder7);
    jTextFieldSendMessages.setToolTipText("");
    jTextFieldSendMessages.addKeyListener(new Client_jTextFieldSendMessages_keyAdapter(this));
    jButtonMessageStresser.setText("Msg Stresser");
    jButtonMessageStresser.addActionListener(
        new Client_jToggleButtonMessageStresser_actionAdapter(this));
    jMenuItemClearMessages.setText("Clear Messages");
    jMenuItemClearMessages.addActionListener(new Client_jMenuItemClearMessages_actionAdapter(this));
    jMenuServer.setText("Server");
    jMenuItemServerConnect.setText("Connect");
    jMenuItemServerConnect.addActionListener(new Client_jMenuItemServerConnect_actionAdapter(this));
    jMenuItemServerDisconnect.setText("Disconnect");
    jMenuItemServerDisconnect.addActionListener(
        new Client_jMenuItemServerDisconnect_actionAdapter(this));
    jMenuOptions.setText("Options");
    jMenuTest.setText("Test");
    jMenuItemOptionsRegister.setText("Register");
    jMenuItemOptionsRegister.addActionListener(
        new Client_jMenuItemOptionsRegister_actionAdapter(this));
    jMenuItemOptionsDeregister.setText("Deregister");
    jMenuItemOptionsDeregister.addActionListener(
        new Client_jMenuItemOptionsDeregister_actionAdapter(this));
    jMenuItemOptionsEavesdrop.setText("Eavesdrop");
    jMenuItemOptionsEavesdrop.addActionListener(
        new Client_jMenuItemOptionsEavesdrop_actionAdapter(this));
    jMenuItemOptionsUneavesdrop.setText("Uneavesdrop");
    jMenuItemOptionsUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsUneavesdrop_actionAdapter(this));
    jMenuItemTestMulticonnect.setText("Multiconnect");
    jMenuItemTestMulticonnect.addActionListener(
        new Client_jMenuItemTestMulticonnect_actionAdapter(this));
    jMenuItemTestMessageStresser.setText("Message Stresser");
    jMenuItemTestMessageStresser.addActionListener(
        new Client_jMenuItemTestMessageStresser_actionAdapter(this));
    jMenuItemTestMultidisconnect.setText("Multidisconnect");
    jMenuItemTestMultidisconnect.addActionListener(
        new Client_jMenuItemTestMultidisconnect_actionAdapter(this));
    jMenuItemOptionsGlobalEavesdrop.setText("Global Eavesdrop");
    jMenuItemOptionsGlobalEavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalEavesdrop_actionAdapter(this));
    jMenuItemOptionsGlobalUneavesdrop.setEnabled(false);
    jMenuItemOptionsGlobalUneavesdrop.setText("Global Uneavesdrop");
    jMenuItemOptionsGlobalUneavesdrop.addActionListener(
        new Client_jMenuItemOptionsGlobalUneavesdrop_actionAdapter(this));
    jLabelPwd.setText("Pwd");
    jPasswordFieldPwd.setMinimumSize(new Dimension(11, 20));
    jPasswordFieldPwd.setPreferredSize(new Dimension(75, 20));
    jPasswordFieldPwd.setText("");
    jMenuItemScheduleCommand.setText("Schedule Command");
    jMenuItemScheduleCommand.addActionListener(
        new Client_jMenuItemScheduleCommand_actionAdapter(this));
    jMenuItemEditScheduledCommands.setText("Edit Scheduled Commands");
    jMenuItemEditScheduledCommands.addActionListener(
        new Client_jMenuItemEditScheduledCommands_actionAdapter(this));
    jPanelSendMessages.add(jTextFieldSendSubject, null);
    jPanelSendMessages.add(jTextFieldSendMessages, null);
    jSplitPane1.add(jSplitPane2, JSplitPane.TOP);
    jSplitPane2.add(jScrollPane1, JSplitPane.TOP);
    jScrollPane1.getViewport().add(jTextPaneDisplayMessages, null);
    jSplitPane2.add(jScrollPane2, JSplitPane.BOTTOM);
    jScrollPane2.getViewport().add(jListOnlineUsers, null);
    this.getContentPane().add(jSplitPane1, BorderLayout.CENTER);
    jSplitPane1.add(jPanelSendMessages, JSplitPane.BOTTOM);
    this.getContentPane().add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(jLabelServer, null);
    jPanel1.add(jTextFieldServer, null);
    jPanel1.add(jLabelUserId, null);
    jPanel1.add(jTextFieldUser, null);
    jPanel1.add(jLabelPwd, null);
    jPanel1.add(jPasswordFieldPwd, null);
    jPanel1.add(jLabeltargetUser, null);
    jPanel1.add(jTextFieldTargetUser, null);
    jPanel1.add(jToggleButtonConnect, null);
    jPanel1.add(jToggleButtonRegister, null);
    jPanel1.add(jButtonMultiConnect, null);
    jPanel1.add(jButtonMessageStresser, null);
    jPopupMenuMessageArea.add(jMenuItemClearMessages);
    jMenuBarMain.add(jMenuServer);
    jMenuBarMain.add(jMenuOptions);
    jMenuBarMain.add(jMenuTest);
    jMenuServer.add(jMenuItemServerConnect);
    jMenuServer.add(jMenuItemServerDisconnect);
    jMenuOptions.add(jMenuItemOptionsRegister);
    jMenuOptions.add(jMenuItemOptionsDeregister);
    jMenuOptions.add(jMenuItemOptionsEavesdrop);
    jMenuOptions.add(jMenuItemOptionsUneavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalEavesdrop);
    jMenuOptions.add(jMenuItemOptionsGlobalUneavesdrop);
    jMenuTest.add(jMenuItemTestMulticonnect);
    jMenuTest.add(jMenuItemTestMultidisconnect);
    jMenuTest.add(jMenuItemTestMessageStresser);
    jMenuTest.add(jMenuItemScheduleCommand);
    jMenuTest.add(jMenuItemEditScheduledCommands);
    jSplitPane1.setDividerLocation(200);
    jSplitPane2.setDividerLocation(600);
    jListOnlineUsers.setCellRenderer(new OnlineListCellRenderer());
    jListOnlineUsers.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    jMenuItemTestMulticonnect.setEnabled(true);
    jMenuItemTestMultidisconnect.setEnabled(false);
    jMenuItemServerConnect.setEnabled(true);
    jMenuItemServerDisconnect.setEnabled(false);
    jMenuItemOptionsRegister.setEnabled(true);
    jMenuItemOptionsDeregister.setEnabled(false);
  }
  /** Creates panel with function logo and some utilities */
  private Container createTopPanel() {
    JPanel topContainer = new JPanel(new BorderLayout());

    Box logoContainer = Box.createHorizontalBox();
    logoContainer.add(new JLabel(logo));

    topContainer.add(logoContainer, BorderLayout.WEST);

    Box toolBox = Box.createHorizontalBox();

    toolBox.add(new JLabel(toolboxIcon));

    final JLabel highlightGroups = new JLabel(highlightOffIcon);
    highlightGroups.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            highlightGroups.setIcon(isHighlighted ? highlightOnOver : highlightOffOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            highlightGroups.setIcon(isHighlighted ? highlightOnIcon : highlightOffIcon);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            if (isHighlighted) {

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getLockedTable(), null);
              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getScrollTable(), null);
            } else {

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getLockedTable(),
                  new CustomRowRenderer(
                      transposedSpreadsheetModel.getRowToColour(), UIHelper.VER_11_BOLD));

              transposedSpreadsheetSubform.changeTableRenderer(
                  transposedSpreadsheetSubform.getScrollTable(),
                  new CustomRowRenderer(
                      transposedSpreadsheetModel.getRowToColour(), UIHelper.VER_11_PLAIN));
            }

            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    transposedSpreadsheetSubform.validate();
                    transposedSpreadsheetSubform.repaint();
                    highlightGroups.setIcon(isHighlighted ? highlightOnIcon : highlightOffIcon);
                  }
                });
            isHighlighted = !isHighlighted;
          }
        });

    toolBox.add(highlightGroups);

    final JLabel goToRecordButton = new JLabel(goToRecord);
    goToRecordButton.addMouseListener(
        new MouseAdapter() {
          public void mouseEntered(MouseEvent mouseEvent) {
            goToRecordButton.setIcon(goToRecordOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            goToRecordButton.setIcon(goToRecord);
          }
        });

    toolBox.add(goToRecordButton);

    Box goToRecordEntryField = Box.createVerticalBox();

    final JTextField field = new JTextField("row #");
    UIHelper.renderComponent(field, UIHelper.VER_10_PLAIN, UIHelper.LIGHT_GREY_COLOR, false);

    Dimension fieldSize = new Dimension(60, 16);
    field.setPreferredSize(fieldSize);
    field.setSize(fieldSize);

    goToRecordEntryField.add(Box.createVerticalStrut(5));
    goToRecordEntryField.add(field);
    goToRecordEntryField.add(Box.createVerticalStrut(5));

    final JLabel goButton = new JLabel(go);
    goButton.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            goButton.setIcon(goOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            goButton.setIcon(go);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            goToColumn(field);
          }
        });

    Action locateColumn =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            goToColumn(field);
          }
        };

    field.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "LOCATE_COLUMN");
    field.getActionMap().put("LOCATE_COLUMN", locateColumn);

    toolBox.add(goToRecordEntryField);
    toolBox.add(goButton);
    goToRecordEntryField.add(Box.createVerticalStrut(5));

    topContainer.add(toolBox, BorderLayout.EAST);

    information = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.LIGHT_GREY_COLOR);
    information.setHorizontalAlignment(SwingConstants.RIGHT);

    topContainer.add(UIHelper.wrapComponentInPanel(information), BorderLayout.SOUTH);

    return topContainer;
  }
Beispiel #21
0
 private JTextField getTextField() {
   JTextField textField = new JTextField();
   textField.setPreferredSize(new Dimension(350, 20));
   return textField;
 }
Beispiel #22
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame("SkAppA");
    frame.setBounds(100, 100, 750, 400);
    frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    /*  */
    ImageIcon imIcon = new ImageIcon(this.getClass().getClassLoader().getResource("res/logo.png"));
    // ImageIcon imIcon = new ImageIcon("C:\\Users\\davem\\workspace\\Skappa\\res\\logo.png");
    Image image = imIcon.getImage();
    Image newImage = image.getScaledInstance(120, 120, Image.SCALE_SMOOTH);
    imIcon = new ImageIcon(newImage);
    frame.getContentPane().setLayout(new CardLayout(0, 0));

    panelIniziale = new JPanel();
    frame.getContentPane().add(panelIniziale, "name_10245570710976");
    panelIniziale.setLayout(new BorderLayout(0, 0));

    JPanel panel = new JPanel();
    panelIniziale.add(panel, BorderLayout.SOUTH);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JPanel panelInviaMail = new JPanel();
    frame.getContentPane().add(panelInviaMail, "name_74765522122111");
    frame.setBounds(100, 100, 750, 400);
    panelInviaMail.setLayout(new BorderLayout(0, 0));

    JPanel panel_6 = new JPanel();
    panelInviaMail.add(panel_6, BorderLayout.CENTER);
    GridBagLayout gbl_panel_6 = new GridBagLayout();
    gbl_panel_6.columnWidths = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    gbl_panel_6.rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    gbl_panel_6.columnWeights =
        new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_panel_6.rowWeights =
        new double[] {
          0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE
        };
    panel_6.setLayout(gbl_panel_6);

    JLabel lblIndirizzoEmail = new JLabel("Indirizzo email");
    GridBagConstraints gbc_lblIndirizzoEmail = new GridBagConstraints();
    gbc_lblIndirizzoEmail.insets = new Insets(0, 0, 5, 5);
    gbc_lblIndirizzoEmail.gridx = 3;
    gbc_lblIndirizzoEmail.gridy = 1;
    panel_6.add(lblIndirizzoEmail, gbc_lblIndirizzoEmail);

    textFieldEmail = new JTextField();
    GridBagConstraints gbc_textFieldEmail = new GridBagConstraints();
    gbc_textFieldEmail.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldEmail.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldEmail.gridx = 5;
    gbc_textFieldEmail.gridy = 1;
    panel_6.add(textFieldEmail, gbc_textFieldEmail);
    textFieldEmail.setColumns(10);

    JLabel lblUsername = new JLabel("Username");
    GridBagConstraints gbc_lblUsername = new GridBagConstraints();
    gbc_lblUsername.insets = new Insets(0, 0, 5, 5);
    gbc_lblUsername.gridx = 3;
    gbc_lblUsername.gridy = 3;
    panel_6.add(lblUsername, gbc_lblUsername);

    textFieldUsername = new JTextField();
    GridBagConstraints gbc_textFieldUsername = new GridBagConstraints();
    gbc_textFieldUsername.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldUsername.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldUsername.gridx = 5;
    gbc_textFieldUsername.gridy = 3;
    panel_6.add(textFieldUsername, gbc_textFieldUsername);
    textFieldUsername.setColumns(10);

    JLabel lblPassword = new JLabel("Password");
    GridBagConstraints gbc_lblPassword = new GridBagConstraints();
    gbc_lblPassword.insets = new Insets(0, 0, 5, 5);
    gbc_lblPassword.gridx = 3;
    gbc_lblPassword.gridy = 5;
    panel_6.add(lblPassword, gbc_lblPassword);

    passwordField = new JPasswordField();
    GridBagConstraints gbc_passwordField = new GridBagConstraints();
    gbc_passwordField.insets = new Insets(0, 0, 5, 5);
    gbc_passwordField.fill = GridBagConstraints.HORIZONTAL;
    gbc_passwordField.gridx = 5;
    gbc_passwordField.gridy = 5;
    panel_6.add(passwordField, gbc_passwordField);

    JLabel lblIndirizzoServerSmtp = new JLabel("Indirizzo server smtp");
    GridBagConstraints gbc_lblIndirizzoServerSmtp = new GridBagConstraints();
    gbc_lblIndirizzoServerSmtp.insets = new Insets(0, 0, 5, 5);
    gbc_lblIndirizzoServerSmtp.gridx = 3;
    gbc_lblIndirizzoServerSmtp.gridy = 7;
    panel_6.add(lblIndirizzoServerSmtp, gbc_lblIndirizzoServerSmtp);

    textFieldSMTP = new JTextField();
    GridBagConstraints gbc_textFieldSMTP = new GridBagConstraints();
    gbc_textFieldSMTP.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldSMTP.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldSMTP.gridx = 5;
    gbc_textFieldSMTP.gridy = 7;
    panel_6.add(textFieldSMTP, gbc_textFieldSMTP);
    textFieldSMTP.setColumns(10);

    JLabel lblPortaServerSmtp = new JLabel("Porta server smtp");
    GridBagConstraints gbc_lblPortaServerSmtp = new GridBagConstraints();
    gbc_lblPortaServerSmtp.insets = new Insets(0, 0, 5, 5);
    gbc_lblPortaServerSmtp.gridx = 3;
    gbc_lblPortaServerSmtp.gridy = 9;
    panel_6.add(lblPortaServerSmtp, gbc_lblPortaServerSmtp);

    textFieldSMTPPort = new JTextField();
    GridBagConstraints gbc_textFieldSMTPPort = new GridBagConstraints();
    gbc_textFieldSMTPPort.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldSMTPPort.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldSMTPPort.gridx = 5;
    gbc_textFieldSMTPPort.gridy = 9;
    panel_6.add(textFieldSMTPPort, gbc_textFieldSMTPPort);
    textFieldSMTPPort.setColumns(10);

    progressBar = new JProgressBar();
    GridBagConstraints gbc_progressBar = new GridBagConstraints();
    gbc_progressBar.fill = GridBagConstraints.HORIZONTAL;
    gbc_progressBar.insets = new Insets(0, 0, 5, 5);
    gbc_progressBar.gridx = 5;
    gbc_progressBar.gridy = 11;
    panel_6.add(progressBar, gbc_progressBar);
    progressBar.setVisible(false);

    JPanel panel_7 = new JPanel();
    panelInviaMail.add(panel_7, BorderLayout.NORTH);

    JLabel lblInserisciCredenziali = new JLabel("Inserisci credenziali");
    lblInserisciCredenziali.setFont(new Font("Tahoma", Font.PLAIN, 18));
    panel_7.add(lblInserisciCredenziali);

    JPanel panel_8 = new JPanel();
    panelInviaMail.add(panel_8, BorderLayout.SOUTH);

    btnNewButton_5 = new JButton("Invia");
    btnNewButton_5.setPreferredSize(new Dimension(70, 25));
    btnNewButton_5.addActionListener(this);

    panel_8.add(btnNewButton_5);

    JButton btnNewButton_6 = new JButton("Annulla");
    btnNewButton_6.setPreferredSize(new Dimension(70, 25));
    btnNewButton_6.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            panelInviaMail.setVisible(false);
            panelCreaEvento.setVisible(true);
            frame.setBounds(100, 100, 750, 400);
          }
        });
    panel_8.add(btnNewButton_6);

    JButton btnNewButton = new JButton("Crea evento");
    btnNewButton.setPreferredSize(new Dimension(150, 30));
    btnNewButton.setMinimumSize(new Dimension(150, 30));
    btnNewButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            panelCreaEvento.setVisible(true);
            panelIniziale.setVisible(false);
            // frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
            frame.setBounds(100, 100, 750, 400);
          }
        });
    panel.add(btnNewButton);

    JButton btnNewButton_1 = new JButton("Carica partecipanti");
    btnNewButton_1.setPreferredSize(new Dimension(150, 30));
    btnNewButton_1.setMinimumSize(new Dimension(150, 30));
    btnNewButton_1.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            panelCaricaPartecipanti.setVisible(true);
            panelIniziale.setVisible(false);
          }
        });
    panel.add(btnNewButton_1);

    JPanel panel_1 = new JPanel();
    panelIniziale.add(panel_1, BorderLayout.CENTER);
    SimpleAttributeSet attribs = new SimpleAttributeSet();
    StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_CENTER);
    JTextPane txtpnSelezionaLaModalit = new JTextPane();
    txtpnSelezionaLaModalit.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    txtpnSelezionaLaModalit.setEnabled(false);
    txtpnSelezionaLaModalit.setEditable(false);
    txtpnSelezionaLaModalit.setFont(new Font("Tahoma", Font.PLAIN, 16));
    txtpnSelezionaLaModalit.setText("Seleziona la modalit\u00E0");
    txtpnSelezionaLaModalit.setParagraphAttributes(attribs, true);
    panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.X_AXIS));
    panel_1.add(txtpnSelezionaLaModalit);

    JPanel panel_2 = new JPanel();
    panelIniziale.add(panel_2, BorderLayout.NORTH);

    JLabel lblLogo = new JLabel("");
    lblLogo.setIcon(imIcon);
    panel_2.add(lblLogo);

    panelCreaEvento = new JPanel();
    frame.getContentPane().add(panelCreaEvento, "name_10426205657299");

    JPanel panel_5 = new JPanel();

    JPanel panel_3 = new JPanel();
    panelCreaEvento.setLayout(new BorderLayout(0, 0));
    panelCreaEvento.add(panel_5);
    GridBagLayout gbl_panel_5 = new GridBagLayout();
    gbl_panel_5.columnWidths =
        new int[] {64, 66, 67, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 81, 48, 43, 55, 0};
    gbl_panel_5.rowHeights = new int[] {0, 0, 30, 20, 35, 20, 35, 20, 0, 0};
    gbl_panel_5.columnWeights =
        new double[] {
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          1.0,
          0.0,
          1.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          0.0,
          Double.MIN_VALUE
        };
    gbl_panel_5.rowWeights =
        new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    panel_5.setLayout(gbl_panel_5);

    Component verticalStrut_1 = Box.createVerticalStrut(20);
    GridBagConstraints gbc_verticalStrut_1 = new GridBagConstraints();
    gbc_verticalStrut_1.insets = new Insets(0, 0, 5, 5);
    gbc_verticalStrut_1.gridx = 13;
    gbc_verticalStrut_1.gridy = 0;
    panel_5.add(verticalStrut_1, gbc_verticalStrut_1);

    Component verticalStrut_2 = Box.createVerticalStrut(20);
    GridBagConstraints gbc_verticalStrut_2 = new GridBagConstraints();
    gbc_verticalStrut_2.insets = new Insets(0, 0, 5, 5);
    gbc_verticalStrut_2.gridx = 13;
    gbc_verticalStrut_2.gridy = 1;
    panel_5.add(verticalStrut_2, gbc_verticalStrut_2);

    JLabel lblInserisciDatiEvento = new JLabel("Inserisci dati evento");
    lblInserisciDatiEvento.setFont(new Font("Tahoma", Font.PLAIN, 18));
    GridBagConstraints gbc_lblInserisciDatiEvento = new GridBagConstraints();
    gbc_lblInserisciDatiEvento.gridwidth = 2;
    gbc_lblInserisciDatiEvento.insets = new Insets(0, 0, 5, 5);
    gbc_lblInserisciDatiEvento.gridx = 1;
    gbc_lblInserisciDatiEvento.gridy = 2;
    panel_5.add(lblInserisciDatiEvento, gbc_lblInserisciDatiEvento);

    JLabel lblNomeEvento = new JLabel("Nome evento");
    lblNomeEvento.setFont(new Font("Tahoma", Font.PLAIN, 13));
    GridBagConstraints gbc_lblNomeEvento = new GridBagConstraints();
    gbc_lblNomeEvento.gridwidth = 2;
    gbc_lblNomeEvento.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblNomeEvento.insets = new Insets(0, 0, 5, 5);
    gbc_lblNomeEvento.gridx = 1;
    gbc_lblNomeEvento.gridy = 3;
    panel_5.add(lblNomeEvento, gbc_lblNomeEvento);

    textFieldNome = new JTextField();
    textFieldNome.setColumns(10);
    GridBagConstraints gbc_textFieldNome = new GridBagConstraints();
    gbc_textFieldNome.anchor = GridBagConstraints.NORTH;
    gbc_textFieldNome.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldNome.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldNome.gridwidth = 5;
    gbc_textFieldNome.gridx = 3;
    gbc_textFieldNome.gridy = 3;
    panel_5.add(textFieldNome, gbc_textFieldNome);

    JLabel lblLuogoEvento = new JLabel("Luogo evento");
    lblLuogoEvento.setFont(new Font("Tahoma", Font.PLAIN, 13));
    GridBagConstraints gbc_lblLuogoEvento = new GridBagConstraints();
    gbc_lblLuogoEvento.gridwidth = 2;
    gbc_lblLuogoEvento.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblLuogoEvento.insets = new Insets(0, 0, 5, 5);
    gbc_lblLuogoEvento.gridx = 1;
    gbc_lblLuogoEvento.gridy = 5;
    panel_5.add(lblLuogoEvento, gbc_lblLuogoEvento);

    textFieldLuogo = new JTextField();
    textFieldLuogo.setColumns(10);
    GridBagConstraints gbc_textFieldLuogo = new GridBagConstraints();
    gbc_textFieldLuogo.anchor = GridBagConstraints.NORTH;
    gbc_textFieldLuogo.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldLuogo.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldLuogo.gridwidth = 5;
    gbc_textFieldLuogo.gridx = 3;
    gbc_textFieldLuogo.gridy = 5;
    panel_5.add(textFieldLuogo, gbc_textFieldLuogo);

    JLabel lblProvincia = new JLabel("Provincia");
    GridBagConstraints gbc_lblProvincia = new GridBagConstraints();
    gbc_lblProvincia.anchor = GridBagConstraints.WEST;
    gbc_lblProvincia.insets = new Insets(0, 0, 5, 5);
    gbc_lblProvincia.gridx = 9;
    gbc_lblProvincia.gridy = 5;
    panel_5.add(lblProvincia, gbc_lblProvincia);

    JComboBox comboBoxProvincia = new JComboBox(provinceArray);
    GridBagConstraints gbc_comboBoxProvincia = new GridBagConstraints();
    gbc_comboBoxProvincia.anchor = GridBagConstraints.NORTHWEST;
    gbc_comboBoxProvincia.insets = new Insets(0, 0, 5, 5);
    gbc_comboBoxProvincia.gridx = 10;
    gbc_comboBoxProvincia.gridy = 5;
    panel_5.add(comboBoxProvincia, gbc_comboBoxProvincia);

    JLabel lblDataEvento = new JLabel("Data evento");
    lblDataEvento.setFont(new Font("Tahoma", Font.PLAIN, 13));
    GridBagConstraints gbc_lblDataEvento = new GridBagConstraints();
    gbc_lblDataEvento.gridwidth = 2;
    gbc_lblDataEvento.fill = GridBagConstraints.HORIZONTAL;
    gbc_lblDataEvento.insets = new Insets(0, 0, 0, 5);
    gbc_lblDataEvento.gridx = 1;
    gbc_lblDataEvento.gridy = 7;
    panel_5.add(lblDataEvento, gbc_lblDataEvento);

    JComboBox comboBoxGiorno = new JComboBox(giorniArray);
    GridBagConstraints gbc_comboBoxGiorno = new GridBagConstraints();
    gbc_comboBoxGiorno.anchor = GridBagConstraints.NORTHWEST;
    gbc_comboBoxGiorno.insets = new Insets(0, 0, 0, 5);
    gbc_comboBoxGiorno.gridx = 3;
    gbc_comboBoxGiorno.gridy = 7;
    panel_5.add(comboBoxGiorno, gbc_comboBoxGiorno);

    JComboBox comboBoxMese = new JComboBox(mesiArray);
    GridBagConstraints gbc_comboBoxMese = new GridBagConstraints();
    gbc_comboBoxMese.anchor = GridBagConstraints.NORTHWEST;
    gbc_comboBoxMese.insets = new Insets(0, 0, 0, 5);
    gbc_comboBoxMese.gridx = 4;
    gbc_comboBoxMese.gridy = 7;
    panel_5.add(comboBoxMese, gbc_comboBoxMese);

    JComboBox comboBoxAnno = new JComboBox(anniArray);
    GridBagConstraints gbc_comboBoxAnno = new GridBagConstraints();
    gbc_comboBoxAnno.insets = new Insets(0, 0, 0, 5);
    gbc_comboBoxAnno.anchor = GridBagConstraints.NORTHEAST;
    gbc_comboBoxAnno.gridx = 5;
    gbc_comboBoxAnno.gridy = 7;
    panel_5.add(comboBoxAnno, gbc_comboBoxAnno);

    JLabel lblOra = new JLabel("Ora");
    GridBagConstraints gbc_lblOra = new GridBagConstraints();
    gbc_lblOra.anchor = GridBagConstraints.EAST;
    gbc_lblOra.insets = new Insets(0, 0, 0, 5);
    gbc_lblOra.gridx = 8;
    gbc_lblOra.gridy = 7;
    panel_5.add(lblOra, gbc_lblOra);

    JComboBox comboBoxOre = new JComboBox(oreArray);
    GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
    gbc_comboBox_1.insets = new Insets(0, 0, 0, 5);
    gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_1.gridx = 10;
    gbc_comboBox_1.gridy = 7;
    panel_5.add(comboBoxOre, gbc_comboBox_1);

    JComboBox comboBoxMinuti = new JComboBox(minutiArray);
    GridBagConstraints gbc_comboBox_2 = new GridBagConstraints();
    gbc_comboBox_2.insets = new Insets(0, 0, 0, 5);
    gbc_comboBox_2.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_2.gridx = 12;
    gbc_comboBox_2.gridy = 7;
    panel_5.add(comboBoxMinuti, gbc_comboBox_2);
    panelCreaEvento.add(panel_3, BorderLayout.NORTH);
    GridBagLayout gbl_panel_3 = new GridBagLayout();
    gbl_panel_3.columnWidths = new int[] {0, 0, 0, 200, 0, 227, 77, 0, 0, 0};
    gbl_panel_3.rowHeights = new int[] {0, 0, 23, 0};
    gbl_panel_3.columnWeights =
        new double[] {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_panel_3.rowWeights = new double[] {0.0, 0.0, 0.0, Double.MIN_VALUE};
    panel_3.setLayout(gbl_panel_3);

    Component verticalStrut = Box.createVerticalStrut(20);
    GridBagConstraints gbc_verticalStrut = new GridBagConstraints();
    gbc_verticalStrut.insets = new Insets(0, 0, 5, 5);
    gbc_verticalStrut.gridx = 6;
    gbc_verticalStrut.gridy = 0;
    panel_3.add(verticalStrut, gbc_verticalStrut);

    JLabel lblInserisciPercorsoFile = new JLabel("Inserisci percorso file nominativi");
    GridBagConstraints gbc_lblInserisciPercorsoFile = new GridBagConstraints();
    gbc_lblInserisciPercorsoFile.insets = new Insets(0, 0, 5, 5);
    gbc_lblInserisciPercorsoFile.gridx = 3;
    gbc_lblInserisciPercorsoFile.gridy = 1;
    panel_3.add(lblInserisciPercorsoFile, gbc_lblInserisciPercorsoFile);

    textField = new JTextField();
    textField.setPreferredSize(new Dimension(6, 25));
    textField.setColumns(10);
    GridBagConstraints gbc_textField = new GridBagConstraints();
    gbc_textField.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField.insets = new Insets(0, 0, 5, 5);
    gbc_textField.gridx = 5;
    gbc_textField.gridy = 1;
    panel_3.add(textField, gbc_textField);

    JButton btnNewButton_2 = new JButton("Apri...");
    btnNewButton_2.setPreferredSize(new Dimension(135, 25));
    btnNewButton_2.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            chooser.setCurrentDirectory(new java.io.File("."));
            chooser.setDialogTitle("Choose the folder");
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            chooser.setAcceptAllFileFilterUsed(false);
            if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
              System.out.println("getCurrentDirectory(): " + chooser.getSelectedFile());
              file = chooser.getSelectedFile();
              inputFilePath = file.getAbsolutePath();
              textField.setText(inputFilePath);
            }
          }
        });
    GridBagConstraints gbc_btnNewButton_2 = new GridBagConstraints();
    gbc_btnNewButton_2.insets = new Insets(0, 0, 5, 5);
    gbc_btnNewButton_2.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnNewButton_2.gridx = 6;
    gbc_btnNewButton_2.gridy = 1;
    panel_3.add(btnNewButton_2, gbc_btnNewButton_2);

    Component horizontalStrut = Box.createHorizontalStrut(20);
    GridBagConstraints gbc_horizontalStrut = new GridBagConstraints();
    gbc_horizontalStrut.insets = new Insets(0, 0, 0, 5);
    gbc_horizontalStrut.gridx = 2;
    gbc_horizontalStrut.gridy = 2;
    panel_3.add(horizontalStrut, gbc_horizontalStrut);

    Component horizontalStrut_1 = Box.createHorizontalStrut(20);
    GridBagConstraints gbc_horizontalStrut_1 = new GridBagConstraints();
    gbc_horizontalStrut_1.insets = new Insets(0, 0, 0, 5);
    gbc_horizontalStrut_1.gridx = 7;
    gbc_horizontalStrut_1.gridy = 2;
    panel_3.add(horizontalStrut_1, gbc_horizontalStrut_1);

    JPanel panel_4 = new JPanel();
    panelCreaEvento.add(panel_4, BorderLayout.SOUTH);

    JButton btnNewButton_3 = new JButton("Crea evento");
    btnNewButton_3.setPreferredSize(new Dimension(95, 25));
    btnNewButton_3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            int giorno = Integer.parseInt((String) comboBoxGiorno.getSelectedItem());
            int mese = comboBoxMese.getSelectedIndex();
            int anno = Integer.parseInt((String) comboBoxAnno.getSelectedItem());
            int ore = Integer.parseInt((String) comboBoxOre.getSelectedItem());
            int minuti = Integer.parseInt((String) comboBoxMinuti.getSelectedItem());
            inputFilePath = textField.getText();
            file = new File(inputFilePath);

            if (!isValidDate(giorno, mese, anno)) {
              JOptionPane.showMessageDialog(
                  frame, "Data non corretta.", "Errore", JOptionPane.ERROR_MESSAGE);
            } else if (!extensionIs("xlsx", file)) {
              JOptionPane.showMessageDialog(
                  frame, "Formato file non corretto.", "Errore", JOptionPane.ERROR_MESSAGE);
            } else {
              inputFilePath = textField.getText();
              /*try {
                  l = Loader.generateList(inputFilePath);
              } catch (Exception e) {
                  JOptionPane.showMessageDialog(frame, "Errore nel file di input.", "Errore", JOptionPane.ERROR_MESSAGE);
              }*/

              evento =
                  new Event(
                      textFieldNome.getText(),
                      textFieldLuogo.getText(),
                      (String) comboBoxProvincia.getSelectedItem(),
                      new GregorianCalendar(anno, mese, giorno, ore, minuti),
                      l);
              frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              try {
                evento.generateList(inputFilePath);
              } catch (Exception e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(
                    frame, "Errore nel file di output.", "Errore", JOptionPane.ERROR_MESSAGE);
              }

              evento.toString();
              File dir = new File(inputFilePath);
              evento.assignQR(dir.getParent());

              frame.setCursor(null);

              frame.setBounds(100, 100, 750, 400);
              panelCreaEvento.setVisible(false);
              panelInviaMail.setVisible(true);
            }
          }
        });
    panel_4.add(btnNewButton_3);

    JButton btnNewButton_4 = new JButton("Indietro");
    btnNewButton_4.setPreferredSize(new Dimension(95, 25));
    btnNewButton_4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            panelCreaEvento.setVisible(false);
            panelIniziale.setVisible(true);
          }
        });
    panel_4.add(btnNewButton_4);

    panelCaricaPartecipanti = new JPanel();
    frame.getContentPane().add(panelCaricaPartecipanti, "name_80084471932092");
    panelCaricaPartecipanti.setLayout(new BorderLayout(0, 0));

    JPanel panel_9 = new JPanel();
    panelCaricaPartecipanti.add(panel_9);
    GridBagLayout gbl_panel_9 = new GridBagLayout();
    gbl_panel_9.columnWidths = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
    gbl_panel_9.rowHeights = new int[] {0, 0, 0, 0, 0, 0};
    gbl_panel_9.columnWeights = new double[] {0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_panel_9.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    panel_9.setLayout(gbl_panel_9);

    JLabel lblInserisciFileExcel = new JLabel("Inserisci file Excel di output");
    GridBagConstraints gbc_lblInserisciFileExcel = new GridBagConstraints();
    gbc_lblInserisciFileExcel.insets = new Insets(0, 0, 5, 5);
    gbc_lblInserisciFileExcel.gridx = 2;
    gbc_lblInserisciFileExcel.gridy = 2;
    panel_9.add(lblInserisciFileExcel, gbc_lblInserisciFileExcel);

    textField_1 = new JTextField();
    GridBagConstraints gbc_textField_1 = new GridBagConstraints();
    gbc_textField_1.insets = new Insets(0, 0, 5, 5);
    gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_1.gridx = 3;
    gbc_textField_1.gridy = 2;
    panel_9.add(textField_1, gbc_textField_1);
    textField_1.setColumns(10);

    JButton btnNewButton_7 = new JButton("Scegli file...");
    btnNewButton_7.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            chooser.setCurrentDirectory(new java.io.File("."));
            chooser.setDialogTitle("Choose the folder");
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            chooser.setAcceptAllFileFilterUsed(false);
            if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
              System.out.println("getCurrentDirectory(): " + chooser.getSelectedFile());
              file = chooser.getSelectedFile();
              excelOutputFilePath = file.getAbsolutePath();
              textField_1.setText(excelOutputFilePath);
            }
          }
        });
    GridBagConstraints gbc_btnNewButton_7 = new GridBagConstraints();
    gbc_btnNewButton_7.insets = new Insets(0, 0, 5, 5);
    gbc_btnNewButton_7.gridx = 5;
    gbc_btnNewButton_7.gridy = 2;
    panel_9.add(btnNewButton_7, gbc_btnNewButton_7);

    JLabel lblInserisciFileDelle = new JLabel("Inserisci file delle scansioni");
    GridBagConstraints gbc_lblInserisciFileDelle = new GridBagConstraints();
    gbc_lblInserisciFileDelle.insets = new Insets(0, 0, 0, 5);
    gbc_lblInserisciFileDelle.gridx = 2;
    gbc_lblInserisciFileDelle.gridy = 4;
    panel_9.add(lblInserisciFileDelle, gbc_lblInserisciFileDelle);

    textField_2 = new JTextField();
    GridBagConstraints gbc_textField_2 = new GridBagConstraints();
    gbc_textField_2.insets = new Insets(0, 0, 0, 5);
    gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_2.gridx = 3;
    gbc_textField_2.gridy = 4;
    panel_9.add(textField_2, gbc_textField_2);
    textField_2.setColumns(10);

    JButton btnNewButton_8 = new JButton("Scegli file...");
    btnNewButton_8.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            chooser.setCurrentDirectory(new java.io.File("."));
            chooser.setDialogTitle("Choose the folder");
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            chooser.setAcceptAllFileFilterUsed(false);
            if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
              System.out.println("getCurrentDirectory(): " + chooser.getSelectedFile());
              file = chooser.getSelectedFile();
              txtOutputFilePath = file.getAbsolutePath();
              textField_2.setText(txtOutputFilePath);
            }
          }
        });
    GridBagConstraints gbc_btnNewButton_8 = new GridBagConstraints();
    gbc_btnNewButton_8.insets = new Insets(0, 0, 0, 5);
    gbc_btnNewButton_8.gridx = 5;
    gbc_btnNewButton_8.gridy = 4;
    panel_9.add(btnNewButton_8, gbc_btnNewButton_8);

    JPanel panel_10 = new JPanel();
    panelCaricaPartecipanti.add(panel_10, BorderLayout.NORTH);

    JPanel panel_11 = new JPanel();
    panelCaricaPartecipanti.add(panel_11, BorderLayout.SOUTH);

    JButton btnNewButton_9 = new JButton("Associa");
    btnNewButton_9.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            txtOutputFilePath = textField_2.getText();
            File f = new File(txtOutputFilePath);
            excelOutputFilePath = textField_1.getText();
            Loader.writeInOut(excelOutputFilePath, Loader.loadParticipants(f));
            JOptionPane.showMessageDialog(
                frame, "Associazione degli orari eseguita!", "", JOptionPane.PLAIN_MESSAGE);
          }
        });
    panel_11.add(btnNewButton_9);

    JButton btnNewButton_10 = new JButton("Annulla");
    panel_11.add(btnNewButton_10);
  }
  /** Instantiates a new game panel. */
  public GamePanel() {
    super();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    doubleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            if (!Game.doubleDown()) {
              hitButton.setEnabled(true);
              standButton.setEnabled(true);
              doubleButton.setEnabled(false);
            }
          }
        });
  }
Beispiel #24
0
  FlashPlayer() {
    BrComponent.DESIGN_MODE = false;
    BrComponent.setDefaultPaintAlgorithm(BrComponent.PAINT_NATIVE);

    setTitle("Flash Player");

    JPanel rootPanel = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    rootPanel.setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;

    final BrComponent player = new BrComponent();
    player.setBounds(0, 0, 500, 363);
    player.setPreferredSize(new Dimension(425, 363));
    final String stGame = "http://flashportal.ru/monstertruckcurfew.swfi";
    final String stMovie =
        "<html><body border=\"no\" scroll=\"no\" style=\"margin: 0px 0px 0px 0px;\">"
            + "<object style=\"margin: 0px 0px 0px 0px; width:100%; height:100%\""
            + "        value=\"http://www.youtube.com/v/mlTKOsBOVMw&hl=en\">"
            + "<param name=\"wmode\" value=\"transparent\"> "
            + "<embed style=\"margin: 0px 0px 0px 0px; width:100%; height:100%\" src=\"http://www.youtube.com/v/mlTKOsBOVMw&hl=en\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></embed>"
            + "</object>"
            + "</body></html>";
    player.setHTML((InputStream) new StringBufferInputStream(stMovie), "");

    c.gridwidth = GridBagConstraints.REMAINDER; // end row REMAINDER
    gridbag.setConstraints(player, c);
    rootPanel.add(player);

    final JTextField help = new JTextField("Please, use \u2190,\u2191,\u2192,\u2193 keys!");
    help.setPreferredSize(new Dimension(220, 10));
    help.setBounds(50, 10, 220, 16);
    player.add(help, BorderLayout.LINE_END);

    // c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row
    c.weightx = 0.0; // reset to the default
    c.weighty = 0.0;

    //
    {
      JPanel p2 = new JPanel();
      gridbag.setConstraints(p2, c);
      rootPanel.add(p2);

      JButton edSampleGame = new JButton("Sample Game (SWF)");
      edSampleGame.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              player.setHTML(getFlashHTMLSource(stGame), stGame);
              help.setText("Please, use \u2190,\u2191,\u2192,\u2193 keys!");
            }
          });
      p2.add(edSampleGame, BorderLayout.LINE_START);

      JButton edSampleMovie = new JButton("Sample Movie (FLV)");
      edSampleMovie.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              player.setHTML((InputStream) new StringBufferInputStream(stMovie), "");
              help.setText("Enjoy!");
            }
          });
      p2.add(edSampleMovie, BorderLayout.LINE_START);

      JButton edSave = new JButton("Open flash file...");
      edSave.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              JFileChooser fc = new JFileChooser();
              FileNameExtensionFilter filter = new FileNameExtensionFilter("Flash Files", "swf");
              fc.setFileFilter(filter);
              if (JFileChooser.APPROVE_OPTION == fc.showDialog(FlashPlayer.this, "Play")) {
                String stGame = fc.getSelectedFile().getAbsolutePath();
                player.setHTML(getFlashHTMLSource(stGame), stGame);
                help.setText("Enjoy!");
              }
            }
          });
      p2.add(edSave, BorderLayout.LINE_END);
    }

    add(rootPanel);
    pack();
    setVisible(true);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
Beispiel #25
0
  public JChat() {
    this.setSize(500, 600);
    this.setResizable(false);
    this.setLayout(new BorderLayout());

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridLayout(2, 1));

    // set up buttons
    openChat = new JButton("Open to chat");
    openChat.addActionListener(new OpenChat());
    chatWith = new JButton("Chat with");
    chatWith.addActionListener(new ChatWith());
    send = new JButton("send");
    send.addActionListener(new Send());
    send.setEnabled(false);
    InputMap inputMap = send.getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    inputMap.put(enter, "ENTER");
    send.getActionMap().put("ENTER", new ClickAction(send));

    // set up labels
    pickPort = new JLabel();
    pickPort.setText("Pick your port number:");
    desPort = new JLabel();
    desPort.setText("Or enter a destinaltion port number:");

    // set up text fields
    pickText = new JTextField();
    pickText.setPreferredSize(new Dimension(150, 30));
    desText = new JTextField();
    desText.setPreferredSize(new Dimension(150, 30));
    chatText = new JTextField();
    chatText.setPreferredSize(new Dimension(400, 30));
    chatText.setEnabled(false);

    JPanel top1 = new JPanel();
    top1.add(pickPort);
    top1.add(pickText);
    top1.add(openChat);

    JPanel top2 = new JPanel();
    top2.add(desPort);
    top2.add(desText);
    top2.add(chatWith);

    topPanel.add(top1);
    topPanel.add(top2);

    chatField = new JTextArea();
    chatField.setAutoscrolls(true);
    chatField.setDragEnabled(true);
    chatField.setEditable(false);
    chatField.setAlignmentY(TOP_ALIGNMENT);

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(chatText);
    bottomPanel.add(send);

    this.add(topPanel, BorderLayout.NORTH);
    this.add(chatField, BorderLayout.CENTER);
    this.add(bottomPanel, BorderLayout.SOUTH);

    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
    private void initComponents() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      textLayout.putConstraint(SpringLayout.NORTH, fpsField_, 0, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(SpringLayout.NORTH, zPosLabel_, 3, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(
          SpringLayout.NORTH, timeStampLabel_, 3, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(SpringLayout.NORTH, fpsLabel, 3, SpringLayout.NORTH, textPanel);
    }
Beispiel #27
0
  void jbInit() throws Exception {
    titledBorder1 =
        new TitledBorder(
            BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages");
    this.getContentPane().setLayout(borderLayout1);

    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);

    this.setTitle("EDIT");

    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(470);
    sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12));
    controlPanel.setLayout(gridBagLayout1);
    controlPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    positionPanel.setLayout(gridBagLayout2);
    fileLabel.setText("Source file:");
    fileText.setEditable(false);
    browseButton.setSelected(false);
    browseButton.setText("Browse ...");
    assembleButton.setEnabled(false);
    assembleButton.setText("Assemble file");
    saveButton.setEnabled(false);
    saveButton.setText("Save file");
    lineLabel.setText("Line:");
    lineText.setMinimumSize(new Dimension(50, 20));
    lineText.setPreferredSize(new Dimension(50, 20));
    lineText.setEditable(false);
    columnLabel.setText("Column:");
    columnText.setMinimumSize(new Dimension(41, 20));
    columnText.setPreferredSize(new Dimension(41, 20));
    columnText.setEditable(false);
    columnText.setText("");
    messageScrollPane.setBorder(titledBorder1);
    messageScrollPane.setMinimumSize(new Dimension(33, 61));
    messageScrollPane.setPreferredSize(new Dimension(60, 90));
    optionsButton.setEnabled(false);
    optionsButton.setText("Assembler options ...");
    messageScrollPane.getViewport().add(messageList, null);
    messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.add(textScrollPane, JSplitPane.TOP);
    splitPane.add(controlPanel, JSplitPane.BOTTOM);
    textScrollPane.getViewport().add(sourceArea, null);

    controlPanel.add(
        fileLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        fileText,
        new GridBagConstraints(
            1,
            0,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        browseButton,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        optionsButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        assembleButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        saveButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        positionPanel,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        lineLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    positionPanel.add(
        lineText,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        columnLabel,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    positionPanel.add(
        columnText,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        messageScrollPane,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
Beispiel #28
0
  /** Install the Rotate-Button into the toolbar */
  private void installRotateButton() {
    URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/rotate.gif");
    ImageIcon rotateIcon = new ImageIcon(imgURL);
    rotate = new JButton(rotateIcon);
    rotate.setEnabled(false);
    rotatePanel = new JToolBar();
    rotatePanel.setOrientation(1);
    rotatePanel.setLayout(new BorderLayout(0, 1));
    rotateSlider = new JSlider();
    rotateSlider.setMaximum(359);
    rotateSlider.setMinimum(0);
    rotateSlider.setMaximumSize(new Dimension(100, 100));
    rotateSlider.setOrientation(1);
    Box box = Box.createVerticalBox();

    sliderValue.setPreferredSize(new Dimension(30, 20));

    rotateSlider.setAlignmentY(Component.TOP_ALIGNMENT);
    box.add(sliderValue);
    box.add(rotateSlider);
    sliderValue.setAlignmentY(Component.TOP_ALIGNMENT);
    rotatePanel.add(box, BorderLayout.NORTH);

    sliderValue.addFocusListener(
        new FocusListener() {

          private int oldValue = 0;

          public void focusGained(FocusEvent arg0) {
            oldValue = Integer.parseInt(sliderValue.getText());
          }

          public void focusLost(FocusEvent arg0) {
            int newValue = 0;
            try {
              newValue = Integer.parseInt(sliderValue.getText());
            } catch (Exception ex) {
              sliderValue.setText(Integer.toString(oldValue));
            }
            if (newValue >= 0 && newValue <= 359) {

              RotateCommand rc = new RotateCommand(board.getSelectedItems());
              ArrayList<Command> actCommands = new ArrayList<Command>();
              actCommands.add(rc);
              TBE.getInstance().addCommands(actCommands);
              rotateSlider.setValue(newValue);
            } else {
              sliderValue.setText(Integer.toString(oldValue));
            }
          }
        });

    rotateSlider.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent arg0) {

            if (board.getSelectionCount() == 1
                && board.getSelectionCells()[0] instanceof ShapeItem) {
              sliderValue.setText(Integer.toString(rotateSlider.getValue()));
              ShapeItem s = (ShapeItem) board.getSelectionCells()[0];
              board.removeItem(new ItemComponent[] {s});
              s.setRotation(rotateSlider.getValue());
              board.addItem(s);
            }
          }
        });
    rotateSlider.addMouseListener(
        new MouseAdapter() {

          private int value;

          public void mousePressed(MouseEvent e) {
            value = rotateSlider.getValue();
          }

          public void mouseReleased(MouseEvent e) {
            if (value != rotateSlider.getValue()) {
              RotateCommand rc = new RotateCommand(board.getSelectedItems());
              ArrayList<Command> actCommands = new ArrayList<Command>();
              actCommands.add(rc);
              TBE.getInstance().addCommands(actCommands);
              rc.setRotation(value);
            }
          }
        });

    rotate.setToolTipText(workingViewLabels.getString("rotate"));

    rotate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (board.getSelectionCount() == 1
                && board.getSelectedItems()[0] instanceof ShapeItem) {
              rotateSlider.setValue(((ShapeItem) board.getSelectedItems()[0]).getRotation());
            }
            rotatePanel.setVisible(!rotatePanel.isVisible());
            showRotate = !showRotate;
          }
        });

    rotate.setContentAreaFilled(false);
    rotate.setBorderPainted(false);
    toolbar.add(rotate);
    rotatePanel.setVisible(false);
    this.add(rotatePanel, BorderLayout.EAST);
  }
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel(new GridBagLayout());

    panel.add(
        new JLabel(myName),
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 3, 5),
            0,
            0));
    panel.add(
        myTfUrl,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 5, 5, 5),
            0,
            0));

    myTfUrl.setPreferredSize(new Dimension(350, myTfUrl.getPreferredSize().height));

    if (myShowPath) {
      panel.add(
          new JLabel(myLocation),
          new GridBagConstraints(
              0,
              2,
              1,
              1,
              0,
              0,
              GridBagConstraints.WEST,
              GridBagConstraints.NONE,
              new Insets(0, 5, 3, 5),
              0,
              0));
      panel.add(
          myTfPath,
          new GridBagConstraints(
              0,
              3,
              1,
              1,
              1,
              0,
              GridBagConstraints.WEST,
              GridBagConstraints.HORIZONTAL,
              new Insets(0, 5, 10, 0),
              0,
              0));
      panel.add(
          myBtnBrowseLocalPath,
          new GridBagConstraints(
              1,
              3,
              1,
              1,
              0,
              0,
              GridBagConstraints.CENTER,
              GridBagConstraints.NONE,
              new Insets(0, 0, 10, 5),
              0,
              0));

      //
      TextFieldWithBrowseButton.MyDoClickAction.addTo(myBtnBrowseLocalPath, myTfPath);
      myBtnBrowseLocalPath.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ignored) {
              FileChooserDescriptor descriptor = getChooserDescriptor();
              VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
              if (file != null) {
                myTfPath.setText(file.getPath().replace('/', File.separatorChar));
              }
            }
          });
    }

    //

    return panel;
  }
Beispiel #30
0
 void jbInit() throws Exception {
   panel1.setLayout(borderLayout1);
   jPanel1.setBorder(BorderFactory.createEtchedBorder());
   jPanel1.setPreferredSize(new Dimension(14, 100));
   jPanel1.setLayout(borderLayout2);
   jPanel2.setBorder(BorderFactory.createEtchedBorder());
   jPanel2.setPreferredSize(new Dimension(10, 40));
   jPanel2.setLayout(gridBagLayout1);
   jLabel2.setText("Oznaka banke:");
   bPronadji.setPreferredSize(new java.awt.Dimension(80, 27));
   bPronadji.setText("Pronadji ");
   bPronadji.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           bPronadji_actionPerformed(e);
         }
       });
   bIzlaz.setPreferredSize(new Dimension(80, 27));
   bIzlaz.setText("Izlaz");
   bIzlaz.addActionListener(
       new java.awt.event.ActionListener() {
         public void actionPerformed(ActionEvent e) {
           bIzlaz_actionPerformed(e);
         }
       });
   txtOznakaBanke.setPreferredSize(new Dimension(120, 21));
   getContentPane().add(panel1);
   panel1.add(jPanel1, BorderLayout.NORTH);
   {
     jLabel1 = new JLabel();
     jPanel1.add(jLabel1, BorderLayout.CENTER);
     jLabel1.setText("PREGLED FILIJALA BANKE");
     jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18));
     jLabel1.setPreferredSize(new java.awt.Dimension(588, 96));
     jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
     jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
     jLabel1.setVerticalAlignment(SwingConstants.TOP);
     {
       jLabel3 = new JLabel();
       jLabel1.add(jLabel3);
       jLabel3.setText("NAZIV:");
       jLabel3.setBounds(7, 49, 42, 28);
       jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12));
     }
     {
       jLabel4 = new JLabel();
       jLabel1.add(jLabel4);
       jLabel4.setText("ADRESA:");
       jLabel4.setBounds(280, 49, 63, 28);
       jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12));
     }
     {
       jLnazivBanke = new JLabel();
       jLabel1.add(jLnazivBanke);
       jLnazivBanke.setBounds(56, 49, 203, 28);
     }
     {
       jLadresaBanke = new JLabel();
       jLabel1.add(jLadresaBanke);
       jLadresaBanke.setBounds(336, 49, 238, 28);
     }
   }
   panel1.add(jPanel2, BorderLayout.SOUTH);
   jPanel2.add(
       jLabel2,
       new GridBagConstraints(
           0,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 0, 0, 0),
           0,
           0));
   jPanel2.add(
       txtOznakaBanke,
       new GridBagConstraints(
           1,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.WEST,
           GridBagConstraints.NONE,
           new Insets(0, 10, 0, 0),
           0,
           0));
   jPanel2.add(
       bPronadji,
       new GridBagConstraints(
           5,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 10, 0, 0),
           0,
           0));
   jPanel2.add(
       bIzlaz,
       new GridBagConstraints(
           5,
           0,
           1,
           1,
           0.0,
           0.0,
           GridBagConstraints.CENTER,
           GridBagConstraints.NONE,
           new Insets(0, 200, 0, 0),
           0,
           0));
   panel1.add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(tabBanke, null);
   TModelPrijave tMP = new TModelPrijave(tabBanke);
   tabBanke.setModel(tMP);
   ((TModelPrijave) tabBanke.getModel()).initColumns();
 }