/** Creates the error area component. */
 private void initErrorArea() {
   SimpleAttributeSet attribs = new SimpleAttributeSet();
   StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT);
   StyleConstants.setFontFamily(attribs, errorPane.getFont().getFamily());
   StyleConstants.setForeground(attribs, Color.RED);
   errorPane.setParagraphAttributes(attribs, true);
   errorPane.setPreferredSize(new Dimension(100, 50));
   errorPane.setMinimumSize(new Dimension(100, 50));
   errorPane.setOpaque(false);
 }
  public JWrapLabel(String txt) {
    super();
    setEditable(false);
    setText(txt);

    SimpleAttributeSet set = new SimpleAttributeSet();
    StyleConstants.setAlignment(set, StyleConstants.ALIGN_CENTER);
    StyleConstants.setFontFamily(set, "Arial");
    StyleConstants.setFontSize(set, 13);
    setParagraphAttributes(set, true);
  }
Exemple #3
0
  {
    StyleContext context = new StyleContext();
    document = new DefaultStyledDocument(context);

    Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
    StyleConstants.setAlignment(style, StyleConstants.ALIGN_LEFT);
  }
 public static void main(String[] args) throws IOException {
   /*Cargar Fuentes
   //InputStream istream = getClass().getResourceAsStream("/dossier/productividad/Fonts/Roboto-Bold.ttf");
   try {
       Font myFont = Font.createFont(Font.TRUETYPE_FONT, istream);
   } catch (FontFormatException ex) {
       Logger.getLogger(DossierProductividad.class.getName()).log(Level.SEVERE, null, ex);
   }
   */
   // Obtiene el dia, ano y mes actual para el indice de las listas
   String ddiaActual = new SimpleDateFormat("dd").format(Calendar.getInstance().getTime());
   diaActual = Integer.parseInt(ddiaActual) - 1;
   System.out.println("El dia es: " + diaActual);
   String mmesActual = new SimpleDateFormat("MM").format(Calendar.getInstance().getTime());
   mesActual = Integer.parseInt(mmesActual) - 1;
   System.out.println("El mes es: " + mesActual);
   String aanoActual = new SimpleDateFormat("YY").format(Calendar.getInstance().getTime());
   anoActual = Integer.parseInt(aanoActual);
   System.out.println("El ano es: " + anoActual);
   // Se crea y despliega la interfaz grafica
   DossierProductividadGUI dossier = new DossierProductividadGUI();
   dossier.setVisible(true);
   dossier.setframeicon(dossier, "icono.png"); // Pone el icono de la aplicacion
   // Pone deja como default el texto centrado en el estilo
   SimpleAttributeSet center = new SimpleAttributeSet();
   StyledDocument pane = DossierProductividadGUI.paneDisplay1.getStyledDocument();
   StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
   aplicarCentroPane(pane, center);
   pane = DossierProductividadGUI.paneDisplay2.getStyledDocument();
   aplicarCentroPane(pane, center);
   pane = DossierProductividadGUI.paneDisplay3.getStyledDocument();
   aplicarCentroPane(pane, center);
   StyledDocument pane2 = DossierProductividadGUI.paneDisplay4.getStyledDocument();
   StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
   aplicarCentroPane(pane2, center);
   pane2 = DossierProductividadGUI.paneDisplay5.getStyledDocument();
   aplicarCentroPane(pane2, center);
   pane2 = DossierProductividadGUI.paneDisplay6.getStyledDocument();
   aplicarCentroPane(pane2, center);
   // Carga el texto en los paneles y tablas
   manejaTexto.actualizarTexto(6); // Actualiza los datos de la lista de tareas
   manejaTexto.actualizarTexto(0); // Actualiza el texto en los paneles de tareas
   manejaTexto.actualizarTexto(4); // Actualiza los valores de las tablas
   manejaTexto.actualizarTexto(2); // Actualiza los valores de las tablas
 }
  /** Creates the text area. */
  private void initTextArea() {
    textArea.setOpaque(false);
    textArea.setEditable(false);
    StyledDocument doc = textArea.getStyledDocument();

    MutableAttributeSet standard = new SimpleAttributeSet();
    StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER);
    StyleConstants.setFontFamily(standard, textArea.getFont().getFamily());
    StyleConstants.setFontSize(standard, 12);
    doc.setParagraphAttributes(0, 0, standard, true);

    parentWindow.addSearchFieldListener(this);
  }
Exemple #6
0
  private void setStyles() {

    doc = helpPanel.getjTextPane1().getStyledDocument();

    style = helpPanel.getjTextPane1().addStyle("I'm a Style", null);
    StyleConstants.setAlignment(style, StyleConstants.ALIGN_CENTER);
    StyleConstants.setForeground(style, Color.PINK);
    StyleConstants.setFontSize(style, 20);
    StyleConstants.setFontFamily(style, "cambria");
    StyleConstants.setBold(style, true);
    StyleConstants.setSpaceAbove(style, 4);

    style2 = helpPanel.getjTextPane1().addStyle("I'm a Style", null);
    StyleConstants.setFontFamily(style2, "cambria");
    StyleConstants.setForeground(style2, Color.BLUE);
    StyleConstants.setBold(style2, true);
    StyleConstants.setAlignment(style2, StyleConstants.ALIGN_JUSTIFIED);
    StyleConstants.setFontSize(style2, 12);

    styleW = helpPanel.getjTextPane1().addStyle("I'm a Style", null);
    StyleConstants.setFontFamily(styleW, "cambria");
    StyleConstants.setAlignment(styleW, StyleConstants.ALIGN_JUSTIFIED);
    StyleConstants.setFontSize(styleW, 12);

    styleWB = helpPanel.getjTextPane1().addStyle("I'm a Style", null);
    StyleConstants.setFontFamily(styleWB, "cambria");
    StyleConstants.setBold(styleWB, true);
    StyleConstants.setAlignment(styleWB, StyleConstants.ALIGN_JUSTIFIED);
    StyleConstants.setFontSize(styleWB, 12);

    styleP = helpPanel.getjTextPane1().addStyle("I'm a Style", null);
    StyleConstants.setFontFamily(styleP, "cambria");
    StyleConstants.setForeground(styleP, Color.MAGENTA);
    StyleConstants.setBold(styleP, true);
    StyleConstants.setAlignment(styleP, StyleConstants.ALIGN_JUSTIFIED);
    StyleConstants.setFontSize(styleP, 12);
  }
  public void setSelectionAlignment(int alignment) {
    setAlignmentOptions(alignment);

    StyledDocument sd = (StyledDocument) editor.getDocument();
    int a = editor.getSelectionStart();
    int b = editor.getSelectionEnd();
    if (a == b) {
      rtf.getInputAttributes().addAttribute(StyleConstants.Alignment, alignment);
      return;
    }
    SimpleAttributeSet sas = new SimpleAttributeSet();
    StyleConstants.setAlignment(sas, alignment);
    sd.setParagraphAttributes(a, b - a, sas, false);
    return;
  }
  /**
   * Sets the reason of a call failure if one occurs. The renderer should display this reason to the
   * user.
   *
   * @param reason the reason to display
   */
  public void setErrorReason(final String reason) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              setErrorReason(reason);
            }
          });
      return;
    }

    if (errorMessageComponent == null) {
      errorMessageComponent = new JTextPane();

      JTextPane textPane = (JTextPane) errorMessageComponent;
      textPane.setEditable(false);
      textPane.setOpaque(false);

      StyledDocument doc = textPane.getStyledDocument();

      MutableAttributeSet standard = new SimpleAttributeSet();
      StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER);
      StyleConstants.setFontFamily(standard, textPane.getFont().getFamily());
      StyleConstants.setFontSize(standard, 12);
      doc.setParagraphAttributes(0, 0, standard, true);

      GridBagConstraints constraints = new GridBagConstraints();
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.gridx = 0;
      constraints.gridy = 4;
      constraints.weightx = 1;
      constraints.weighty = 0;
      constraints.insets = new Insets(5, 0, 0, 0);

      add(errorMessageComponent, constraints);
      this.revalidate();
    }

    errorMessageComponent.setText(reason);

    if (isVisible()) errorMessageComponent.repaint();
  }
Exemple #9
0
  private void displayCenteredText(String text) {
    textArea.setText("");
    text = "\n\n\n" + text;
    SimpleAttributeSet attribs = new SimpleAttributeSet();
    float fnt = sd.getFontSize();
    StyledDocument doc = (StyledDocument) textArea.getDocument();
    Style style = doc.getStyle(StyleContext.DEFAULT_STYLE); // doc.addStyle("MyStyle",null);
    StyleConstants.setFontSize(style, (int) fnt);
    StyleConstants.setLineSpacing(attribs, 0.5f);
    StyleConstants.setFontFamily(style, "Segoe UI");
    StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_CENTER);
    textArea.setParagraphAttributes(attribs, true);

    try {
      doc.insertString(doc.getLength(), text, style);
      doc.setParagraphAttributes(0, doc.getLength() - 1, attribs, false);
    } catch (BadLocationException ex) {
      Logger.getLogger(DylematorUI.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
  public void changePanel(EventPanelInfo epi) {
    JPanel newButtonPanel = new JPanel();
    label.setText("\n" + epi.getText());

    // format the text
    SimpleAttributeSet bSet = new SimpleAttributeSet();
    StyleConstants.setAlignment(bSet, StyleConstants.ALIGN_CENTER);
    StyleConstants.setFontFamily(bSet, "lucida typewriter bold");
    StyleConstants.setFontSize(bSet, 24);
    StyledDocument doc = label.getStyledDocument();
    doc.setParagraphAttributes(0, doc.getLength(), bSet, false);

    System.out.println("label.getText(): " + label.getText());

    int buttonCount = epi.getButtonCount();
    for (int i = 0; i < buttonCount; i++) {
      JButton button = epi.getButtonAtIndex(i);
      newButtonPanel.add(button);
    }
    master.remove(buttonPanel);
    buttonPanel = newButtonPanel;
    master.add(label, BorderLayout.CENTER);
    master.add(buttonPanel, BorderLayout.SOUTH);
  }
Exemple #11
0
  /**
   * Returns a JPanel that represents the mancala board using strategy pattern to insert style.
   *
   * @param strat concrete strategy
   * @return JPanel containing both users' pits as controllers
   */
  public JPanel boardContextDoWork(Strategy strat) {
    this.s = strat;
    Color boardColor = s.getBoardColor();
    Color fontColor = s.getFontColor();
    Font font = s.getFont();
    JPanel panCenter = new JPanel();
    JPanel panLeft = new JPanel();
    JPanel panRight = new JPanel();

    panCenter.setLayout(new GridLayout(2, 6, 10, 10));
    // B6 to B1 Controllers
    for (int i = 12; i > 6; i--) {
      final Pits temp = new Pits(i);
      final int pit = i;
      final JLabel tempLabel = new JLabel(temp);
      tempLabel.addMouseListener(
          new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              if (Model.player == 1) {
                JFrame frame = new JFrame();
                JOptionPane.showMessageDialog(frame, "Player A's turn!");
              } else if (model.data[pit] == 0) {
                JFrame frame = new JFrame();
                JOptionPane.showMessageDialog(frame, "Pit is Empty try another one.");
              } else {
                if (temp.pitShape.contains(e.getPoint())) {
                  model.move(pit); // mutator
                  undoBtn.setText("Undo : " + model.getUndoCounter());
                  model.display();
                }
              }
            }
          });
      JPanel tempPanel = new JPanel(new BorderLayout());

      JTextPane textPane = new JTextPane();
      textPane.setEditable(false);
      textPane.setBackground(boardColor);
      textPane.setForeground(fontColor);
      textPane.setFont(font);
      textPane.setText("B" + (i - 6));
      StyledDocument doc = textPane.getStyledDocument();
      SimpleAttributeSet center = new SimpleAttributeSet();
      StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
      doc.setParagraphAttributes(0, doc.getLength(), center, false);
      tempPanel.add(textPane, BorderLayout.NORTH);
      tempPanel.add(tempLabel, BorderLayout.SOUTH);
      panCenter.add(tempPanel, BorderLayout.SOUTH);

      tempPanel.setBackground(boardColor);
    }
    // A1 to A6 Controllers
    for (int i = 0; i < 6; i++) {
      final Pits newPits = new Pits(i);
      JLabel label = new JLabel(newPits);
      final int pit = i;
      label.addMouseListener(
          new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              if (Model.player == 2) {
                JFrame frame = new JFrame();
                JOptionPane.showMessageDialog(frame, "Player B's turn!");
              } else if (model.data[pit] == 0) {
                JFrame frame = new JFrame();
                JOptionPane.showMessageDialog(frame, "Pit is Empty try another one.");
              } else {
                if (newPits.pitShape.contains(e.getPoint())) {
                  model.move(pit); // mutator
                  undoBtn.setText("Undo : " + model.getUndoCounter());
                  model.display();
                }
              }
            }
          });
      JPanel tempPanel = new JPanel(new BorderLayout());

      tempPanel.add(label, BorderLayout.NORTH);
      JTextPane textPane = new JTextPane();
      textPane.setBackground(boardColor);
      textPane.setForeground(fontColor);
      textPane.setFont(font);
      textPane.setEditable(false);
      textPane.setText("A" + (i + 1));
      StyledDocument doc = textPane.getStyledDocument();
      SimpleAttributeSet center = new SimpleAttributeSet();
      StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
      doc.setParagraphAttributes(0, doc.getLength(), center, false);
      tempPanel.add(textPane, BorderLayout.SOUTH);
      tempPanel.setBackground(boardColor);
      panCenter.add(tempPanel, BorderLayout.SOUTH);
    }

    // left text pane
    JTextPane paneLeft = new JTextPane();
    paneLeft.setBackground(boardColor);
    paneLeft.setForeground(fontColor);
    paneLeft.setFont(font);
    paneLeft.setEditable(false);
    paneLeft.setText("M\nA\nN\nC\nA\nL\nA\n \nB");

    // right text pane
    JTextPane paneRight = new JTextPane();
    paneRight.setBackground(boardColor);
    paneRight.setForeground(fontColor);
    paneRight.setFont(font);
    paneRight.setEditable(false);
    paneRight.setText("M\nA\nN\nC\nA\nL\nA\n \nA");

    // Add text panes to left and right panels
    panLeft.setLayout(new BorderLayout());
    panRight.setLayout(new BorderLayout());
    panLeft.add(paneLeft, BorderLayout.WEST);
    panRight.add(paneRight, BorderLayout.EAST);
    panLeft.add(new JLabel(new Pits(13)), BorderLayout.EAST);
    panRight.add(new JLabel(new Pits(6)), BorderLayout.WEST);

    // add the 2 mancala panels and pit panel to larger displayPanel
    JPanel displayPanel = new JPanel();
    displayPanel.add(panLeft, BorderLayout.WEST);
    displayPanel.add(panCenter, BorderLayout.CENTER);
    displayPanel.add(panRight, BorderLayout.EAST);

    // set color
    panCenter.setBackground(boardColor);
    panLeft.setBackground(boardColor);
    panRight.setBackground(boardColor);
    displayPanel.setBackground(boardColor);

    // return display panel which contains the containers and elements created
    return displayPanel;
  }
Exemple #12
0
  void createStyles() {
    // no attributes defined
    Style s = styles.addStyle(null, null);
    runAttr.put("none", s);
    s = styles.addStyle(null, null);
    StyleConstants.setItalic(s, true);
    StyleConstants.setForeground(s, new Color(153, 153, 102));
    runAttr.put("cquote", s); // catepillar quote

    s = styles.addStyle(null, null);
    StyleConstants.setItalic(s, true);
    StyleConstants.setForeground(s, new Color(51, 102, 153));
    runAttr.put("aquote", s); // alice quote

    try {
      ResourceBundle resources =
          ResourceBundle.getBundle("resources.Stylepad", Locale.getDefault());
      s = styles.addStyle(null, null);
      Icon alice = new ImageIcon(resources.getString("aliceGif"));
      StyleConstants.setIcon(s, alice);
      runAttr.put("alice", s); // alice

      s = styles.addStyle(null, null);
      Icon caterpillar = new ImageIcon(resources.getString("caterpillarGif"));
      StyleConstants.setIcon(s, caterpillar);
      runAttr.put("caterpillar", s); // caterpillar

      s = styles.addStyle(null, null);
      Icon hatter = new ImageIcon(resources.getString("hatterGif"));
      StyleConstants.setIcon(s, hatter);
      runAttr.put("hatter", s); // hatter

    } catch (MissingResourceException mre) {
      // can't display image
    }

    Style def = styles.getStyle(StyleContext.DEFAULT_STYLE);

    Style heading = styles.addStyle("heading", def);
    // StyleConstants.setFontFamily(heading, "SansSerif");
    StyleConstants.setBold(heading, true);
    StyleConstants.setAlignment(heading, StyleConstants.ALIGN_CENTER);
    StyleConstants.setSpaceAbove(heading, 10);
    StyleConstants.setSpaceBelow(heading, 10);
    StyleConstants.setFontSize(heading, 18);

    // Title
    Style sty = styles.addStyle("title", heading);
    StyleConstants.setFontSize(sty, 32);

    // edition
    sty = styles.addStyle("edition", heading);
    StyleConstants.setFontSize(sty, 16);

    // author
    sty = styles.addStyle("author", heading);
    StyleConstants.setItalic(sty, true);
    StyleConstants.setSpaceBelow(sty, 25);

    // subtitle
    sty = styles.addStyle("subtitle", heading);
    StyleConstants.setSpaceBelow(sty, 35);

    // normal
    sty = styles.addStyle("normal", def);
    StyleConstants.setLeftIndent(sty, 10);
    StyleConstants.setRightIndent(sty, 10);
    // StyleConstants.setFontFamily(sty, "SansSerif");
    StyleConstants.setFontSize(sty, 14);
    StyleConstants.setSpaceAbove(sty, 4);
    StyleConstants.setSpaceBelow(sty, 4);
  }
Exemple #13
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);
  }
Exemple #14
0
  public ChatPanel(final String roomId, final String gameId) {
    this.roomId = roomId;
    this.gameId = gameId;

    setLayout(new BorderLayout());

    textPane = new WrapTextPane();
    textPane.setEditable(false);

    JScrollPane scrollPane = new JScrollPane(textPane);

    Style defaultStyle = textPane.getStyle("default");
    userNameStyle = textPane.addStyle("userNameStyle", defaultStyle);
    textStyle = textPane.addStyle("textStyle", defaultStyle);
    iconStyle = textPane.addStyle("iconStyle", defaultStyle);
    actionStyle = textPane.addStyle("actionStyle", defaultStyle);

    StyleConstants.setBold(userNameStyle, true);
    StyleConstants.setAlignment(iconStyle, StyleConstants.ALIGN_CENTER);
    StyleConstants.setBold(actionStyle, true);

    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    add(scrollPane, BorderLayout.CENTER);

    text = (StyledDocument) textPane.getDocument();

    final JTextField userInputField = new JTextField(20);
    userInputField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // We get the text from the textfield
            String messageContent = userInputField.getText();

            if (messageContent != null) {
              if (ChatPanel.this.gameId != null || ChatPanel.this.roomId != null) {
                AbstractMessage message = null;
                if (ChatPanel.this.gameId != null) {
                  message =
                      new PostGameMessageMessage(
                          CurrentUserInfo.getInstance().getPlayerId(),
                          messageContent,
                          ChatPanel.this.gameId);
                } else {
                  message =
                      new PostRoomMessageMessage(
                          CurrentUserInfo.getInstance().getId(),
                          messageContent,
                          ChatPanel.this.roomId);
                }

                CoreMessageBus.post(message);
                // We reset our text field to "" each time the user presses Enter
                userInputField.setText("");
              }
            }
          }
        });

    add(userInputField, BorderLayout.PAGE_END);

    Dimension dim = new Dimension(200, 400);
    setPreferredSize(dim);

    GuiMessageBus.register(this);
  }
  protected void buildErrorPanel() {
    errorPanel = new JPanel();
    GroupLayout layout = new GroupLayout(errorPanel);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    errorPanel.setLayout(layout);
    //    errorPanel.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
    errorMessage = new JTextPane();
    errorMessage.setEditable(false);
    errorMessage.setContentType("text/html");
    errorMessage.setText(
        "<html><body>Could not connect to the Processing server.<br>"
            + "Contributions cannot be installed or updated without an Internet connection.<br>"
            + "Please verify your network connection again, then try connecting again.</body></html>");
    errorMessage.setFont(Toolkit.getSansFont(14, Font.PLAIN));
    errorMessage.setMaximumSize(new Dimension(550, 50));
    errorMessage.setOpaque(false);

    StyledDocument doc = errorMessage.getStyledDocument();
    SimpleAttributeSet center = new SimpleAttributeSet();
    StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
    doc.setParagraphAttributes(0, doc.getLength(), center, false);

    closeButton = new JButton("X");
    closeButton.setContentAreaFilled(false);
    closeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            contribDialog.makeAndShowTab(false, false);
          }
        });
    tryAgainButton = new JButton("Try Again");
    tryAgainButton.setFont(Toolkit.getSansFont(14, Font.PLAIN));
    tryAgainButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            contribDialog.makeAndShowTab(false, true);
            contribDialog.downloadAndUpdateContributionListing(editor.getBase());
          }
        });
    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.CENTER)
                    .addComponent(errorMessage)
                    .addComponent(
                        tryAgainButton,
                        StatusPanel.BUTTON_WIDTH,
                        StatusPanel.BUTTON_WIDTH,
                        StatusPanel.BUTTON_WIDTH))
            .addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addComponent(closeButton));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout.createParallelGroup().addComponent(errorMessage).addComponent(closeButton))
            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(tryAgainButton));
    errorPanel.setBackground(Color.PINK);
    errorPanel.validate();
  }
Exemple #16
0
    @Override
    public void actionPerformed(ActionEvent e) {

      licence_text =
          new String(
              "This program is free software: you can redistribute it and/or modify\n"
                  + "it under the terms of the GNU General Public License as published by\n"
                  + "the Free Software Foundation, either version 3 of the License, or\n"
                  + "(at your option) any later version.\n"
                  + "\n"
                  + "This program is distributed in the hope that it will be useful,\n"
                  + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
                  + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
                  + "GNU General Public License for more details.\n"
                  + "\n"
                  + "You should have received a copy of the GNU General Public License\n"
                  + "along with this program.  If not, see <http://www.gnu.org/licenses/>.\n"
                  + "\n\n\n");

      try {
        InputStream ips = new FileInputStream(getClass().getResource("COPYING").getPath());
        InputStreamReader ipsr = new InputStreamReader(ips);
        BufferedReader br = new BufferedReader(ipsr);

        String line;
        while ((line = br.readLine()) != null) {
          licence_text += line + '\n';
        }
        br.close();
      } catch (Exception e1) {
      }

      Dimension dimension = new Dimension(600, 400);

      JDialog licence = new JDialog(memento, "Licence");

      JTextPane text_pane = new JTextPane();
      text_pane.setEditable(false);
      text_pane.setPreferredSize(dimension);
      text_pane.setSize(dimension);

      StyledDocument doc = text_pane.getStyledDocument();

      Style justified =
          doc.addStyle(
              "justified",
              StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE));
      StyleConstants.setAlignment(justified, StyleConstants.ALIGN_JUSTIFIED);

      try {
        doc.insertString(0, licence_text, justified);
      } catch (BadLocationException ble) {
        System.err.println("Couldn't insert initial text into text pane.");
      }
      Style logicalStyle = doc.getLogicalStyle(0);
      doc.setParagraphAttributes(0, licence_text.length(), justified, false);
      doc.setLogicalStyle(0, logicalStyle);

      JScrollPane paneScrollPane = new JScrollPane(text_pane);
      paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
      paneScrollPane.setPreferredSize(dimension);
      paneScrollPane.setMinimumSize(dimension);

      JPanel pan = new JPanel();
      LayoutManager layout = new BorderLayout();
      pan.setLayout(layout);

      pan.add(new JScrollPane(paneScrollPane), BorderLayout.CENTER);
      JButton close = new JButton("Fermer");
      close.addActionListener(new ButtonCloseActionListener(licence));
      JPanel button_panel = new JPanel();
      FlowLayout button_panel_layout = new FlowLayout(FlowLayout.RIGHT, 20, 20);
      button_panel.setLayout(button_panel_layout);

      button_panel.add(close);
      pan.add(button_panel, BorderLayout.SOUTH);

      licence.add(pan);

      licence.pack();
      licence.setLocationRelativeTo(memento);
      licence.setVisible(true);
    }
  /**
   * Interfaz gráfica de usuaria creada directamente en el constructor.
   *
   * @throws IOException
   */
  public IUCliente() throws IOException {

    socket =
        new Socket(
            "localhost",
            55555); // Lo ponemos en contacto con el servidor, que lo aceptará una vez le llegue
    oos =
        new ObjectOutputStream(
            socket.getOutputStream()); // Abrimos los streamings de escritura y lectura.
    ois = new ObjectInputStream(socket.getInputStream());

    // Parte de la interfaz gráfica que he creado con la paleta del IDE
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 319, 295);
    getContentPane().setLayout(null);

    SimpleAttributeSet attribs = new SimpleAttributeSet();
    StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT);

    panel = new JTextPane();
    panel.setText("");
    panel.setFont(new Font("Consolas", Font.PLAIN, 15));
    panel.setEditable(false);
    panel.setBounds(10, 11, 177, 41);
    panel.setParagraphAttributes(attribs, true);

    getContentPane().add(panel);

    JPanel panel_1 = new JPanel();
    panel_1.setBounds(10, 63, 284, 188);
    getContentPane().add(panel_1);
    panel_1.setLayout(null);

    // Todos los eventos de la calculadora por cada botón. Básicamente cada botóne escribe en el
    // panel lo que pone en dicho botón.

    JButton btnNewButton = new JButton("1");
    btnNewButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            panel.setText(panel.getText() + btnNewButton.getText());
          }
        });
    btnNewButton.setBounds(0, 0, 56, 33);
    panel_1.add(btnNewButton);

    JButton button = new JButton("2");
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button.getText());
          }
        });
    button.setBounds(62, 0, 56, 33);
    panel_1.add(button);

    JButton button_1 = new JButton("3");
    button_1.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button_1.getText());
          }
        });
    button_1.setBounds(123, 0, 56, 33);
    panel_1.add(button_1);

    JButton button_2 = new JButton("4");
    button_2.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button_2.getText());
          }
        });
    button_2.setBounds(0, 44, 56, 33);
    panel_1.add(button_2);

    JButton button_3 = new JButton("5");
    button_3.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button_3.getText());
          }
        });
    button_3.setBounds(62, 44, 56, 33);
    panel_1.add(button_3);

    JButton button_4 = new JButton("6");
    button_4.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button_4.getText());
          }
        });
    button_4.setBounds(123, 44, 56, 33);
    panel_1.add(button_4);

    JButton button_5 = new JButton("7");
    button_5.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button_5.getText());
          }
        });
    button_5.setBounds(0, 88, 56, 33);
    panel_1.add(button_5);

    JButton button_6 = new JButton("8");
    button_6.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button_6.getText());
          }
        });
    button_6.setBounds(62, 88, 56, 33);
    panel_1.add(button_6);

    JButton button_7 = new JButton("9");
    button_7.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button_7.getText());
          }
        });
    button_7.setBounds(123, 88, 56, 33);
    panel_1.add(button_7);

    JButton button_8 = new JButton("0");
    button_8.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + button_8.getText());
          }
        });

    button_8.setBounds(62, 132, 56, 33);
    panel_1.add(button_8);

    JButton button_9 = new JButton("/");
    button_9.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + " " + button_9.getText() + " ");
          }
        });
    button_9.setBounds(225, 88, 56, 33);
    panel_1.add(button_9);

    JButton button_10 = new JButton("—");
    button_10.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + " " + button_10.getText() + " ");
          }
        });
    button_10.setBounds(225, 44, 56, 33);
    panel_1.add(button_10);

    JButton button_11 = new JButton("+");
    button_11.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + " " + button_11.getText() + " ");
          }
        });
    button_11.setBounds(225, 0, 56, 33);
    panel_1.add(button_11);

    JButton btnX = new JButton("X");
    btnX.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            panel.setText(panel.getText() + " " + btnX.getText() + " ");
          }
        });
    btnX.setBounds(225, 132, 56, 33);
    panel_1.add(btnX);

    // Este es el único evento que cambia un poco. No tenemos un hilo que envíe y recibe
    // automáticamente, sino que
    // va en función del click del usuario.  LLama a dos métodos que he definido más abajo.
    JButton btnNewButton_1 = new JButton("Calcular");
    btnNewButton_1.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            try {
              enviar();
              recibir();
            } catch (IOException | ClassNotFoundException e1) {
              e1.printStackTrace();
            }
          }
        });
    btnNewButton_1.setBounds(197, 11, 96, 41);
    getContentPane().add(btnNewButton_1);
  }