Example #1
0
  public Perfil() {
    super.setBounds(181, 61, 700, 538); // (ancho,alto)
    super.setLayout(null);
    super.setOpaque(false);
    super.setVisible(false);

    try {
      UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    jbtnGuardar = new JButton("Guardar Cambios");
    jbtnGuardar.setBounds(55, 457, 150, 40);
    jbtnGuardar.addActionListener(this);
    jbtnGuardar.setBorder(null);
    jbtnGuardar.setBackground(new Color(0, 154, 225));
    jbtnGuardar.setForeground(Color.WHITE);
    jbtnGuardar.setFont(new Font("Segoe UI", Font.PLAIN, 14));
    jbtnGuardar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnGuardar.setFocusPainted(false);
    this.add(jbtnGuardar);

    nombre = new JLabel("Ninguna imagen seleccionada");
    nombre.setBounds(210, 250, 200, 40);
    nombre.setForeground(Color.GRAY);
    this.add(nombre);

    jbtnCargarI = new JButton("Cargar imagen");
    jbtnCargarI.setBounds(55, 250, 150, 40);
    jbtnCargarI.addActionListener(this);
    jbtnCargarI.setBorder(null);
    jbtnCargarI.setBackground(new Color(0, 154, 225));
    jbtnCargarI.setForeground(Color.WHITE);
    jbtnCargarI.setFont(new Font("Segoe UI", Font.PLAIN, 14));
    jbtnCargarI.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnCargarI.setFocusPainted(false);
    this.add(jbtnCargarI);

    jbtnQuitarI = new JButton("Quitar imagen");
    jbtnQuitarI.setBounds(55, 186, 150, 40);
    jbtnQuitarI.addActionListener(this);
    jbtnQuitarI.setBorder(null);
    jbtnQuitarI.setBackground(new Color(0, 154, 225));
    jbtnQuitarI.setForeground(Color.WHITE);
    jbtnQuitarI.setFont(new Font("Segoe UI", Font.PLAIN, 14));
    jbtnQuitarI.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnQuitarI.setFocusPainted(false);
    this.add(jbtnQuitarI);

    jlbimage = new JLabel();
    jlbimage.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    jlbimage.setBounds(55, 46, 150, 150);
    this.add(jlbimage);

    this.repaint();
  }
Example #2
0
  public JButton ButtonProperties(JButton button, String buttonText) {

    button.setFont(componentFont);
    button.setBorderPainted(false);
    button.setFocusPainted(false);
    button.setBackground(themeColor1);
    button.setForeground(themeColor4);
    button.setVerticalTextPosition(SwingConstants.BOTTOM);
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {

            button.setBackground(themeColor2);
            button.setForeground(Color.BLACK);
            button.setText(buttonText);
          }

          @Override
          public void mouseExited(MouseEvent e) {

            button.setBackground(themeColor1);
            button.setForeground(themeColor4);
            button.setText("");
          }
        });
    return button;
  }
Example #3
0
  public JButton ButtonProperties(JButton button) {

    button.setFont(componentFont);
    button.setBorderPainted(false);
    button.setFocusPainted(false);
    button.setBackground(themeColor1);
    button.setForeground(themeColor4);
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {

            button.setBackground(themeColor2);
            button.setForeground(Color.BLACK);
          }

          @Override
          public void mouseExited(MouseEvent e) {

            button.setBackground(themeColor1);
            button.setForeground(themeColor4);
          }
        });
    return button;
  }
Example #4
0
  private void listPeople() {

    try {

      jScrollPane1.getViewport().setView(null);

      JFlowPanel jPeople = new JFlowPanel();
      jPeople.applyComponentOrientation(getComponentOrientation());

      java.util.List people = m_dlSystem.listPeopleVisible();

      for (int i = 0; i < people.size(); i++) {

        AppUser user = (AppUser) people.get(i);

        JButton btn = new JButton(new AppUserAction(user));
        btn.applyComponentOrientation(getComponentOrientation());
        btn.setFocusPainted(false);
        btn.setFocusable(false);
        btn.setRequestFocusEnabled(false);
        btn.setHorizontalAlignment(SwingConstants.LEADING);
        btn.setMaximumSize(new Dimension(150, 50));
        btn.setPreferredSize(new Dimension(150, 50));
        btn.setMinimumSize(new Dimension(150, 50));

        jPeople.add(btn);
      }
      jScrollPane1.getViewport().setView(jPeople);

    } catch (BasicException ee) {
      ee.printStackTrace();
    }
  }
Example #5
0
  private MainPanel() {
    super(new GridLayout(3, 1, 5, 5));
    final JTree tree = new JTree();
    final JCheckBox c = new JCheckBox("CheckBox", true);
    c.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            tree.setEnabled(c.isSelected());
          }
        });
    c.setFocusPainted(false);
    JScrollPane l1 = new JScrollPane(tree);
    l1.setBorder(new ComponentTitledBorder(c, l1, BorderFactory.createEtchedBorder()));

    JLabel icon = new JLabel(new ImageIcon(getClass().getResource("16x16.png")));
    JLabel l2 = new JLabel("<html>aaaaaaaaaaaaaaaa<br>bbbbbbbbbbbbbbbbb");
    l2.setBorder(new ComponentTitledBorder(icon, l2, BorderFactory.createEtchedBorder()));

    JButton b = new JButton("Button");
    b.setFocusPainted(false);
    JLabel l3 = new JLabel("ccccccccccccccc");
    l3.setBorder(new ComponentTitledBorder(b, l3, BorderFactory.createEtchedBorder()));

    add(l1);
    add(l2);
    add(l3);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setPreferredSize(new Dimension(320, 240));
  }
 private void initButton(JButton button) {
   button.setText("");
   button.setBorder(RAISED_BORDER);
   button.setBorderPainted(false);
   button.setFocusPainted(false);
   button.setHorizontalAlignment(SwingConstants.CENTER);
   button.setVerticalAlignment(SwingConstants.CENTER);
 }
Example #7
0
 /**
  * _more_
  *
  * @param type
  * @return _more_
  */
 private JButton createButton(SpinIcon.Type type) {
   SpinIcon icon = new SpinIcon(type);
   JButton butt = new JButton(icon);
   Insets i = new Insets(0, 0, 0, 0);
   butt.setMargin(i);
   butt.setBorderPainted(false);
   butt.setFocusPainted(false);
   butt.setPreferredSize(new Dimension(icon.getIconWidth() + 2, icon.getIconHeight() + 2));
   return butt;
 }
  public void initComponents() {
    /** ******************** The main container *************************** */
    Container container = this.getContentPane();
    container.setLayout(new BorderLayout());
    container.setBackground(Color.black);
    this.setSize(650, 600);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {}
        });

    /** ************************* MAIN PANEL ******************************* */
    mainPanel = new JPanel();
    // If put to False: we see the container's background
    mainPanel.setOpaque(false);
    mainPanel.setLayout(new BorderLayout());
    container.add(mainPanel, BorderLayout.CENTER);

    allmessagesTextArea = new TextArea();
    allmessagesTextArea.setEditable(false);
    allmessagesTextArea.setFont(new Font("Dialog", 1, 12));
    allmessagesTextArea.setForeground(Color.black);
    allmessagesTextArea.append("Select a session in the list to view its messages");
    mainPanel.add(allmessagesTextArea, BorderLayout.CENTER);

    sessionsList = new List();
    sessionsList.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            showMessages(e);
          }
        });
    sessionsList.setForeground(Color.black);
    sessionsList.setFont(new Font("Dialog", 1, 14));
    mainPanel.add(sessionsList, BorderLayout.WEST);

    okButton = new JButton("  OK  ");
    okButton.setToolTipText("Returns to the main frame");
    okButton.setFont(new Font("Dialog", 1, 16));
    okButton.setFocusPainted(false);
    okButton.setBackground(Color.lightGray);
    okButton.setBorder(new BevelBorder(BevelBorder.RAISED));
    okButton.setVerticalAlignment(SwingConstants.CENTER);
    okButton.setHorizontalAlignment(SwingConstants.CENTER);
    container.add(okButton, BorderLayout.SOUTH);
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
  }
Example #9
0
  public Abschluss(String wahl, Sudoku s, Sudoku2 s2) {
    super("Sudoku-Abschluss");
    this.setSize(270, 135);
    this.setLocation(250, 300);
    this.setLayout(null);
    this.setAlwaysOnTop(true);
    this.setResizable(false);
    this.setUndecorated(true);
    if (s == null) this.setLocationRelativeTo(s2);
    else this.setLocationRelativeTo(s);

    su = s;
    su2 = s2;
    w = wahl;

    ImageIcon icon = new ImageIcon("files/minigames/Sudoku/beispiel2.jpg");
    icon.setImage(icon.getImage().getScaledInstance(290, 135, Image.SCALE_DEFAULT));

    lab = new JLabel(icon);
    lab.setSize(270, 135);
    lab.setLocation(0, 0);
    this.add(lab);

    text = new JLabel();
    text.setSize(250, 20);
    text.setLocation(10, 10);
    text.setForeground(Color.white);
    text.setHorizontalAlignment(0);
    lab.add(text);

    text2 = new JLabel();
    text2.setSize(270, 20);
    text2.setLocation(10, 30);
    text2.setForeground(Color.white);
    lab.add(text2);

    ok = new JButton("OK");
    ok.setSize(90, 30);
    ok.setLocation(80, 50);
    ok.setBorderPainted(false);
    ok.setBackground(Color.lightGray);
    ok.setForeground(Color.lightGray);
    ok.setOpaque(false);
    ok.setFont(new Font("Arial Black", 4, 20));
    ok.setContentAreaFilled(false);
    ok.setFocusPainted(false);
    ok.addActionListener(this);
    ok.addMouseListener(this);
    lab.add(ok);

    textWahl(wahl);

    this.setVisible(true);
  }
Example #10
0
 public Buttons() {
   setPreferredSize(new Dimension(w, h));
   setBackground(new Color(0, 0, 0, 0));
   setLayout(new BorderLayout());
   min = new JButton("-");
   plus = new JButton("+");
   // min.setPreferredSize(new Dimension(100,10));
   // plus.setPreferredSize(new Dimension(100,10));
   min.setBackground(Color.WHITE);
   plus.setBackground(Color.WHITE);
   min.setOpaque(false);
   plus.setOpaque(false);
   min.setBorderPainted(true);
   min.setFocusPainted(true);
   plus.setFocusPainted(true);
   plus.setBorderPainted(true);
   min.addActionListener(this);
   plus.addActionListener(this);
   min.setActionCommand("-");
   plus.setActionCommand("+");
   add(plus, BorderLayout.NORTH);
   add(min, BorderLayout.CENTER);
 }
Example #11
0
 @Override
 protected JButton createArrowButton() {
   ImageIcon icon = new ImageIcon(getClass().getResource("14x14.png"));
   JButton button =
       new JButton(icon) {
         @Override
         public Dimension getPreferredSize() {
           return new Dimension(14, 14);
         }
       };
   button.setRolloverIcon(makeRolloverIcon(icon));
   button.setFocusPainted(false);
   button.setContentAreaFilled(false);
   return button;
 }
  private static JButton createButton(String accessibleName, Icon icon, Action action) {
    JButton button =
        new JButton() {
          boolean mouseOverButton = false;

          {
            enableEvents(AWTEvent.MOUSE_EVENT_MASK);
            addMouseListener(
                new MouseAdapter() {
                  @Override
                  public void mouseEntered(MouseEvent e) {
                    mouseOverButton = true;
                    repaint();
                  }

                  @Override
                  public void mouseExited(MouseEvent e) {
                    mouseOverButton = false;
                    repaint();
                  }
                });
          }

          @Override
          protected void paintComponent(Graphics g) {
            final Window window = SwingUtilities.windowForComponent(this);
            float alpha = window.isActive() && mouseOverButton ? 1f : 0.5f;
            final GraphicsConfig config = GraphicsUtil.paintWithAlpha(g, alpha);
            getIcon().paintIcon(this, g, 0, 0);
            config.restore();
          }
        };
    button.setFocusPainted(false);
    button.setFocusable(false);
    button.setOpaque(false);
    button.putClientProperty("paintActive", Boolean.TRUE);
    button.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName);
    button.setBorder(JBUI.Borders.empty());
    button.setText(null);
    button.setAction(action);
    button.setIcon(icon);
    return button;
  }
  public void setUseFlatUI(boolean b) {
    main.setContentAreaFilled(!b);
    main.setFocusPainted(!b);
    main.setBorderPainted(!b);
    main.setMargin(new Insets(1, 1, 1, 1));

    popper.setContentAreaFilled(!b);
    popper.setFocusPainted(!b);
    popper.setBorderPainted(!b);
    popper.setMargin(new Insets(1, 1, 1, 1));

    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    setOpaque(false);

    MouseAdapter ma =
        new MouseAdapter() {
          public void mouseEntered(MouseEvent e) {
            main.setContentAreaFilled(true);
            main.setBackground(new Color(216, 240, 254));
            // m.getMainButton().setForeground( Color.black );
            setBorder(new LineBorder(new Color(200, 200, 200), 1));
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

            popper.setBackground(new Color(242, 242, 242));
            popper.setContentAreaFilled(true);
            popper.setBorder(menu.getBorder());
          }

          public void mouseExited(MouseEvent e) {
            main.setContentAreaFilled(false);
            //	c.setForeground( Color.black );
            setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
            setCursor(Cursor.getDefaultCursor());

            popper.setContentAreaFilled(false);
            popper.setBorder(null);
          }
        };

    main.addMouseListener(ma);
    popper.addMouseListener(ma);
  }
 private void onSuchen() {
   LOGGER.trace("KurseSemesterwahlController OK gedrückt");
   if (!isModelValidationMode() && !validateOnSpeichern()) {
     btnOk.setFocusPainted(false);
     return;
   }
   setWaitCursorAllComponents();
   KurseTableData kurseTableData = kurseSemesterwahlModel.suchen();
   KurseTableModel kurseTableModel = new KurseTableModel(kurseTableData);
   String titel =
       "Kurse "
           + kurseSemesterwahlModel.getSemester().getSemesterbezeichnung()
           + " "
           + kurseSemesterwahlModel.getSemester().getSchuljahr();
   KursePanel kursePanel =
       new KursePanel(svmContext, kurseSemesterwahlModel, kurseTableModel, titel);
   kursePanel.addCloseListener(closeListener);
   resetCursorAllComponents();
   nextPanelListener.actionPerformed(
       new ActionEvent(
           new Object[] {kursePanel.$$$getRootComponent$$$(), titel},
           ActionEvent.ACTION_PERFORMED,
           "Suchresultat verfügbar"));
 }
  public LoginPanel(Image img, ActionListener listener) {
    super(null);
    this.listener = listener;
    if (img == null) {
      InputStream inData = getClass().getResourceAsStream("/resources/background.gif");
      BufferedImage back = null;
      if (inData != null)
        try {
          back = ImageIO.read(inData);
        } catch (IOException e) {
          loger.finest("LoginPanel class can't get the background image");
        }
      this.background = back;
    }

    setLayout(null);
    JPanel logingPanel = new JPanel();
    loginTitle = new JLabel("Autentificare");
    logingPanel.setSize(250, 150);
    logingPanel.setBorder(new javax.swing.border.LineBorder(Color.black, 2));
    logingPanel.setLayout(null);
    loginTitle.setBounds(3, 0, logingPanel.getWidth(), 20);
    logingPanel.add(loginTitle);
    JLabel loginUser = new JLabel("Utilizator");
    loginUser.setBounds(
        80 - loginUser.getPreferredSize().width,
        40,
        loginUser.getPreferredSize().width,
        loginUser.getPreferredSize().height);
    logingPanel.add(loginUser);
    user = new JTextField(10);
    user.setBounds(85, 40, user.getPreferredSize().width, user.getPreferredSize().height);
    // user.setText("test");
    // loginUser.setLabelFor(user);
    logingPanel.add(user);
    JLabel loginPass = new JLabel("Parola");
    loginPass.setBounds(
        80 - loginPass.getPreferredSize().width,
        80,
        loginPass.getPreferredSize().width,
        loginPass.getPreferredSize().height);
    logingPanel.add(loginPass);
    // JTextField pass = new JTextField(10);
    pass = new JPasswordField(10);
    pass.setBounds(85, 80, pass.getPreferredSize().width, pass.getPreferredSize().height);
    pass.addKeyListener(this);
    // pass.setText("test");
    // loginUser.setLabelFor(user);
    logingPanel.add(pass);
    JButton loginButton = new JButton("Start");
    loginButton.setActionCommand("LOGIN");
    loginButton.setBounds(
        60, 110, loginButton.getPreferredSize().width, loginButton.getPreferredSize().height);
    // loginButton.setOpaque(false);
    loginButton.setFocusPainted(false);
    // loginButton.setContentAreaFilled(false);
    // loginButton.setBorderPainted(false);
    loginButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    loginButton.addActionListener(listener);
    logingPanel.add(loginButton);

    add(logingPanel);
  }
Example #16
0
  public void init() {

    areaventana = new JPanel();
    areabotones = new JPanel();
    imagen = new JLabel("");
    presentacion = new JButton(imgPlay);
    siguiente = new JButton(imgSiguiente);
    atras = new JButton(imgAnterior);
    ptiempo = new JSlider();
    carpeta = new JButton(imgNuevaCarpeta);
    grid = new JButton(imgGrid);
    bcomentario = new JButton(imgComentario);
    zoom = new JButton(imgZoom);

    /* Agregando los componentes */

    areaventana.add(imagen);
    // areaventana.add(desplazamiento);

    areabotones.add(grid);
    areabotones.add(atras);
    areabotones.add(presentacion);
    areabotones.add(siguiente);
    areabotones.add(ptiempo);
    areabotones.add(carpeta);
    areabotones.add(bcomentario);
    areabotones.add(zoom);

    areabotones.setBackground(colorGris);
    areaventana.setBackground(colorGris);

    // desplazamiento.setVisible(false);
    // areaventana.add(desplazamiento);

    /* GUI GUI GUI GUI  */
    presentacion.setBackground(colorGris);
    atras.setBackground(colorGris);
    siguiente.setBackground(colorGris);
    carpeta.setBackground(colorGris);
    grid.setBackground(colorGris);
    ptiempo.setBackground(colorGris);
    bcomentario.setBackground(colorGris);
    zoom.setBackground(colorGris);

    presentacion.setPreferredSize(new Dimension(100, 80));
    atras.setPreferredSize(new Dimension(100, 80));
    siguiente.setPreferredSize(new Dimension(100, 80));
    carpeta.setPreferredSize(new Dimension(100, 80));
    grid.setPreferredSize(new Dimension(100, 80));
    bcomentario.setPreferredSize(new Dimension(100, 80));
    zoom.setPreferredSize(new Dimension(100, 80));

    grid.setFocusPainted(false);
    atras.setFocusPainted(false);
    siguiente.setFocusPainted(false);
    carpeta.setFocusPainted(false);
    presentacion.setFocusPainted(false);
    bcomentario.setFocusPainted(false);
    zoom.setFocusPainted(false);

    grid.setBorder(null);
    atras.setBorder(null);
    siguiente.setBorder(null);
    carpeta.setBorder(null);
    presentacion.setBorder(null);
    areabotones.setBorder(null);
    areaventana.setBorder(null);
    bcomentario.setBorder(null);
    zoom.setBorder(null);
    /* GUI GUI GUI GUI  */

    /* Action Listeners */
    siguiente.addActionListener(this);
    atras.addActionListener(this);
    presentacion.addActionListener(this);
    carpeta.addActionListener(this);
    grid.addActionListener(this);
    bcomentario.addActionListener(this);
    zoom.addActionListener(this);

    this.setLayout(new BorderLayout());
    add(areaventana, BorderLayout.CENTER);
    add(areabotones, BorderLayout.SOUTH);

    ptiempo.setVisible(false);

    siguiente.setEnabled(false);
    atras.setEnabled(false);
    presentacion.setEnabled(false);
    grid.setEnabled(false);
    bcomentario.setEnabled(false);
    zoom.setEnabled(false);

    /* Abre el selector desde que inicia el programa */

    chooser = new JFileChooser();
    chooser.setDialogTitle("Selecciona una imagen...");
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    // Abrir archivo es de acá...
    returnChooser = chooser.showOpenDialog(ArcViewer.this);

    if (returnChooser == 0) {

      imagenes = lista.Miranda(chooser, returnChooser);

      siguiente.setEnabled(true);
      atras.setEnabled(true);
      presentacion.setEnabled(true);
      grid.setEnabled(true);
      bcomentario.setEnabled(true);
      zoom.setEnabled(true);

      for (int asd1 = 0; asd1 < imagenes.size(); asd1++) {
        imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0));
      }

      String getImgSelected = chooser.getSelectedFile().getPath();

      for (int index = 0; index < imagenesbean.size(); index++) {
        if (getImgSelected.equals(imagenesbean.get(index).getIcon())) {
          imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
          indexaux = index;
        }
      }
    } else {
      System.out.println("No Selection");
      carpeta.setEnabled(true);
    }

    // for (int asd1=0; asd1 < imagenes.size(); asd1++) {
    // 	imagenesbean.add(new ImagenBean(imagenes.get(asd1),0,0));
    // }
    // String getImgSelected = chooser.getSelectedFile().getPath();
    // for (int index=0; index < imagenesbean.size(); index++) {
    // 	if (getImgSelected.equals( imagenesbean.get(index).getIcon() )) {
    // 		imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon()));
    // 		indexaux = index;
    // 	}
    // }

  }
  /**
   * Creates and return an instance of JButton that can be used to collapse the right component in
   * the metal split pane.
   */
  protected JButton createRightOneTouchButton() {
    JButton b =
        new JButton() {
          // Sprite buffer for the arrow image of the right button
          int[][] buffer = {
            {2, 2, 2, 2, 2, 2, 2, 2},
            {0, 1, 1, 1, 1, 1, 1, 3},
            {0, 0, 1, 1, 1, 1, 3, 0},
            {0, 0, 0, 1, 1, 3, 0, 0},
            {0, 0, 0, 0, 3, 0, 0, 0}
          };

          public void setBorder(Border border) {}

          public void paint(Graphics g) {
            JSplitPane splitPane = getSplitPaneFromSuper();
            if (splitPane != null) {
              int oneTouchSize = getOneTouchSizeFromSuper();
              int orientation = getOrientationFromSuper();
              int blockSize = Math.min(getDividerSize(), oneTouchSize);

              // Initialize the color array
              Color[] colors = {
                this.getBackground(),
                MetalLookAndFeel.getPrimaryControlDarkShadow(),
                MetalLookAndFeel.getPrimaryControlInfo(),
                MetalLookAndFeel.getPrimaryControlHighlight()
              };

              // Fill the background first ...
              g.setColor(this.getBackground());
              if (isOpaque()) {
                g.fillRect(0, 0, this.getWidth(), this.getHeight());
              }

              // ... then draw the arrow.
              if (getModel().isPressed()) {
                // Adjust color mapping for pressed button state
                colors[1] = colors[2];
              }
              if (orientation == JSplitPane.VERTICAL_SPLIT) {
                // Draw the image for a vertical split
                for (int i = 1; i <= buffer[0].length; i++) {
                  for (int j = 1; j < blockSize; j++) {
                    if (buffer[j - 1][i - 1] == 0) {
                      continue;
                    } else {
                      g.setColor(colors[buffer[j - 1][i - 1]]);
                    }
                    g.drawLine(i, j, i, j);
                  }
                }
              } else {
                // Draw the image for a horizontal split
                // by simply swaping the i and j axis.
                // Except the drawLine() call this code is
                // identical to the code block above. This was done
                // in order to remove the additional orientation
                // check for each pixel.
                for (int i = 1; i <= buffer[0].length; i++) {
                  for (int j = 1; j < blockSize; j++) {
                    if (buffer[j - 1][i - 1] == 0) {
                      // Nothing needs
                      // to be drawn
                      continue;
                    } else {
                      // Set the color from the
                      // color map
                      g.setColor(colors[buffer[j - 1][i - 1]]);
                    }
                    // Draw a pixel
                    g.drawLine(j, i, j, i);
                  }
                }
              }
            }
          }

          // Don't want the button to participate in focus traversable.
          public boolean isFocusTraversable() {
            return false;
          }
        };
    b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    b.setFocusPainted(false);
    b.setBorderPainted(false);
    b.setRequestFocusEnabled(false);
    maybeMakeButtonOpaque(b);
    return b;
  }
  /** This method is called from within the constructor to initialize the form. */
  public void initComponents() {

    /** **************** The components ********************************* */
    firstPanel = new JPanel();
    firstPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 2));
    // If put to False: we see the container's background
    firstPanel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    firstPanel.setLayout(new GridLayout(4, 2, 3, 3));
    this.setLayout(new GridLayout(2, 1, 3, 3));
    this.add(firstPanel);

    proxyStackNameLabel = new JLabel("Proxy stack name:");
    proxyStackNameLabel.setToolTipText("The name of the stack to set");
    // Alignment of the text
    proxyStackNameLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    proxyStackNameLabel.setForeground(Color.black);
    // Size of the text
    proxyStackNameLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    proxyStackNameLabel.setOpaque(true);
    proxyStackNameLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    proxyStackNameLabel.setBorder(ProxyLauncher.labelBorder);
    proxyStackNameTextField = new JTextField(20);
    proxyStackNameTextField.setHorizontalAlignment(AbstractButton.CENTER);
    proxyStackNameTextField.setFont(new Font("Dialog", 0, 14));
    proxyStackNameTextField.setBackground(ProxyLauncher.textBackGroundColor);
    proxyStackNameTextField.setForeground(Color.black);
    proxyStackNameTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(proxyStackNameLabel);
    firstPanel.add(proxyStackNameTextField);

    proxyIPAddressLabel = new JLabel("Proxy IP address:");
    proxyIPAddressLabel.setToolTipText("The address of the proxy to set");
    // Alignment of the text
    proxyIPAddressLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    proxyIPAddressLabel.setForeground(Color.black);
    // Size of the text
    proxyIPAddressLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    proxyIPAddressLabel.setOpaque(true);
    proxyIPAddressLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    proxyIPAddressLabel.setBorder(ProxyLauncher.labelBorder);
    proxyIPAddressTextField = new JTextField(20);
    proxyIPAddressTextField.setHorizontalAlignment(AbstractButton.CENTER);
    proxyIPAddressTextField.setFont(new Font("Dialog", 0, 14));
    proxyIPAddressTextField.setBackground(ProxyLauncher.textBackGroundColor);
    proxyIPAddressTextField.setForeground(Color.black);
    proxyIPAddressTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(proxyIPAddressLabel);
    firstPanel.add(proxyIPAddressTextField);

    outboundProxyLabel = new JLabel("Next hop (IP:port/protocol):");
    outboundProxyLabel.setToolTipText(
        "Location where the message will be sent "
            + "if all the resolutions (DNS, router,...) fail. If not set: 404 will be replied");
    // Alignment of the text
    outboundProxyLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    outboundProxyLabel.setForeground(Color.black);
    // Size of the text
    outboundProxyLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    outboundProxyLabel.setOpaque(true);
    outboundProxyLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    outboundProxyLabel.setBorder(ProxyLauncher.labelBorder);
    outboundProxyTextField = new JTextField(20);
    outboundProxyTextField.setHorizontalAlignment(AbstractButton.CENTER);
    outboundProxyTextField.setFont(new Font("Dialog", 0, 14));
    outboundProxyTextField.setBackground(ProxyLauncher.textBackGroundColor);
    outboundProxyTextField.setForeground(Color.black);
    outboundProxyTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(outboundProxyLabel);
    firstPanel.add(outboundProxyTextField);

    routerClassLabel = new JLabel("The Router class name:");
    routerClassLabel.setToolTipText(
        "The class name (full java package name) of the router" + " used to forward the messages");
    // Alignment of the text
    routerClassLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    routerClassLabel.setForeground(Color.black);
    // Size of the text
    routerClassLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    routerClassLabel.setOpaque(true);
    routerClassLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    routerClassLabel.setBorder(ProxyLauncher.labelBorder);
    routerClassTextField = new JTextField(20);
    routerClassTextField.setHorizontalAlignment(AbstractButton.CENTER);
    routerClassTextField.setFont(new Font("Dialog", 0, 12));
    routerClassTextField.setBackground(ProxyLauncher.textBackGroundColor);
    routerClassTextField.setForeground(Color.black);
    routerClassTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(routerClassLabel);
    firstPanel.add(routerClassTextField);

    JPanel panel = new JPanel();
    // top, left, bottom, right
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 2));
    // If put to False: we see the container's background
    panel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    panel.setLayout(new BorderLayout());
    this.add(panel);

    JLabel lpLabel = new JLabel("Listening points list:");
    lpLabel.setVisible(true);
    lpLabel.setToolTipText("The listening points of the proxy");
    lpLabel.setHorizontalAlignment(AbstractButton.CENTER);
    lpLabel.setForeground(Color.black);
    lpLabel.setFont(new Font("Dialog", 1, 12));
    lpLabel.setOpaque(true);
    lpLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    lpLabel.setBorder(ProxyLauncher.labelBorder);
    panel.add(lpLabel, BorderLayout.NORTH);

    // this.add(listeningPointsList);
    JScrollPane scrollPane =
        new JScrollPane(
            listeningPointsList,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    panel.add(scrollPane, BorderLayout.CENTER);

    thirdPanel = new JPanel();
    thirdPanel.setOpaque(false);
    // top, left, bottom, right
    thirdPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 5, 0));
    thirdPanel.setLayout(new GridLayout(1, 2, 3, 3));

    JButton addLPButton = new JButton(" Add ");
    addLPButton.setToolTipText("Add a listening point");
    addLPButton.setFocusPainted(false);
    addLPButton.setFont(new Font("Dialog", 1, 16));
    addLPButton.setBackground(ProxyLauncher.buttonBackGroundColor);
    addLPButton.setBorder(ProxyLauncher.buttonBorder);
    addLPButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            addLPButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(addLPButton);

    JButton removeLPButton = new JButton(" Remove ");
    removeLPButton.setToolTipText("Remove a listening point");
    removeLPButton.setFocusPainted(false);
    removeLPButton.setFont(new Font("Dialog", 1, 16));
    removeLPButton.setBackground(ProxyLauncher.buttonBackGroundColor);
    removeLPButton.setBorder(ProxyLauncher.buttonBorder);
    removeLPButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            removeLPButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(removeLPButton);

    panel.add(thirdPanel, BorderLayout.SOUTH);
  }
  /** Class constructor - make the JFrame ready */
  public TestProgram() {
    // Set screen size
    Toolkit tk = Toolkit.getDefaultToolkit();
    int x = (int) tk.getScreenSize().getWidth() - 150;
    int y = (int) tk.getScreenSize().getHeight() - 100;
    this.setSize(x, y);

    // Some settings
    this.setTitle("Friends With Benefits - Test program");
    field = new Field();
    random = new Random(System.currentTimeMillis());

    // Set the panel
    c = this.getContentPane();
    c.setLayout(new BorderLayout());

    contentpanel = new ContentPanel();
    contentpanel.setField(field);
    c.add(contentpanel, BorderLayout.CENTER);

    // Menupanel
    menupanel = new JPanel();
    layout = new GroupLayout(menupanel);
    menupanel.setLayout(layout);
    c.add(menupanel, BorderLayout.EAST);

    progress = new JProgressBar(0, 99);
    progress.setValue(99);

    open = new JButton("Open");
    open.setFocusPainted(false);
    save = new JButton("Save");
    save.setFocusPainted(false);
    open.addActionListener(this);
    save.addActionListener(this);

    everywhere = new JRadioButton("Everywhere");
    everywhere.setFocusPainted(false);
    inRectangle = new JRadioButton("In bounding rectangle");
    inRectangle.setFocusPainted(false);
    inRectangle.setSelected(true);

    placeOfCluster = new ButtonGroup();
    placeOfCluster.add(everywhere);
    placeOfCluster.add(inRectangle);

    addnoise = new JButton("Add noise");
    addnoise.setFocusPainted(false);
    addnoise.addActionListener(this);

    circle = new JRadioButton("Circle");
    circle.setFocusPainted(false);
    square = new JRadioButton("Square");
    square.setFocusPainted(false);
    circle.setSelected(true);

    squarecircle = new ButtonGroup();
    squarecircle.add(circle);
    squarecircle.add(square);

    fillFactor = new JSlider();
    fillFactor.setMajorTickSpacing(20);
    fillFactor.setMinorTickSpacing(5);
    fillFactor.setPaintTicks(true);

    addacluster = new JButton("Add simple cluster");
    addacluster.setFocusPainted(false);
    addacluster.addActionListener(this);

    clear = new JButton("Clear field");
    clear.addActionListener(this);
    clear.setFocusPainted(false);

    center = new JButton("Center field");
    center.addActionListener(this);
    center.setFocusPainted(false);

    minAlgo = new JTextField();
    minAlgo.setText("0");
    maxAlgo = new JTextField();
    maxAlgo.setText("10");
    run = new JButton("Run algo");
    run.addActionListener(this);
    run.setFocusPainted(false);

    empty = new JPanel();
    empty.setLayout(new BorderLayout());

    JSeparator sep1 = new JSeparator();
    JSeparator sep2 = new JSeparator();
    JSeparator sep3 = new JSeparator();
    JSeparator sep4 = new JSeparator();
    JLabel runalgo = new JLabel("Run algorithm"), addcluster = new JLabel("Add simple cluster");
    JLabel addNoise = new JLabel("Add noise"), fillf = new JLabel("Fill factor:");
    JLabel minalgo = new JLabel("Min:"), maxalgo = new JLabel("Max:");
    addcluster.setFont(f);
    addNoise.setFont(f);
    runalgo.setFont(f);

    fillFactor.setPreferredSize(
        new Dimension(
            menupanel.getPreferredSize().width / 2, fillFactor.getPreferredSize().height));

    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.CENTER)
            .addGroup(
                layout.createSequentialGroup().addComponent(open).addGap(2).addComponent(save))
            .addComponent(sep1)
            .addComponent(addNoise)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(everywhere)
                    .addComponent(inRectangle))
            .addComponent(addnoise)
            .addComponent(sep2)
            .addComponent(addcluster)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(circle)
                    .addComponent(square))
            .addComponent(fillf)
            .addComponent(fillFactor)
            .addComponent(addacluster)
            .addComponent(sep3)
            .addComponent(center)
            .addComponent(clear)
            .addComponent(sep4)
            .addComponent(runalgo)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(minalgo)
                    .addGap(2)
                    .addComponent(minAlgo)
                    .addGap(10)
                    .addComponent(maxalgo)
                    .addGap(2)
                    .addComponent(maxAlgo))
            .addComponent(run)
            .addComponent(empty)
            .addComponent(progress));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(open)
                    .addComponent(save))
            .addGap(5)
            .addComponent(sep1)
            .addGap(5)
            .addComponent(addNoise)
            .addComponent(everywhere)
            .addComponent(inRectangle)
            .addGap(3)
            .addComponent(addnoise)
            .addGap(5)
            .addComponent(sep2)
            .addGap(5)
            .addComponent(addcluster)
            .addComponent(circle)
            .addComponent(square)
            .addGap(3)
            .addComponent(fillf)
            .addGap(3)
            .addComponent(fillFactor)
            .addGap(3)
            .addComponent(addacluster)
            .addGap(5)
            .addComponent(sep3)
            .addGap(5)
            .addComponent(center)
            .addGap(3)
            .addComponent(clear)
            .addGap(5)
            .addComponent(sep4)
            .addGap(5)
            .addComponent(runalgo)
            .addGap(3)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(minalgo)
                    .addComponent(minAlgo)
                    .addComponent(maxalgo)
                    .addComponent(maxAlgo))
            .addComponent(run)
            .addComponent(empty)
            .addComponent(progress));

    int width = menupanel.getPreferredSize().width;

    setSize(addNoise, width - 10);
    setSize(everywhere, width - 20);
    setSize(inRectangle, width - 20);
    setSize(addnoise, width);

    setSize(addcluster, width - 10);
    setSize(circle, width - 20);
    setSize(square, width - 20);
    setSize(addacluster, width);

    setSize(center, width);
    setSize(clear, width);

    setSize(runalgo, width - 10);
    setSize(minalgo, (int) Math.floor(width / 4) - 20);
    setMaxSize(minAlgo, (int) Math.ceil(width / 4));
    setSize(maxalgo, (int) Math.floor(width / 4) - 20);
    setMaxSize(maxAlgo, (int) Math.ceil(width / 4));
    setSize(run, width);

    empty.setPreferredSize(new Dimension(width, 1000));

    menupanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.BLACK),
            "Menu",
            TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION,
            f));
  }
Example #20
0
  public MainForm() {
    GUIStandartOperations.FrameStartOperations(this);
    setSize(960, 610);
    setLocationRelativeTo(null);
    setLayout(null);

    addMouseListener(
        new MouseAdapter() {
          public void mouseReleased(MouseEvent e) {
            mouseDownCompCoords = null;
          }

          public void mousePressed(MouseEvent e) {
            mouseDownCompCoords = e.getPoint();
          }
        });

    addMouseMotionListener(
        new MouseAdapter() {
          public void mouseDragged(MouseEvent e) {
            Point currCoords = e.getLocationOnScreen();
            setLocation(currCoords.x - mouseDownCompCoords.x, currCoords.y - mouseDownCompCoords.y);
          }
        });

    dialogPanelArrayList = new ArrayList<>();
    dialogTabArrayList = new ArrayList<>();

    bigPanel = new JPanel(null);
    bigPanel.setSize(1300, 600);
    bigPanel.setOpaque(false);
    bigPanel.setBackground(new Color(0, 0, 0, 0));

    dialogTabsPanel = new JPanel(null);
    dialogTabsPanel.setBackground(new Color(0, 0, 0, 150));

    JPanel topPanel = new JPanel(null);
    topPanel.setBackground(new Color(0, 0, 0, 150));
    topPanel.setBounds(30, 20, 900, 65);
    topPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.WHITE));
    bigPanel.add(topPanel);

    notificationPanel = new NotificationPanel();
    notificationPanel.setBounds(5, 0, 500, 65);
    notificationPanel.setBorder(null);
    topPanel.add(notificationPanel);

    RepaintPanel repaintPanel = new RepaintPanel(notificationPanel);
    Thread thread = new Thread(repaintPanel);
    thread.start();

    RepaintPanel repaintPanel2 = new RepaintPanel(bigPanel);
    Thread thread2 = new Thread(repaintPanel2);
    thread2.start();

    changeAccButton =
        GUIStandartOperations.ButtonStartOperations(
            changeAccButIcon, changeAccButIconEntered, true);
    settingsButton =
        GUIStandartOperations.ButtonStartOperations(settingsButIcon, settingsButIconEntered, true);
    contactsButton =
        GUIStandartOperations.ButtonStartOperations(contactsButIcon, contactsButIconEntered, true);
    exitButton = GUIStandartOperations.ButtonStartOperations(exitButIcon, exitButIconEntered, true);
    plusButton = GUIStandartOperations.ButtonStartOperations(plusButIcon, plusButIconEntered, true);
    homeButton =
        GUIStandartOperations.ButtonStartOperations(dialogButIcon, dialogButIconEntered, true);

    changeAccButton.setToolTipText("Change account");
    settingsButton.setToolTipText("Your personal settings");
    contactsButton.setToolTipText("Contacts");
    exitButton.setToolTipText("Exit ChatApp");
    homeButton.setToolTipText("Dialog page / Home");

    friendPanelButton = new JButton();
    friendPanelButton.setOpaque(false);
    friendPanelButton.setBorder(null);
    friendPanelButton.setFocusPainted(false);
    friendPanelButton.setContentAreaFilled(false);
    friendPanelButton.setIcon(friendSideOpenIcon);
    friendPanelButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {
            friendPanelButton.setIcon(friendSideOpenIconEntered);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            friendPanelButton.setIcon(friendSideOpenIcon);
          }
        });

    friendPanelButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            isFriendPanelOpened = !isFriendPanelOpened;
            friendPanelMode();
          }
        });

    friendSidePanel = new FriendSidePanel();
    friendSidePanel.setBorder(null);
    friendSidePanel.setBounds(970, 50, 450, 650);
    bigPanel.add(friendSidePanel);

    noConversationsPanel = new JPanel(null);
    noConversationsPanel.setOpaque(false);
    noConversationsPanel.setBackground(new Color(0, 0, 0, 0));
    noConversationsPanel.setBounds(0, 0, 960, 600);
    JLabel noConversationLabel = new JLabel("You have no active conversations now...");
    noConversationLabel.setFont(Fonts.nickFont);
    noConversationLabel.setHorizontalAlignment(SwingConstants.CENTER);
    noConversationLabel.setForeground(Color.WHITE);
    noConversationLabel.setBackground(new Color(0, 0, 0, 0));
    noConversationLabel.setBounds(0, 300, 960, 50);

    JButton noConversationsButton = GUIStandartOperations.ButtonStartOperations(null, null, false);
    noConversationsButton.setText("<HTML><U>It's time to begin, isn't it?</U></HTML>");
    noConversationsButton.setFont(Fonts.nickFont);
    noConversationsButton.setBounds(0, 350, 960, 50);
    noConversationsButton.setHorizontalAlignment(SwingConstants.CENTER);
    noConversationsButton.setForeground(Color.RED);
    noConversationsButton.addActionListener(
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            isFriendPanelOpened = true;
            friendPanelMode();
          }
        });

    noConversationsPanel.add(noConversationsButton);
    noConversationsPanel.add(noConversationLabel);
    noConversationsPanel.setVisible(false);

    final int shiftRight = 90;

    changeAccButton.setBounds(420 + shiftRight, 6, 64, 64);
    topPanel.add(changeAccButton);
    homeButton.setBounds(550 + shiftRight, 6, 64, 64);
    topPanel.add(homeButton);
    settingsButton.setBounds(650 + shiftRight, 0, 64, 64);
    topPanel.add(settingsButton);
    contactsButton.setBounds(600 + shiftRight, 0, 64, 64);
    topPanel.add(contactsButton);
    exitButton.setBounds(470 + shiftRight, 0, 64, 64);
    topPanel.add(exitButton);
    friendPanelButton.setBounds(730 + shiftRight, 6, 64, 64);
    topPanel.add(friendPanelButton);

    friendPanelButton.setVisible(false);

    homePanel = new HomePanel();
    homePanel.setBounds(0, 84, 960, 1000);

    dialogTabsPanel.setBounds(30, 100, 900, 40);
    dialogTabsPanel.setVisible(false);

    bigPanel.add(dialogTabsPanel);
    bigPanel.add(homePanel);
    bigPanel.add(noConversationsPanel);

    this.add(bigPanel);

    exitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
  }
Example #21
0
  /**
   * Create a SubProj2DClickDialog instance
   *
   * @param frame the frame containing the dialog
   * @param level the index of current level
   * @param modal the modal option for the dialog
   * @param plots the plot panel for each sub-cluster
   * @param pointsNum the required number of click pointers for each sub-cluster
   */
  public SubProj2DClickDialog(
      JFrame frame, int level, boolean modal, Plot2DViewer plots[], int pointsNum[]) {
    super(frame, "Level " + level + " Cluster Centers Selection", modal);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Container content = getContentPane();
    numClusters = plots.length;
    totalNum = numClusters;
    numPoints = pointsNum;
    cluster2DCenters = new double[numClusters][2];

    String labelText =
        "<html>Instruction: Left click to select the centers of clusters for each sub-window."
            + "<P>"
            + "When all finished, click the <b>DONE</b> button to continue.</html>";
    instructionsLabel = new JLabel(labelText);
    instructionsLabel.setForeground(java.awt.Color.magenta);

    JPanel buttonPanel = new JPanel();
    doneButton = new JButton("DONE");
    doneButton.setActionCommand("done-command");
    doneButton.setSize(90, 30);
    doneButton.setPreferredSize(new Dimension(90, 30));
    doneButton.setFocusPainted(false);
    buttonPanel.add(doneButton);
    doneButton.addActionListener(new EventListener());

    subPlots = new Proj2DClickPanel[numClusters];
    for (int i = 0; i < numClusters; i++) {
      String subTitle;
      subTitle = "Level_" + level + "_SubCluster_" + (i + 1) + " Plot";
      subPlots[i] = new Proj2DClickPanel(subTitle, plots[i], numPoints[i]);
    }

    // layout
    int rowNum = numClusters / 2;
    int remain = numClusters % 2;
    if (remain > 0) {
      rowNum += 1;
    }

    JPanel plotArea = new JPanel((new GridLayout(rowNum, 2)));
    for (int i = 0; i < numClusters; i++) {
      plotArea.add(subPlots[i]);
    }
    JScrollPane plotScrollPane =
        new JScrollPane(
            plotArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    plotScrollPane.setPreferredSize(new Dimension(800, 600));

    content.setLayout(new GridBagLayout());
    GBA gba = new GBA();
    gba.add(
        content, plotScrollPane, 0, 0, 3, 2, 1, 1, GBA.B, GBA.C, (new Insets(5, 5, 5, 5)), 0, 0);
    gba.add(
        content, instructionsLabel, 0, 2, 2, 1, 1, 0, GBA.H, GBA.C, (new Insets(5, 5, 5, 5)), 0, 0);
    gba.add(content, buttonPanel, 2, 2, 1, 1, 1, 0, GBA.H, GBA.C, (new Insets(5, 5, 5, 5)), 40, 0);
    // content.add(plotArea, BorderLayout.NORTH);
    // content.add(instructionsLabel, BorderLayout.CENTER);
    // content.add(buttonPanel, BorderLayout.SOUTH);

    pack();
    setVisible(true);
  }
Example #22
0
  public GUI() {

    // Frame
    frame = new JFrame("HardwareSwap Notifier");

    // Panels
    panel = new JPanel();
    group1 = new JPanel();
    group2 = new JPanel();
    group3 = new JPanel();
    group4 = new JPanel();
    group5 = new JPanel();
    group6 = new JPanel();
    group7 = new JPanel();
    group8 = new JPanel();

    // Menu Bar
    menus = new JMenuBar();
    fileMenu = new JMenu("File");
    clearCurrent = new JMenuItem("Clear");
    quitItem = new JMenuItem("Quit");
    load = new JMenuItem("Load");
    saveCurrent = new JMenuItem("Save All");
    clearSaved = new JMenuItem("Clear Saved");
    removeItem = new JMenuItem("Remove Item");
    removePhone = new JMenuItem("Remove Phone");
    saveCurrent = new JMenuItem("Save Current");
    helpMenu = new JMenu("Help");
    help = new JMenuItem("How To Use");
    about = new JMenuItem("About");

    // Buttons
    add1 = new JButton("Add");
    add2 = new JButton("Add");
    start = new JButton("Start");
    stop = new JButton("Stop");
    save1 = new JButton("Add/Save");
    save2 = new JButton("Add/Save");
    show = new JButton("Display Data");

    add1.setFocusPainted(false);
    add2.setFocusPainted(false);
    start.setFocusPainted(false);
    stop.setFocusPainted(false);
    save1.setFocusPainted(false);
    save2.setFocusPainted(false);
    show.setFocusPainted(false);

    stop.setEnabled(false);

    // CheckBox
    remove = new JCheckBox("Remove items when found");
    remove.setFocusable(false);

    // Listener
    ButtonListener listener = new ButtonListener();

    add1.addActionListener(listener);
    add2.addActionListener(listener);
    start.addActionListener(listener);
    stop.addActionListener(listener);
    load.addActionListener(listener);
    save1.addActionListener(listener);
    save2.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    show.addActionListener(listener);
    quitItem.addActionListener(listener);
    clearCurrent.addActionListener(listener);
    clearSaved.addActionListener(listener);
    saveCurrent.addActionListener(listener);
    help.addActionListener(listener);
    about.addActionListener(listener);
    removePhone.addActionListener(listener);
    removeItem.addActionListener(listener);
    remove.addActionListener(listener);

    // Carrier Selection
    options = new String[10];
    options[0] = "AT&T";
    options[1] = "Boost Mobile";
    options[2] = "Cellular One";
    options[3] = "Nextel";
    options[4] = "T-Mobile";
    options[5] = "Tracfone";
    options[6] = "US Cellular";
    options[7] = "Sprint";
    options[8] = "Verizon";
    options[9] = "Virgin Mobile";

    carriers = new JComboBox<String>(options);

    // Text Fields
    searchName = new JTextField(15);
    item = new JTextField(15);
    phone = new JTextField(15);
    interval2 = new JTextField(15);
    results = new JTextArea(10, 20);

    JScrollPane scrollPane = new JScrollPane(results);

    results.setEditable(false);

    // Interval
    intOptions = new SpinnerNumberModel(5, 1, 60, 1);
    interval = new JSpinner(intOptions);
    JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField();
    tf.setHorizontalAlignment(JFormattedTextField.LEFT);

    // Background
    panelBackground = new Color(237, 237, 237);

    panel.setBackground(panelBackground);
    searchName.setBackground(panelBackground);
    item.setBackground(panelBackground);
    phone.setBackground(panelBackground);
    interval.setBackground(panelBackground);

    // Panel Layouts
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS));
    group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS));
    group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS));
    group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS));
    group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS));
    group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS));
    group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS));
    group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS));

    // Borders
    searchName.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Search Name",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    item.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Item",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    phone.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Cell Phone",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));
    group5.setBorder(
        BorderFactory.createTitledBorder(
            null,
            "Check Interval (mins)",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_JUSTIFICATION,
            null,
            Color.DARK_GRAY));

    // Sizes
    panel.setPreferredSize(new Dimension(200, 0));
    searchName.setMaximumSize(new Dimension(190, 50));
    item.setMaximumSize(new Dimension(190, 50));
    phone.setMaximumSize(new Dimension(185, 50));
    carriers.setMaximumSize(new Dimension(175, 20));
    group5.setPreferredSize(new Dimension(190, 47));
    group5.setMaximumSize(new Dimension(190, 47));

    add1.setMaximumSize(new Dimension(90, 20));
    save1.setMaximumSize(new Dimension(90, 20));
    add2.setMaximumSize(new Dimension(90, 20));
    save2.setMaximumSize(new Dimension(90, 20));
    start.setMaximumSize(new Dimension(90, 20));
    stop.setMaximumSize(new Dimension(90, 20));
    show.setMaximumSize(new Dimension(120, 20));

    // Add file menu items
    fileMenu.add(clearCurrent);
    fileMenu.add(clearSaved);
    fileMenu.add(load);
    fileMenu.add(removeItem);
    fileMenu.add(removePhone);
    fileMenu.add(saveCurrent);
    fileMenu.add(quitItem);

    // Add help menu items
    helpMenu.add(help);
    helpMenu.add(about);

    // Add to menu bar
    menus.add(fileMenu);
    menus.add(helpMenu);

    // Add items to panel
    group1.add(searchName);
    group1.add(item);

    group2.add(add1);
    group2.add(Box.createHorizontalStrut(10));
    group2.add(save1);

    group6.add(remove);

    group3.add(phone);
    group3.add(Box.createVerticalStrut(10));
    group3.add(carriers);

    group4.add(add2);
    group4.add(Box.createHorizontalStrut(10));
    group4.add(save2);

    group5.add(interval);

    group7.add(show);

    group8.add(start);
    group8.add(Box.createHorizontalStrut(10));
    group8.add(stop);

    panel.add(Box.createVerticalStrut(10));
    panel.add(group1);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group2);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group3);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group4);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group5);
    panel.add(Box.createVerticalStrut(30));
    panel.add(group6);
    panel.add(Box.createVerticalStrut(40));
    panel.add(group7);
    panel.add(Box.createVerticalStrut(10));
    panel.add(group8);
    panel.add(Box.createVerticalStrut(10));

    // Setup frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menus);
    frame.add(scrollPane);
    frame.add(BorderLayout.EAST, panel);
    frame.pack();
    frame.setSize(new Dimension(670, 620));
    frame.setVisible(true);
  }
  /** This method is called from within the constructor to initialize the form. */
  public void initComponents() {
    /** *************** The main frame ************************************** */
    // width, height
    this.setSize(560, 370);
    Container container = this.getContentPane();
    container.setLayout(new BoxLayout(getContentPane(), 1));
    container.setBackground(containerBackGroundColor);
    this.setLocation(0, 0);
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            new AlertInstantMessaging(
                "Your changes will not be checked: use the Submit button!!!",
                JOptionPane.WARNING_MESSAGE);
            hideFrame();
          }
        });

    /** **************** The components ********************************* */
    firstPanel = new JPanel();
    firstPanel.setBorder(BorderFactory.createEmptyBorder(15, 4, 15, 4));
    // If put to False: we see the container's background
    firstPanel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    firstPanel.setLayout(new GridLayout(11, 2, 2, 2));
    container.add(firstPanel);

    outboundProxyAddressLabel = new JLabel("Outbound proxy IP address:");
    outboundProxyAddressLabel.setForeground(Color.black);
    outboundProxyAddressTextField = new JTextField(20);
    outboundProxyAddressLabel.setBorder(labelBorder);
    outboundProxyAddressLabel.setOpaque(true);
    outboundProxyAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outboundProxyAddressLabel);
    firstPanel.add(outboundProxyAddressTextField);

    outboundProxyPortLabel = new JLabel("Outbound proxy port:");
    outboundProxyPortLabel.setForeground(Color.black);
    outboundProxyPortTextField = new JTextField(20);
    outboundProxyPortLabel.setBorder(labelBorder);
    outboundProxyPortLabel.setOpaque(true);
    outboundProxyPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outboundProxyPortLabel);
    firstPanel.add(outboundProxyPortTextField);

    registrarAddressLabel = new JLabel("Registrar IP address:");
    registrarAddressLabel.setForeground(Color.black);
    registrarAddressTextField = new JTextField(20);
    registrarAddressLabel.setBorder(labelBorder);
    registrarAddressLabel.setOpaque(true);
    registrarAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(registrarAddressLabel);
    firstPanel.add(registrarAddressTextField);

    registrarPortLabel = new JLabel("Registrar port:");
    registrarPortLabel.setForeground(Color.black);
    registrarPortTextField = new JTextField(20);
    registrarPortLabel.setBorder(labelBorder);
    registrarPortLabel.setOpaque(true);
    registrarPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(registrarPortLabel);
    firstPanel.add(registrarPortTextField);

    imAddressLabel = new JLabel("Contact IP address:");
    imAddressLabel.setForeground(Color.black);
    imAddressTextField = new JTextField(20);
    imAddressLabel.setBorder(labelBorder);
    imAddressLabel.setOpaque(true);
    imAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imAddressLabel);
    firstPanel.add(imAddressTextField);

    imPortLabel = new JLabel("Contact port:");
    imPortLabel.setForeground(Color.black);
    imPortTextField = new JTextField(20);
    imPortLabel.setBorder(labelBorder);
    imPortLabel.setOpaque(true);
    imPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imPortLabel);
    firstPanel.add(imPortTextField);

    imProtocolLabel = new JLabel("Contact transport:");
    imProtocolLabel.setForeground(Color.black);
    imProtocolTextField = new JTextField(20);
    imProtocolLabel.setBorder(labelBorder);
    imProtocolLabel.setOpaque(true);
    imProtocolLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imProtocolLabel);
    firstPanel.add(imProtocolTextField);

    outputFileLabel = new JLabel("Output file:");
    outputFileLabel.setForeground(Color.black);
    outputFileTextField = new JTextField(20);
    outputFileLabel.setBorder(labelBorder);
    outputFileLabel.setOpaque(true);
    outputFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outputFileLabel);
    firstPanel.add(outputFileTextField);

    buddiesFileLabel = new JLabel("Buddies file:");
    buddiesFileLabel.setForeground(Color.black);
    buddiesFileTextField = new JTextField(20);
    buddiesFileLabel.setBorder(labelBorder);
    buddiesFileLabel.setOpaque(true);
    buddiesFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(buddiesFileLabel);
    firstPanel.add(buddiesFileTextField);

    authenticationFileLabel = new JLabel("Authentication file:");
    authenticationFileLabel.setForeground(Color.black);
    authenticationFileTextField = new JTextField(20);
    authenticationFileLabel.setBorder(labelBorder);
    authenticationFileLabel.setOpaque(true);
    authenticationFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(authenticationFileLabel);
    firstPanel.add(authenticationFileTextField);

    defaultRouterLabel = new JLabel("Default router class name:");
    defaultRouterLabel.setForeground(Color.black);
    defaultRouterTextField = new JTextField(20);
    defaultRouterLabel.setBorder(labelBorder);
    defaultRouterLabel.setOpaque(true);
    defaultRouterLabel.setBackground(labelBackGroundColor);
    firstPanel.add(defaultRouterLabel);
    firstPanel.add(defaultRouterTextField);

    thirdPanel = new JPanel();
    thirdPanel.setOpaque(false);
    // top, left, bottom, right
    thirdPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

    submitButton = new JButton(" Submit ");
    submitButton.setToolTipText("Submit your changes!");
    submitButton.setFocusPainted(false);
    submitButton.setFont(new Font("Dialog", 1, 16));
    submitButton.setBackground(buttonBackGroundColor);
    submitButton.setBorder(buttonBorder);
    submitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            submitButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(submitButton);
    container.add(thirdPanel);
  }
  private JPanel adminPanel() {
    FormLayout layout1 =
        new FormLayout(
            "152px, 120px, 35px,120px, 35px, 120px, 152px",
            "60px, 90px,  35px, 90px, 35px, 90px, 59px");

    adminPanel = new JPanel(layout1);
    // adminPanel = new FormDebugPanel(layout1);
    CellConstraints cc = new CellConstraints();
    JLabel labell = new JLabel("Wyloguj");
    labell.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent me) {
            CardLayout c1 = (CardLayout) (utworzPanel.getLayout());
            c1.show(utworzPanel, "card1");
            tx1.setText("");
            tx2.setText("");
          }
        });
    adminPanel.setPreferredSize(new Dimension(800, 500));
    Color c = new Color(153, 180, 209);
    adminPanel.setBackground(c);
    Color c2 = new Color(105, 105, 105);
    buttonAdmin1 = new JButton("Drużyny");
    buttonAdmin1.addActionListener(this);
    buttonAdmin2 = new JButton("Piłkarze");
    buttonAdmin2.addActionListener(this);
    buttonAdmin3 = new JButton("Gole");
    buttonAdmin3.addActionListener(this);
    buttonAdmin4 = new JButton("Kartki");
    buttonAdmin4.addActionListener(this);
    buttonAdmin5 = new JButton("Obecność");
    buttonAdmin5.addActionListener(this);
    buttonAdmin6 = new JButton("Sędziowie");
    buttonAdmin6.addActionListener(this);
    buttonAdmin7 = new JButton("Spotkania");
    buttonAdmin7.addActionListener(this);
    buttonAdmin8 = new JButton("Trenerzy");
    buttonAdmin8.addActionListener(this);
    buttonAdmin9 = new JButton("Zmiany");
    buttonAdmin9.addActionListener(this);
    Border br = BorderFactory.createEmptyBorder();
    buttonAdmin1.setBorder(br);
    buttonAdmin2.setBorder(br);
    buttonAdmin3.setBorder(br);
    buttonAdmin4.setBorder(br);
    buttonAdmin5.setBorder(br);
    buttonAdmin6.setBorder(br);
    buttonAdmin7.setBorder(br);
    buttonAdmin8.setBorder(br);
    buttonAdmin9.setBorder(br);
    buttonAdmin1.setFocusPainted(false);
    buttonAdmin2.setFocusPainted(false);
    buttonAdmin3.setFocusPainted(false);
    buttonAdmin4.setFocusPainted(false);
    buttonAdmin5.setFocusPainted(false);
    buttonAdmin6.setFocusPainted(false);
    buttonAdmin7.setFocusPainted(false);
    buttonAdmin8.setFocusPainted(false);
    buttonAdmin9.setFocusPainted(false);

    adminPanel.add(labell, cc.xy(7, 1, CellConstraints.RIGHT, CellConstraints.TOP));
    adminPanel.add(buttonAdmin1, cc.xy(2, 2, CellConstraints.FILL, CellConstraints.FILL));
    adminPanel.add(buttonAdmin2, cc.xy(4, 2, CellConstraints.FILL, CellConstraints.FILL));
    adminPanel.add(buttonAdmin3, cc.xy(6, 2, CellConstraints.FILL, CellConstraints.FILL));
    adminPanel.add(buttonAdmin4, cc.xy(2, 4, CellConstraints.FILL, CellConstraints.FILL));
    adminPanel.add(buttonAdmin5, cc.xy(4, 4, CellConstraints.FILL, CellConstraints.FILL));
    adminPanel.add(buttonAdmin6, cc.xy(6, 4, CellConstraints.FILL, CellConstraints.FILL));
    adminPanel.add(buttonAdmin9, cc.xy(2, 6, CellConstraints.FILL, CellConstraints.FILL));
    adminPanel.add(buttonAdmin8, cc.xy(4, 6, CellConstraints.FILL, CellConstraints.FILL));
    adminPanel.add(buttonAdmin7, cc.xy(6, 6, CellConstraints.FILL, CellConstraints.FILL));

    return adminPanel;
  }
Example #25
0
  public Viajes() {
    super.setBounds(181, 61, 700, 538); // (ancho,alto)
    super.setLayout(null);
    super.setOpaque(false);
    super.setVisible(false);

    try {
      UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    tbDatos = new JTable(dataModel);
    tbDatos.setEnabled(false);
    tbDatos.setAutoResizeMode(5);
    tbDatos.setCellSelectionEnabled(true);
    tbDatos.setForeground(Color.BLACK);
    pnDatos = new JScrollPane(tbDatos);
    pnDatos.setBounds(30, 30, 640, 478);
    pnDatos.setVisible(false);
    this.add(pnDatos);
    llenarDatos();

    jlbCodigo = new JLabel("*Código");
    jlbCodigo.setBounds(90, 100, 220, 25);
    jlbCodigo.setForeground(Color.BLACK);
    jlbCodigo.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbCodigo);

    jtxtCodigo = new JTextField("");
    jtxtCodigo.setBounds(90, 125, 520, 30);
    jtxtCodigo.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    jtxtCodigo.addKeyListener(this);
    this.add(jtxtCodigo);

    jlbOrigen = new JLabel("*Origen");
    jlbOrigen.setBounds(90, 180, 150, 25);
    jlbOrigen.setForeground(Color.BLACK);
    jlbOrigen.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbOrigen);

    jcbOrigen = new JComboBox();
    jcbOrigen.setBorder(null);
    jcbOrigen.setBackground(Color.WHITE);
    jcbOrigen.addItem("Medellín");
    jcbOrigen.addItem("Bogotá");
    jcbOrigen.addItem("Barranquilla");
    jcbOrigen.setBounds(90, 205, 250, 30);
    this.add(jcbOrigen);

    jlbDestino = new JLabel("*Destino");
    jlbDestino.setBounds(360, 180, 150, 25);
    jlbDestino.setForeground(Color.BLACK);
    jlbDestino.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbDestino);

    jcbDestino = new JComboBox();
    jcbDestino.setBorder(null);
    jcbDestino.setBackground(Color.WHITE);
    jcbDestino.addItem("Bogotá");
    jcbDestino.addItem("Medellín");
    jcbDestino.addItem("Barranquilla");
    jcbDestino.setBounds(360, 205, 250, 30);
    this.add(jcbDestino);

    jlbPrecio = new JLabel("*Precio");
    jlbPrecio.setBounds(90, 260, 120, 25);
    jlbPrecio.setForeground(Color.BLACK);
    jlbPrecio.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbPrecio);

    jtxtPrecio = new JTextField("");
    jtxtPrecio.setBounds(90, 285, 520, 30);
    jtxtPrecio.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
    jtxtPrecio.addKeyListener(this);
    this.add(jtxtPrecio);

    jlbEstado = new JLabel("*Estado");
    jlbEstado.setBounds(90, 340, 150, 25);
    jlbEstado.setForeground(Color.BLACK);
    jlbEstado.setFont(new Font("Segoe UI", Font.PLAIN, 18));
    this.add(jlbEstado);

    jcbEstado = new JComboBox();
    jcbEstado.setBorder(null);
    jcbEstado.setBackground(Color.WHITE);
    jcbEstado.addItem("Activo");
    jcbEstado.addItem("Inactivo");
    jcbEstado.setBounds(90, 365, 520, 30);
    this.add(jcbEstado);

    jbtnListar = new JButton(" Lista");
    jbtnListar.setBounds(0, 0, 233, 60);
    jbtnListar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/List-26.png")));
    jbtnListar.setBorder(null);
    jbtnListar.setBackground(new Color(0, 154, 225));
    jbtnListar.setForeground(Color.WHITE);
    jbtnListar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnListar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnListar.addMouseListener(this);
    jbtnListar.addActionListener(this);
    jbtnListar.setFocusPainted(false);
    this.add(jbtnListar);

    jbtnBuscar = new JButton(" Buscar");
    jbtnBuscar.setBounds(233, 0, 234, 60);
    jbtnBuscar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Search-26.png")));
    jbtnBuscar.setBorder(null);
    jbtnBuscar.setBackground(new Color(0, 154, 225));
    jbtnBuscar.setForeground(Color.WHITE);
    jbtnBuscar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnBuscar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnBuscar.addMouseListener(this);
    jbtnBuscar.addActionListener(this);
    jbtnBuscar.setFocusPainted(false);
    this.add(jbtnBuscar);

    jbtnActualizar = new JButton(" Actualizar");
    jbtnActualizar.setBounds(233, 0, 234, 60);
    jbtnActualizar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Edit-26.png")));
    jbtnActualizar.setBorder(null);
    jbtnActualizar.setBackground(new Color(0, 154, 225));
    jbtnActualizar.setForeground(Color.WHITE);
    jbtnActualizar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnActualizar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnActualizar.addMouseListener(this);
    jbtnActualizar.setVisible(false);
    jbtnActualizar.addActionListener(this);
    jbtnActualizar.setFocusPainted(false);
    this.add(jbtnActualizar);

    jbtnLimpiar = new JButton(" Limpiar");
    jbtnLimpiar.setBounds(467, 0, 233, 60);
    jbtnLimpiar.setIcon(new ImageIcon(getClass().getResource("/Imagenes/icons/Clean-26.png")));
    jbtnLimpiar.setBorder(null);
    jbtnLimpiar.setBackground(new Color(0, 154, 225));
    jbtnLimpiar.setForeground(Color.WHITE);
    jbtnLimpiar.setFont(new Font("Segoe UI", Font.PLAIN, 20));
    jbtnLimpiar.setCursor(new Cursor(java.awt.Cursor.HAND_CURSOR));
    jbtnLimpiar.addMouseListener(this);
    jbtnLimpiar.addActionListener(this);
    jbtnLimpiar.setFocusPainted(false);
    this.add(jbtnLimpiar);

    jpBotones = new JPanel();
    jpBotones.setBackground(new Color(0, 123, 183));
    jpBotones.add(jbtnListar);
    jpBotones.add(jbtnBuscar);
    jpBotones.add(jbtnActualizar);
    jpBotones.add(jbtnLimpiar);
    jpBotones.setLayout(null);
    jpBotones.setBounds(0, 478, 700, 60);
    this.add(jpBotones);

    jlbValidar = new JLabel("Los campos con (*) son obligatorios");
    jlbValidar.setForeground(Color.WHITE);
    jlbValidar.setBounds(80, 8, 300, 27);
    jlbValidar.setFont(new Font("Segoe UI", Font.PLAIN, 17));
    this.add(jlbValidar);

    jpError = new JPanel();
    jpError.add(jlbValidar);
    jpError.setLayout(null);
    jpError.setBackground(new Color(0, 123, 183));
    jpError.setBounds(0, 0, 700, 45);
    this.add(jpError);

    this.repaint();
  }
  public IllegalMovePopUp() {

    setTitle("THIS IS ILLEGAL");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    setBackground(Color.WHITE);

    JPanel center = new JPanel();
    center.setBackground(color);
    center.setLayout(new GridBagLayout());

    JLabel cross = new JLabel(image);
    cross.setBackground(color);
    center.add(cross);
    cross.setBorder(new EmptyBorder(10, 10, 0, 10));
    cross.setHorizontalAlignment(JLabel.CENTER);
    cross.setVerticalAlignment(JLabel.CENTER);

    JPanel doubleColumn = new JPanel();
    doubleColumn.setBackground(color);
    doubleColumn.setLayout(new GridLayout(2, 1));
    center.add(doubleColumn);

    JLabel invalid = new JLabel("invalid move ");
    invalid.setBackground(color);
    invalid.setForeground(Color.WHITE);
    invalid.setFont(new Font("Georgia", Font.BOLD, 30));
    doubleColumn.add(invalid);
    invalid.setHorizontalAlignment(JLabel.CENTER);
    invalid.setVerticalAlignment(JLabel.CENTER);

    JLabel tryAgain = new JLabel("Try Again!");
    tryAgain.setBackground(color);
    tryAgain.setForeground(Color.WHITE);
    tryAgain.setFont(new Font("Courier New", Font.PLAIN, 20));
    doubleColumn.add(tryAgain);
    tryAgain.setHorizontalAlignment(JLabel.CENTER);
    tryAgain.setVerticalAlignment(JLabel.CENTER);

    JPanel south = new JPanel();
    south.setBackground(color);

    JPanel forTheButton = new JPanel();
    forTheButton.setBackground(color);

    JButton OK = new JButton("OK");
    OK.setBorderPainted(false);
    OK.setFocusPainted(false);
    OK.setBackground(Color.BLACK);
    OK.setForeground(Color.WHITE);

    OK.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            dispose();
          }
        });

    forTheButton.add(OK);
    south.add(forTheButton);

    add(center, BorderLayout.CENTER);
    add(south, BorderLayout.SOUTH);

    pack();
    setSize(450, 200);
    setVisible(true);
    setAlwaysOnTop(true);
    setLocationRelativeTo(null);
  }
Example #27
0
  /**
   * The class constructor.
   *
   * @param owner the GuiKeyboardInstance class instance
   * @param space plugin dimension
   */
  public GUI(final ButtonGridInstance owner, final Dimension space) {
    this.owner = owner;

    final JButton buttons[] = new JButton[owner.NUMBER_OF_KEYS];
    panel = new JPanel();

    setLayout(new BorderLayout());

    int labelHeight;

    if (owner.getCaption().length() > 0) {
      JLabel label = new JLabel(owner.getCaption(), 0);
      add(label, BorderLayout.NORTH);
      labelHeight = (int) getPreferredSize().getHeight();
    } else {
      labelHeight = 0;
    }

    for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
      buttons[i] = new JButton();
      String caption = owner.getButtonCaption(i);
      buttons[i].setText(caption);
      if ("".equalsIgnoreCase(caption)) {
        buttons[i].setEnabled(false);
        buttons[i].setVisible(false);
      } else {
        numberOfKeys = numberOfKeys + 1;
        buttons[i].setEnabled(true);
        buttons[i].setVisible(true);

        final JButton b = buttons[i];

        // final Border raisedBevelBorder = BorderFactory.createRaisedBevelBorder();
        // final Insets insets = raisedBevelBorder.getBorderInsets(buttons[i]);
        // final EmptyBorder emptyBorder = new EmptyBorder(insets);
        // b.setBorder(emptyBorder);
        // b.setOpaque(false);
        // b.setContentAreaFilled(false);

        if (owner.propBorderColor != USE_DEFAULT_COLOR)
          b.setBorder(
              BorderFactory.createLineBorder(
                  getColorProperty(owner.propBorderColor), owner.propBorderThickness));

        b.setFocusPainted(false);
        if (!("".equalsIgnoreCase(owner.getToolTip(i)))) b.setToolTipText(owner.getToolTip(i));

        if (owner.propBackgroundColor != USE_DEFAULT_COLOR)
          b.setBackground(getColorProperty(owner.propBackgroundColor));

        if (owner.propTextColor != USE_DEFAULT_COLOR)
          b.setForeground(getColorProperty(owner.propTextColor));

        if (owner.propSelectionFrameColor != USE_DEFAULT_COLOR) {
          b.getModel()
              .addChangeListener(
                  new ChangeListener() {
                    @Override
                    public void stateChanged(ChangeEvent e) {
                      ButtonModel model = (ButtonModel) e.getSource();
                      if (model.isRollover()) {
                        // b.setBorder(raisedBevelBorder);
                        b.setBorder(
                            BorderFactory.createLineBorder(
                                getColorProperty(owner.propSelectionFrameColor),
                                owner.propSelectionFrameThickness));
                      } else {
                        // b.setBorder(emptyBorder);
                        b.setBorder(
                            BorderFactory.createLineBorder(
                                getColorProperty(owner.propBorderColor),
                                owner.propBorderThickness));
                      }
                    }
                  });
        }
      }

      final int y = i;

      buttons[i].addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (colSav == null) colSav = buttons[y].getBackground();
              if (owner.propSelectionFrameColor == USE_DEFAULT_COLOR)
                buttons[y].setBackground(Color.RED);
              else buttons[y].setBackground(getColorProperty(owner.propSelectionFrameColor));
              owner.etpKeyArray[y].raiseEvent();

              AstericsThreadPool.instance.execute(
                  new Runnable() {
                    public void run() {
                      try {
                        Thread.sleep(250);
                        buttons[y].setBackground(colSav);
                      } catch (InterruptedException e) {
                      }
                    }
                  });
            }
          });
    }

    if (numberOfKeys > 0) {

      Dimension buttonDimension;
      Dimension panelDimension;

      if (owner.propHorizontalOrientation == true) {
        buttonDimension = new Dimension(space.width / numberOfKeys, ((space.height - labelHeight)));

        panelDimension =
            new Dimension(numberOfKeys * buttonDimension.width, buttonDimension.height);
      } else {
        buttonDimension = new Dimension(space.width, ((space.height - labelHeight) / numberOfKeys));

        panelDimension = new Dimension(space.width, numberOfKeys * buttonDimension.height);
      }

      panel.setMaximumSize(panelDimension);
      panel.setPreferredSize(panelDimension);
      panel.setMinimumSize(panelDimension);
      panel.setVisible(true);

      if (owner.propHorizontalOrientation == true) {
        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
      } else {
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
      }

      for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
        buttons[i].setPreferredSize(buttonDimension);
        buttons[i].setMinimumSize(buttonDimension);
        buttons[i].setMaximumSize(buttonDimension);
        // panel.add(buttons[i]);
      }

      float maxFontSize = fontSizeMax;
      float maxFontSizeTable[] = new float[owner.NUMBER_OF_KEYS];

      Rectangle buttonRectangle = new Rectangle();

      for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
        float fontSize = 0;
        boolean finish = false;
        maxFontSizeTable[i] = 0;
        if (owner.getButtonCaption(i).length() > 0) {
          do {

            fontSize = fontSize + fontIncrementStep;

            buttons[i].setMargin(new Insets(2, 2, 2, 2));

            Font font = buttons[i].getFont();
            font = font.deriveFont(fontSize);
            FontMetrics fontMetrics = buttons[i].getFontMetrics(font);
            Rectangle2D tmpFontSize =
                fontMetrics.getStringBounds(owner.getButtonCaption(i), buttons[i].getGraphics());

            Insets insets = buttons[i].getMargin();

            double height = tmpFontSize.getHeight();
            double width = tmpFontSize.getWidth();
            double buttonHeightSpace =
                buttonDimension.getHeight()
                    - (double) insets.bottom
                    - (double) insets.top
                    - verticalOffset;
            double buttonWidthSpace =
                buttonDimension.getWidth()
                    - (double) insets.left
                    - (double) insets.right
                    - horizontalOffset;

            if ((height >= buttonHeightSpace) || (width >= buttonWidthSpace)) {
              finish = true;
              maxFontSizeTable[i] = fontSize - 1;
            } else {

              if (fontSize > fontSizeMax) {
                finish = true;
                maxFontSizeTable[i] = fontSize;
              }
            }

          } while (!finish);
        }
      }

      for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
        if ((maxFontSizeTable[i] > 0) && (maxFontSizeTable[i] < maxFontSize)) {
          maxFontSize = maxFontSizeTable[i];
        }
      }

      for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
        Font font = buttons[i].getFont();
        font = font.deriveFont(maxFontSize);
        buttons[i].setFont(font);
      }
    }

    for (int i = 0; i < owner.NUMBER_OF_KEYS; i++) {
      panel.add(buttons[i]);
    }

    add(panel, BorderLayout.CENTER);
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
  }