public CustomIconDemo() {
    Icon leftButtonIcon = new ArrowIcon(SwingConstants.RIGHT);
    Icon middleButtonIcon = createImageIcon("images/middle.gif", "the middle button");
    Icon rightButtonIcon = new ArrowIcon(SwingConstants.LEFT);

    b1 = new JButton("Disable middle button", leftButtonIcon);
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING);
    b1.setMnemonic(KeyEvent.VK_D);
    b1.setActionCommand("disable");

    b2 = new JButton("Middle button", middleButtonIcon);
    b2.setVerticalTextPosition(AbstractButton.BOTTOM);
    b2.setHorizontalTextPosition(AbstractButton.CENTER);
    b2.setMnemonic(KeyEvent.VK_M);

    b3 = new JButton("Enable middle button", rightButtonIcon);
    // Use the default text position of CENTER, TRAILING (RIGHT).
    b3.setMnemonic(KeyEvent.VK_E);
    b3.setActionCommand("enable");
    b3.setEnabled(false);

    // Listen for actions on buttons 1 and 3.
    b1.addActionListener(this);
    b3.addActionListener(this);

    b1.setToolTipText("Click this button to disable the middle button.");
    b2.setToolTipText("This middle button does nothing when you click it.");
    b3.setToolTipText("Click this button to enable the middle button.");

    // Add Components to this container, using the default FlowLayout.
    add(b1);
    add(b2);
    add(b3);
  }
예제 #2
0
  public ButtonDemo() {
    ImageIcon leftButtonIcon = new ImageIcon("src/images/right.png");
    ImageIcon middleButtonIcon = new ImageIcon("src/images/middle.png");
    ImageIcon rightButtonIcon = new ImageIcon("src/images/left.png");

    b1 = new JButton("가운데 버튼은 사용 불가", leftButtonIcon);
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for left-to-right locales
    b1.setMnemonic(KeyEvent.VK_D);
    b1.setActionCommand("disable");

    b2 = new JButton("Middle button", middleButtonIcon);
    b2.setVerticalTextPosition(AbstractButton.BOTTOM);
    b2.setHorizontalTextPosition(AbstractButton.CENTER);
    b2.setMnemonic(KeyEvent.VK_M);

    b3 = new JButton("Enable middle button", rightButtonIcon);
    // Use the default text position of CENTER, TRAILING (RIGHT).
    b3.setMnemonic(KeyEvent.VK_E);
    b3.setActionCommand("enable");
    b3.setEnabled(false);

    // Listen for actions on buttons 1 and 3.
    b1.addActionListener(this);
    b3.addActionListener(this);

    b1.setToolTipText("Click this button to disable the middle button.");
    b2.setToolTipText("This middle button does nothing when you click it.");
    b3.setToolTipText("Click this button to enable the middle button.");

    // Add Components to this container, using the default FlowLayout.
    add(b1);
    add(b2);
    add(b3);
  }
예제 #3
0
  private void setupToolBar() // {{{
      {
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setName("listToolbar"); // NOI18N
    toolbar.setPreferredSize(new java.awt.Dimension(100, 18));

    btnPrev.setIcon(resourceMap.getIcon("btnPrev.icon")); // NOI18N
    btnPrev.setText(resourceMap.getString("btnPrev.text")); // NOI18N
    btnPrev.setToolTipText(resourceMap.getString("btnPrev.toolTipText")); // NOI18N
    btnPrev.setFocusable(false);
    btnPrev.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnPrev.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnPrev.setName("btnPrev"); // NOI18N
    btnPrev.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    toolbar.add(btnPrev);

    jSeparator3.setMaximumSize(new java.awt.Dimension(1000, 10));
    jSeparator3.setName("jSeparator3"); // NOI18N
    toolbar.add(jSeparator3);

    btnAddList.setAction(actionMap.get("addNewList"));
    btnAddList.setText(resourceMap.getString("btnAddList.text"));
    btnAddList.setIcon(resourceMap.getIcon("btnAddList.icon"));
    btnAddList.setToolTipText(resourceMap.getString("btnAddList.toolTipText"));
    btnAddList.setMargin(new java.awt.Insets(2, 2, 2, 2));
    toolbar.add(btnAddList);

    btnDeleteList.setAction(actionMap.get("deleteList"));
    btnDeleteList.setText(resourceMap.getString("btnDeleteList.text"));
    btnDeleteList.setIcon(resourceMap.getIcon("btnDeleteList.icon"));
    btnDeleteList.setToolTipText(resourceMap.getString("btnDeleteList.toolTipText"));
    btnDeleteList.setMargin(new java.awt.Insets(2, 2, 2, 2));
    toolbar.add(btnDeleteList);

    separatorRight.setMaximumSize(new java.awt.Dimension(1000, 10));
    separatorRight.setName("separatorRight"); // NOI18N
    toolbar.add(separatorRight);

    btnNext.setIcon(resourceMap.getIcon("btnNext.icon")); // NOI18N
    btnNext.setToolTipText(resourceMap.getString("btnNext.toolTipText")); // NOI18N
    btnNext.setFocusable(false);
    btnNext.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    btnNext.setLabel(resourceMap.getString("btnNext.label")); // NOI18N
    btnNext.setMargin(new java.awt.Insets(2, 2, 2, 2));
    btnNext.setName("btnNext"); // NOI18N
    btnNext.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    toolbar.add(btnNext);
  } // }}}
  public DriverUserInterface(
      String userName,
      String password,
      JPanel graphicPanel,
      LoginUserInterface loginUserInterface) {
    this.driver = (Driver) driverService.login(userName, password);
    this.graphicPanel = graphicPanel;
    this.loginUserInterface = loginUserInterface;

    WindowUtilities.setNativeLookAndFeel();

    reportLocationButton = new JButton("اعلام موقعیت", new ImageIcon("img/reportloc.png"));
    reportLocationButton.setVerticalTextPosition(AbstractButton.BOTTOM);
    reportLocationButton.setHorizontalTextPosition(AbstractButton.CENTER);
    reportLocationButton.setActionCommand("reportloc");
    reportLocationButton.addActionListener(this);

    loadShipmentButton = new JButton("بارگذاری", new ImageIcon("img/load.png"));
    loadShipmentButton.setVerticalTextPosition(AbstractButton.BOTTOM);
    loadShipmentButton.setHorizontalTextPosition(AbstractButton.CENTER);
    loadShipmentButton.setActionCommand("loadShipment");
    loadShipmentButton.addActionListener(this);

    mainMenuButton = new JButton(new ImageIcon("img/home.png"));
    mainMenuButton.setActionCommand("mainmenu");
    mainMenuButton.addActionListener(this);

    refreshButton = new JButton(new ImageIcon("img/refresh.png"));
    refreshButton.setActionCommand("update");
    refreshButton.addActionListener(this);

    logoutButton = new JButton(new ImageIcon("img/logout.png"));
    logoutButton.setActionCommand("logout");
    logoutButton.addActionListener(this);

    reportButton = new JButton("اعلام");
    reportButton.setActionCommand("report");
    reportButton.addActionListener(this);

    pickupButton = new JButton("بارگذاری");
    pickupButton.setActionCommand("pickup");
    pickupButton.addActionListener(this);

    title = new JLabel("در سیستم به نام " + driver.getUsername());
    title.setFont(new Font("sansserif", Font.PLAIN, 24));
    title.setForeground(new Color(0.85f, 0.0f, 0.0f));

    this.update("main");
  }
예제 #5
0
 /**
  * This method initializes jButtonSands
  *
  * @return javax.swing.JButton
  */
 private JButton getJButtonSands() {
   if (jButtonSands == null) {
     jButtonSands = new JButton();
     jButtonSands.setIcon(
         new ImageIcon(LobbySuite.class.getResource("/simplytech/image/SandsSuite.jpg")));
     jButtonSands.setVerticalAlignment(SwingConstants.BOTTOM);
     jButtonSands.setVerticalTextPosition(SwingConstants.BOTTOM);
     jButtonSands.setText("Sands Suite");
     jButtonSands.setPreferredSize(new Dimension(200, 200));
     jButtonSands.setHorizontalTextPosition(SwingConstants.CENTER);
     jButtonSands.setBackground(new Color(91, 155, 213));
     jButtonSands.setBounds(new Rectangle(565, 100, 161, 151));
     jButtonSands.setFont(new Font("Arial", Font.BOLD, 12));
     jButtonSands.addActionListener(
         new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent e) {
             JPanel panel = new SandsSuite(myFrame);
             myFrame.getContentPane().removeAll();
             myFrame.getContentPane().add(panel);
             myFrame.getContentPane().validate();
             myFrame.getContentPane().repaint();
           }
         });
   }
   return jButtonSands;
 }
  private JButton createExampleButton(final CommonApp commonApp) {
    String iconResource = commonApp.getIconResource();
    Icon icon =
        iconResource == null
            ? new EmptyIcon()
            : new ImageIcon(getClass().getResource(iconResource));
    JButton button =
        new JButton(
            new AbstractAction(commonApp.getName(), icon) {
              public void actionPerformed(ActionEvent e) {
                commonApp.init(OptaPlannerExamplesApp.this, false);
              }
            });
    button.setHorizontalAlignment(JButton.LEFT);
    button.setHorizontalTextPosition(JButton.RIGHT);
    button.setVerticalTextPosition(JButton.CENTER);
    button.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent e) {
            descriptionTextArea.setText(commonApp.getDescription());
          }

          public void mouseExited(MouseEvent e) {
            descriptionTextArea.setText("");
          }
        });
    return button;
  }
예제 #7
0
 /**
  * This method initializes jButtonPresidential
  *
  * @return javax.swing.JButton
  */
 private JButton getJButtonPresidential() {
   if (jButtonPresidential == null) {
     jButtonPresidential = new JButton();
     jButtonPresidential.setVerticalAlignment(SwingConstants.BOTTOM);
     jButtonPresidential.setVerticalTextPosition(SwingConstants.BOTTOM);
     jButtonPresidential.setLocation(new Point(800, 270));
     jButtonPresidential.setSize(new Dimension(161, 151));
     jButtonPresidential.setIcon(
         new ImageIcon(LobbySuite.class.getResource("/simplytech/image/PresidentialSuite.jpg")));
     jButtonPresidential.setText("Presidential Suite");
     jButtonPresidential.setHorizontalTextPosition(SwingConstants.CENTER);
     jButtonPresidential.setFont(new Font("Arial", Font.BOLD, 12));
     jButtonPresidential.setBackground(new Color(91, 155, 213));
     jButtonPresidential.addActionListener(
         new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent e) {
             JPanel panel = new PresidentialSuite(myFrame);
             myFrame.getContentPane().removeAll();
             myFrame.getContentPane().add(panel);
             myFrame.getContentPane().validate();
             myFrame.getContentPane().repaint();
           }
         });
   }
   return jButtonPresidential;
 }
예제 #8
0
 public JButton createToolButton(String text, String iconPath) {
   // ImageIcon icon = new ImageIcon(Base.getImage(iconPath, this));
   JButton button = new JButton(text); // ,icon);
   button.setVerticalTextPosition(SwingConstants.BOTTOM);
   button.setHorizontalTextPosition(SwingConstants.CENTER);
   return button;
 }
  private JButton createExampleButton(
      final String title, final String description, String iconResource, final Runnable runnable) {
    ImageIcon icon =
        iconResource == null ? null : new ImageIcon(getClass().getResource(iconResource));
    JButton button =
        new JButton(
            new AbstractAction(title, icon) {
              public void actionPerformed(ActionEvent e) {
                runnable.run();
              }
            });
    button.setHorizontalTextPosition(JButton.CENTER);
    button.setVerticalTextPosition(JButton.BOTTOM);
    button.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent e) {
            descriptionTextArea.setText(description);
          }

          public void mouseExited(MouseEvent e) {
            descriptionTextArea.setText("");
          }
        });
    return button;
  }
예제 #10
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;
  }
예제 #11
0
 public void initButton() {
   JButton button = new JButton("Suivant");
   button.setVerticalTextPosition(AbstractButton.CENTER);
   button.setHorizontalTextPosition(AbstractButton.CENTER);
   button.setToolTipText("Continuer au panneau suivant");
   button.addActionListener(e -> nextAction());
   add(button);
 }
  private void mountButtonsPanel() {
    next.setVerticalTextPosition(AbstractButton.CENTER);
    next.setHorizontalTextPosition(AbstractButton.LEADING);
    next.setMnemonic('n');

    prev.setMnemonic('p');

    jumpToBt.setMnemonic('j');
    jumpToBt.setVerticalTextPosition(AbstractButton.CENTER);
    jumpToBt.setHorizontalTextPosition(AbstractButton.LEADING);

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS));
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    buttonsPanel.add(prev);
    prev.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            prevButtonAction();
          }
        });
    Dimension space = new Dimension(5, 0);
    buttonsPanel.add(Box.createRigidArea(space));

    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextButtonAction();
          }
        });
    buttonsPanel.add(next);
    buttonsPanel.add(Box.createRigidArea(space));

    jumpToBt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jumpToButtonAction();
          }
        });

    buttonsPanel.add(jumpToBt);
    jumpToBt.setEnabled(false);

    panel.add(buttonsPanel, BorderLayout.PAGE_START);
  }
예제 #13
0
 private void setupButton(JButton button) {
   button.setOpaque(false);
   button.setContentAreaFilled(false);
   button.setBorderPainted(false);
   button.setForeground(Color.white);
   button.setHorizontalTextPosition(JButton.CENTER);
   button.setVerticalTextPosition(JButton.TOP);
   button.setFont(new Font("Sans Serif", Font.PLAIN, 12));
 }
  private JButton getOKButton() {
    JButton okBtn = new JButton("OK");
    okBtn.setVerticalTextPosition(AbstractButton.CENTER);
    okBtn.setHorizontalTextPosition(AbstractButton.LEADING);
    okBtn.setMnemonic(KeyEvent.VK_ENTER);
    okBtn.setActionCommand("OK");
    okBtn.addActionListener(this);

    return okBtn;
  }
예제 #15
0
 public void setAdditionalProperties() {
   btLogin.setBorder(null);
   btLogin.setOpaque(false);
   btLogin.setContentAreaFilled(false);
   btLogin.setBorderPainted(false);
   btLogin.setCursor(new Cursor(Cursor.HAND_CURSOR));
   btLogin.setVerticalTextPosition(SwingConstants.BOTTOM);
   btLogin.setHorizontalTextPosition(SwingConstants.CENTER);
   btLogin.setPressedIcon(new ImageIcon("files/pix/login.png"));
 }
예제 #16
0
	/** 创建图片按钮的方法 */
	private JButton createImgBtn(String img, String txt) {
		ImageIcon ico = new ImageIcon(this.getClass().getResource(img));
		JButton button = new JButton(txt, ico);
		//button.setIcon(ico);
		//垂直文本对齐位置
		button.setVerticalTextPosition(JButton.BOTTOM);
		//水平文本对齐位置
		button.setHorizontalTextPosition(JButton.CENTER);
		return button;
	}
예제 #17
0
  public Buttons() {

    b1 = new JButton("Yes");
    b1.setVerticalTextPosition(AbstractButton.CENTER);
    b1.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for left-to-right locales
    b1.setMnemonic(KeyEvent.VK_D);
    b1.setActionCommand("disable No");

    b2 = new JButton("No");
    b2.setVerticalTextPosition(AbstractButton.BOTTOM);
    b2.setHorizontalTextPosition(AbstractButton.CENTER);
    b2.setMnemonic(KeyEvent.VK_M);
    b2.setActionCommand("disable Yes");

    b3 = new JButton("Send Vote");
    b3.setMnemonic(KeyEvent.VK_E);
    b3.setActionCommand("disable both");
    b3.setEnabled(false);

    b4 = new JButton("Reset");
    b4.setVerticalTextPosition(AbstractButton.CENTER);
    b4.setHorizontalTextPosition(AbstractButton.LEADING); // aka LEFT, for left-to-right locales
    b4.setMnemonic(KeyEvent.VK_D);
    b4.setActionCommand("reset");

    // Listen for actions on buttons 1 and 3.
    b1.addActionListener(this);
    b2.addActionListener(this);
    b3.addActionListener(this);
    b4.addActionListener(this);

    b1.setToolTipText("Click this button to vote yes.");
    b2.setToolTipText("This middle button to vote no.");
    b3.setToolTipText("Click this button to send votes.");
    b4.setToolTipText("Click this button to reset.");

    // Add Components to this container, using the default FlowLayout.
    add(b1);
    add(b2);
    add(b3);
    add(b4);
  }
예제 #18
0
 public JButton createToolButton(final Tool tool) {
   JButton button = new JButton(tool.getButtonName(), tool.getButtonIcon());
   button.setVerticalTextPosition(SwingConstants.BOTTOM);
   button.setHorizontalTextPosition(SwingConstants.CENTER);
   button.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           setTool(tool);
         }
       });
   return button;
 }
예제 #19
0
  private JPanel createButtonsPanel() {
    List<JButton> buttons = createButtons();

    int colNumber = 3;
    int rows = ((buttons.size() - 1) / colNumber) + 1;
    int cols = Math.min(buttons.size(), colNumber);

    JPanel panel = new JPanel(new GridLayout(rows, cols, 30, 30));
    panel.setOpaque(false);

    for (JButton button : buttons) {
      button.setName("suite." + button.getText());
      button.setHorizontalTextPosition(JButton.CENTER);
      button.setVerticalTextPosition(JButton.BOTTOM);
      button.setFocusable(false);
      panel.add(button);
    }
    return panel;
  }
예제 #20
0
  /**
   * Returns a button with an arrow icon and a collapse/expand action listener.
   *
   * @return button Button which is used in the titled border component
   */
  private JButton createArrowButton() {
    JButton button = new JButton("arrow", iconArrow[COLLAPSED]);
    button.setBorder(BorderFactory.createEmptyBorder(0, 1, 5, 1));
    button.setVerticalTextPosition(AbstractButton.CENTER);
    button.setHorizontalTextPosition(AbstractButton.LEFT);
    button.setMargin(new Insets(0, 0, 3, 0));

    // We want to use the same font as those in the titled border font
    Font font = BorderFactory.createTitledBorder("Sample").getTitleFont();
    Color color = BorderFactory.createTitledBorder("Sample").getTitleColor();
    button.setFont(font);
    button.setForeground(color);
    button.setFocusable(false);
    button.setContentAreaFilled(false);

    button.addActionListener(new CollapsablePanel.ExpandAndCollapseAction());

    return button;
  }
예제 #21
0
  private void initializeComponents() {
    confirmButton = new JButton("Confirm", new ImageIcon("images/buttons/grey_button00.png"));
    confirmButton.setDisabledIcon(new ImageIcon("images/buttons/grey_button01.png"));
    confirmButton.setBorder(BorderFactory.createEmptyBorder());
    confirmButton.setHorizontalTextPosition(JButton.CENTER);
    confirmButton.setVerticalTextPosition(JButton.CENTER);
    confirmButton.setFont(kenVector16);
    confirmButton.setEnabled(false);

    colorLabel = new JLabel("Select your color");
    colorLabel.setFont(kenVector25);

    buttonGroup = new ButtonGroup();
    redButton =
        new CustomButton(
            "Red",
            new ImageIcon("images/buttons/red_button01.png"),
            new ImageIcon("images/buttons/red_button00.png"));
    buttonGroup.add(redButton);

    blueButton =
        new CustomButton(
            "Blue",
            new ImageIcon("images/buttons/blue_button01.png"),
            new ImageIcon("images/buttons/blue_button00.png"));
    buttonGroup.add(blueButton);

    greenButton =
        new CustomButton(
            "Green",
            new ImageIcon("images/buttons/green_button01.png"),
            new ImageIcon("images/buttons/green_button00.png"));
    buttonGroup.add(greenButton);

    yellowButton =
        new CustomButton(
            "Yellow",
            new ImageIcon("images/buttons/yellow_button01.png"),
            new ImageIcon("images/buttons/yellow_button00.png"));
    buttonGroup.add(yellowButton);
  }
예제 #22
0
  /** Créer un pannel avec un bouton capâble de lançer la Proglet */
  private static JPanel createShortcut(
      ImageIcon icon, String name, String title, final Runnable start) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(Box.createVerticalGlue());
    JButton label = new JButton(name, icon);
    // Affichage du titre dans le charset de l'ordinateur
    label.setToolTipText(title);
    label.setPreferredSize(new Dimension(160, 160));
    label.setVerticalTextPosition(JLabel.BOTTOM);
    label.setHorizontalTextPosition(JLabel.CENTER);
    label.setAlignmentX(Component.CENTER_ALIGNMENT);
    label.setAlignmentY(Component.CENTER_ALIGNMENT);
    panel.add(label);
    panel.add(Box.createVerticalGlue());
    label.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            start.run();
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}
        });
    return panel;
  }
예제 #23
0
  // *********************************************CONSTRUCTOR METHOD
  public EPoverty() throws IOException {
    UIManager.put("Button.select", Color.BLACK);

    // ******************************************CREATE MAIN PANEL
    setTitle("|||E-Poverty || V-0.1 (SKELETON)|||");
    setSize(500, 275);
    setLocation(500, 200);
    setVisible(true);
    setResizable(false);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    mainPanel = new JPanel();
    setContentPane(mainPanel);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
    // ******************************************END OF CREATING MAIN PANEL

    /* CREATE THE TOP AND BOTTOM PANELS, ADDING BACKGROUND IMAGES
     *
     * BackgroundPanel is an extension to JPanel that makes it easy to
     * paint images as a background on the panel, or add a gradient
     * fill as the background (this is what you currently see on the
     * back of all the tabs.  The constructors can be seen in the
     * BackgroundPanel.java class if you need or want to use them.
     */
    BackgroundPanel topPanel = new BackgroundPanel(background);
    Dimension top = new Dimension(500, 125);
    topPanel.setPreferredSize(top);
    GradientPaint paintTop = new GradientPaint(0, 0, Color.DARK_GRAY, 100, 100, Color.BLACK);
    topPanel.setPaint(paintTop);

    BackgroundPanel bottomPanel = new BackgroundPanel(null, BackgroundPanel.ACTUAL, 1.0f, 0.5f);
    Dimension bottom = new Dimension(500, 75);
    bottomPanel.setPreferredSize(bottom);
    GradientPaint paintBottom = new GradientPaint(50, 200, Color.WHITE, 100, 50, Color.BLACK);
    bottomPanel.setPaint(paintBottom);

    // *******************************************ADD PANELS TO THE MAIN
    mainPanel.add(topPanel);
    mainPanel.add(bottomPanel);

    // ******************************************ADD COMPONENTS TO THE BOTTOM PANEL
    bottomPanel.setLayout(new GridBagLayout());
    GridBagConstraints gBC = new GridBagConstraints();
    gBC.fill = GridBagConstraints.HORIZONTAL;

    // *****************************************FIRST ROW (BLANK)
    JLabel blank = new JLabel("");
    gBC.weightx = 1;
    gBC.weighty = 1;
    gBC.gridx = 0;
    gBC.gridy = 0;
    bottomPanel.add(blank, gBC);

    blank = new JLabel("");
    gBC.gridx = 1;
    gBC.gridy = 0;
    bottomPanel.add(blank, gBC);

    blank = new JLabel("");
    gBC.gridx = 2;
    gBC.gridy = 0;
    bottomPanel.add(blank, gBC);

    blank = new JLabel("");
    gBC.gridx = 3;
    gBC.gridy = 0;
    bottomPanel.add(blank, gBC);

    blank = new JLabel("");
    gBC.gridx = 4;
    gBC.gridy = 0;
    bottomPanel.add(blank, gBC);

    blank = new JLabel("");
    gBC.gridx = 5;
    gBC.gridy = 0;
    bottomPanel.add(blank, gBC);

    // *****************************************SECOND ROW (LOGIN)
    blank = new JLabel("LOGIN");
    gBC.gridx = 1;
    gBC.gridy = 1;
    gBC.gridheight = 2;
    gBC.gridwidth = 2;
    blank.setForeground(Color.WHITE);
    blank.setFont(new Font("Serif", Font.PLAIN, 16));
    bottomPanel.add(blank, gBC);
    blank.setHorizontalTextPosition(SwingConstants.RIGHT);

    login_TF = new JTextField("*****@*****.**");
    gBC.gridx = 3;
    gBC.gridy = 1;
    login_TF.setEditable(true);
    login_TF.setBackground(Color.WHITE);
    login_TF.setFont(new Font("Serif", Font.PLAIN, 16));
    login_TF.setForeground(Color.LIGHT_GRAY);
    bottomPanel.add(login_TF, gBC);
    login_TF.requestFocusInWindow();

    // ******************************************THIRD ROW (PASSWORD)
    blank = new JLabel("PASSWORD");
    gBC.gridx = 1;
    gBC.gridy = 3;
    blank.setForeground(Color.WHITE);
    blank.setFont(new Font("Serif", Font.PLAIN, 16));
    blank.setHorizontalTextPosition(JLabel.RIGHT);
    bottomPanel.add(blank, gBC);

    password_TF = new JPasswordField("password");
    gBC.gridx = 3;
    gBC.gridy = 3;
    password_TF.setEditable(true);
    password_TF.setForeground(Color.WHITE);
    password_TF.setFont(new Font("Serif", Font.PLAIN, 16));
    bottomPanel.add(password_TF, gBC);

    // *****************************************FOURTH ROW (BLANK)
    blank = new JLabel("");
    gBC.gridx = 1;
    gBC.gridy = 3;
    gBC.gridheight = 1;
    bottomPanel.add(blank, gBC);

    // *****************************************FIFTH ROW (BUTTONS)
    JButton login_BTN = new JButton("");
    gBC.gridx = 3;
    gBC.gridy = 5;
    gBC.gridwidth = 1;
    login_BTN.setIcon(new ImageIcon(login));
    login_BTN.setMargin(new Insets(0, 0, 0, 0));
    login_BTN.setBackground(Color.LIGHT_GRAY);
    login_BTN.setRolloverEnabled(false);
    login_BTN.setFocusPainted(false);
    login_BTN.setContentAreaFilled(false);
    bottomPanel.add(login_BTN, gBC);

    JButton settings_BTN = new JButton("Settings");
    gBC.gridx = 5;
    gBC.gridy = 5;
    gBC.gridheight = 3;
    settings_BTN.setIcon(new ImageIcon(settings));
    settings_BTN.setMargin(new Insets(0, 0, 0, 0));
    settings_BTN.setHorizontalAlignment(SwingConstants.RIGHT);
    settings_BTN.setVerticalTextPosition(SwingConstants.CENTER);
    settings_BTN.setHorizontalTextPosition(SwingConstants.LEFT);
    settings_BTN.setBackground(Color.LIGHT_GRAY);
    settings_BTN.setBorderPainted(false);
    settings_BTN.setRolloverEnabled(false);
    settings_BTN.setFocusPainted(false);
    settings_BTN.setContentAreaFilled(false);
    bottomPanel.add(settings_BTN, gBC);

    // *****************************************SIXTH ROW (BLANK)
    blank = new JLabel("");
    gBC.gridx = 1;
    gBC.gridy = 5;
    bottomPanel.add(blank, gBC);

    // This makes sure all components are painted on the screen correctly
    mainPanel.validate();

    // ADD AN ACTION LISTENER TO THE BUTTON THAT WILL CHECK THE LOGIN INFO AND LOG INTO THE DATABASE
    login_BTN.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String passwordHash = "";
            // Hash the password for comparison
            try {
              passwordHash = SimpleSHA1.SHA1(password_TF.getText());
            } catch (NoSuchAlgorithmException ex) {
              Logger.getLogger(EPoverty.class.getName()).log(Level.SEVERE, null, ex);
            } catch (UnsupportedEncodingException ex) {
              Logger.getLogger(EPoverty.class.getName()).log(Level.SEVERE, null, ex);
            }

            String checkAdminSQL =
                "SELECT p.password FROM persons AS p, admins AS a "
                    + "WHERE p.personId = a.personId "
                    + "AND p.emailAddress = \""
                    + login_TF.getText()
                    + "\" ";

            try {
              // *********************************CHECK LOGIN AND PASSWORD
              new DBconnection(url, driver, dbLogin, dbPassword);
              conn = DBconnection.getConnection();
              PreparedStatement stmt = (PreparedStatement) conn.prepareStatement(checkAdminSQL);
              ResultSet rs = (ResultSet) stmt.executeQuery();

              // IF THERE IS NO NEXT RECORD, E-MAIL IS NOT THAT OF AN ADMIN
              if (!rs.next()) {
                new Warnings("You do not have login rights.");
              } else {
                String dbPass = rs.getObject(1).toString();

                // CHECK VALUE OF RETURNED PASSWORD TO VALUE ENTERED
                if (dbPass.equals(passwordHash)) {
                  try {
                    new EPovertyMain();
                    EPovertyMain.updateStatus("Logged in");
                    dispose();

                  } catch (IOException ex) {
                    Logger.getLogger(EPoverty.class.getName()).log(Level.SEVERE, null, ex);
                  }
                } else {
                  new Warnings("Incorrect Password.");
                }
              }

              rs.close();
              stmt.close();
              DBconnection.closeConnection();

            } catch (ClassNotFoundException ex) {
              Logger.getLogger(EPoverty.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
              Logger.getLogger(EPoverty.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        }); // END OF LOGIN BUTTON LISTENER

    settings_BTN.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              new Settings();
            } catch (ClassNotFoundException ex) {
              Logger.getLogger(EPoverty.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        }); // END OF SETTINGS BUTTON LISTENER
  }
    private void initComponents() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      textLayout.putConstraint(SpringLayout.NORTH, fpsField_, 0, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(SpringLayout.NORTH, zPosLabel_, 3, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(
          SpringLayout.NORTH, timeStampLabel_, 3, SpringLayout.NORTH, textPanel);
      textLayout.putConstraint(SpringLayout.NORTH, fpsLabel, 3, SpringLayout.NORTH, textPanel);
    }
예제 #25
0
  public MakeReservation() {
    new BorderLayout();

    standardRoom.setMnemonic(KeyEvent.VK_K);
    standardRoom.setActionCommand("Standard Room");
    standardRoom.setSelected(true);

    familyRoom.setMnemonic(KeyEvent.VK_F);
    familyRoom.setActionCommand("Family Room");

    suiteRoom.setMnemonic(KeyEvent.VK_S);
    suiteRoom.setActionCommand("Suite");

    // Add Booking Button
    ImageIcon bookRoomIcon = createImageIcon("images/book.png");
    bookRoom = new JButton("Book Room", bookRoomIcon);
    bookRoom.setVerticalTextPosition(AbstractButton.BOTTOM);
    bookRoom.setHorizontalTextPosition(AbstractButton.CENTER);
    bookRoom.setMnemonic(KeyEvent.VK_M);
    bookRoom.addActionListener(this);
    bookRoom.setActionCommand("book");

    // Group the radio buttons.
    group.add(standardRoom);
    group.add(familyRoom);
    group.add(suiteRoom);

    // Create the labels.
    nameLabel = new JLabel("Name: ");
    amountroomsLabel = new JLabel("How many rooms? ");
    checkoutdateLabel = new JLabel("Check-Out Date: ");
    checkindateLabel = new JLabel("Check-In Date: ");

    // Create the text fields and set them up.
    nameField = new JFormattedTextField();
    nameField.setColumns(10);

    amountroomsField = new JFormattedTextField(new Integer(1));
    amountroomsField.setValue(new Integer(1));
    amountroomsField.setColumns(10);

    // java.util.Date dt_checkin = new java.util.Date();
    LocalDate today = LocalDate.now();
    // java.text.SimpleDateFormat sdf_checkin = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkin = today.toString();
    checkindateField = new JFormattedTextField(currentDate_checkin);
    checkindateField.setColumns(10);

    // java.util.Date dt_checkout = new java.util.Date();
    LocalDate tomorrow = today.plus(1, ChronoUnit.DAYS);
    // java.text.SimpleDateFormat sdf_checkout = new java.text.SimpleDateFormat("MM/dd/yyyy");
    currentDate_checkout = tomorrow.toString();
    checkoutdateField = new JFormattedTextField(currentDate_checkout);
    checkoutdateField.setColumns(10);

    // Tell accessibility tools about label/textfield pairs.
    nameLabel.setLabelFor(nameField);
    amountroomsLabel.setLabelFor(amountroomsField);
    checkoutdateLabel.setLabelFor(checkoutdateField);
    checkindateLabel.setLabelFor(checkindateField);

    // Lay out the labels in a panel.
    JPanel labelPane1 = new JPanel(new GridLayout(0, 1));

    labelPane1.add(amountroomsLabel);

    JPanel labelPane3 = new JPanel(new GridLayout(0, 1));
    labelPane3.add(checkindateLabel);

    JPanel labelPane2 = new JPanel(new GridLayout(0, 1));
    labelPane2.add(checkoutdateLabel);

    JPanel labelPane4 = new JPanel(new GridLayout(0, 1));
    labelPane4.add(nameLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane1 = new JPanel(new GridLayout(0, 1));
    fieldPane1.add(amountroomsField);

    JPanel fieldPane3 = new JPanel(new GridLayout(0, 1));
    fieldPane3.add(checkindateField);

    JPanel fieldPane2 = new JPanel(new GridLayout(0, 1));
    fieldPane2.add(checkoutdateField);

    JPanel fieldPane4 = new JPanel(new GridLayout(0, 1));
    fieldPane4.add(nameField);

    // Put the radio buttons in a column in a panel.
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(standardRoom);
    radioPanel.add(familyRoom);
    radioPanel.add(suiteRoom);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane1, BorderLayout.LINE_START);
    add(fieldPane1, BorderLayout.LINE_END);
    add(labelPane3, BorderLayout.LINE_START);
    add(fieldPane3, BorderLayout.LINE_END);
    add(labelPane2, BorderLayout.LINE_START);
    add(fieldPane2, BorderLayout.LINE_END);
    add(labelPane4, BorderLayout.LINE_START);
    add(fieldPane4, BorderLayout.LINE_END);

    add(radioPanel, BorderLayout.LINE_END);
    add(bookRoom);
  }
예제 #26
0
  private JButton getAcceptOfferButton(final String nick, CargoOffer co) {
    JButton acceptOfferButton = new JButton();
    acceptOfferButton.setToolTipText("Zaakceptuj ofert\u0119");

    CargoOffersLoadPanel loadPanel = new CargoOffersLoadPanel();
    JPanel renderedPanel = new JPanel();
    loadPanel.render(co, renderedPanel, 0);
    renderedPanel.setOpaque(false);

    CargoOffersUnloadPanel unloadPanel = new CargoOffersUnloadPanel();
    JPanel renderedUnloadPanel = new JPanel();
    unloadPanel.render(co, renderedUnloadPanel, 0);
    renderedUnloadPanel.setOpaque(false);

    CargoOffersSubmissionDatePanel submissionPanel = new CargoOffersSubmissionDatePanel();
    JPanel renderedSubmissionDatePanel = new JPanel();
    submissionPanel.render(co, renderedSubmissionDatePanel, 0);
    renderedSubmissionDatePanel.setOpaque(false);

    renderedSubmissionDatePanel.setOpaque(false);

    acceptOfferButton.setLayout(new FlowLayout());

    acceptOfferButton.add(renderedPanel);
    acceptOfferButton.add(renderedUnloadPanel);
    acceptOfferButton.add(renderedSubmissionDatePanel);

    // dodatki wygladowe tego buttonu
    acceptOfferButton.setBorderPainted(false);
    acceptOfferButton.setContentAreaFilled(false);
    acceptOfferButton.setFocusPainted(false);
    acceptOfferButton.setOpaque(false);
    acceptOfferButton.setVerticalTextPosition(SwingConstants.CENTER);
    acceptOfferButton.setHorizontalTextPosition(SwingConstants.CENTER);
    acceptOfferButton.setIcon(SparkRes.getImageIcon(SparkRes.CARGO_AKCEPTACJA_OFERTY1));
    acceptOfferButton.setRolloverIcon(SparkRes.getImageIcon(SparkRes.CARGO_AKCEPTACJA_OFERTY2));
    acceptOfferButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    // koniec dodatkow

    acceptOfferButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            String initiator = null;
            String initiated = null;

            initiator = SparkManager.getSessionManager().getUsername();
            initiated = nick;

            CargoOffer co = getCargoOffer();
            OfferAcceptance offerAcceptance = new OfferAcceptance();
            offerAcceptance.setInitiator(initiator);
            offerAcceptance.setInitiated(initiated);
            offerAcceptance.setOfferId(co.getId());
            CargoDataManager.getInstance().initiateOfferAcceptance(initiator, initiated, co);
          }
        });

    return acceptOfferButton;
  }
예제 #27
0
  public FrameMain(final People loggedUser) {

    setSize(940, 680);
    setTitle("Planning System");
    setLocationRelativeTo(null);
    // setResizable(false);
    setLayout(new BorderLayout());
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);

    // MENU Project
    menuNewProject.setText("New Project");
    menuNewProject.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            OpenPanelNew(loggedUser);
          }
        });
    menuEditProject.setText("Edit Project");
    menuEditProject.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            OpenPanelEdit(loggedUser, null);
          }
        });
    menuListProject.setText("Projects List");
    menuListProject.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            getContentPane().removeAll();
            PanelProjectList fmListProjects = new PanelProjectList(loggedUser);
            getContentPane().add(fmListProjects);
            getContentPane().validate();
            getContentPane().repaint();
          }
        });
    menuTeamProject.setText("Project Teams");
    menuTeamProject.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            getContentPane().removeAll();
            PanelProjectTeam fmTeamProjects = new PanelProjectTeam(loggedUser);
            getContentPane().add(fmTeamProjects);
            getContentPane().validate();
            getContentPane().repaint();
          }
        });
    menuProject.setText("Project");
    menuProject.add(menuNewProject);
    menuProject.add(menuEditProject);
    menuProject.add(menuListProject);
    menuProject.add(menuTeamProject);

    // Menu People
    menuManagePeople.setText("Manage Employees");
    menuManagePeople.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            getContentPane().removeAll();
            PanelManagePeople fmManagePeople = new PanelManagePeople();
            getContentPane().add(fmManagePeople);
            getContentPane().validate();
            getContentPane().repaint();
          }
        });
    menuPeople.setText("Employee");
    menuPeople.add(menuManagePeople);
    // Menu Plan
    menuPlan.setText("Planning");
    menuNewPlan.setText("New Plan");
    menuNewPlan.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            getContentPane().removeAll();
            PanelScheduleNew fmPlanNew = new PanelScheduleNew(loggedUser);
            getContentPane().add(fmPlanNew);
            getContentPane().validate();
            getContentPane().repaint();
          }
        });
    menuPlan.add(menuNewPlan);

    // Menu File
    menuMain.setText("Home");
    menuMain.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            getContentPane().removeAll();
            getContentPane().add(panel);
            getContentPane().validate();
            getContentPane().repaint();
            RefreshIcons(loggedUser);
          }
        });
    menuClose.setText("Close");
    menuClose.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });
    menuFile.setText("File");
    menuFile.add(menuMain);
    menuFile.addSeparator();
    menuFile.add(menuClose);

    // Menu Toolbar
    Menu.add(menuFile);
    Menu.add(menuProject);
    Menu.add(menuPeople);
    Menu.add(menuPlan);

    this.setJMenuBar(Menu);

    // -----PANEL----------------------------------------------
    lbTitle.setText(
        "<html><font color='#CC0000' face='Ubuntu Condensed'>PC</font><font color='#F87A17' face='Droid Sans Fallback'>Planning</font></html>");
    lbTitle.setFont(new Font("Droid Sans Fallback", Font.PLAIN, 110));
    lbTitle.setForeground(Color.red);

    if (loggedUser.getName().length() > 15) {
      StringBuilder UserName = new StringBuilder();
      String[] nameParts = loggedUser.getName().split(" ");
      UserName.append(nameParts[0]);
      for (int i = 1; i < nameParts.length; i++) {
        if (nameParts[i].equals("da") == false
            && nameParts[i].equals("de") == false
            && nameParts[i].equals("do") == false) {
          UserName.append(" " + nameParts[i].substring(0, 1) + ".");
        }
      }
      lbUserName.setText(UserName.toString());
    } else {
      lbUserName.setText(loggedUser.getName());
    }

    if (loggedUser.getLogin().getPermissionLevel() > 0) {
      menuPeople.setEnabled(false);
    }

    lbUserName.setForeground(Color.ORANGE);
    lbUserName.setFont(new Font("Ubuntu Condensed", Font.PLAIN, 20));
    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipady = 30; // make this component tall
    c.weightx = 0.0;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy = 1;

    panel.add(lbTitle, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.ipady = 5; // reset to default
    c.weighty = 1.0; // request any extra vertical space
    c.gridx = 0;
    c.gridy = 1;
    c.insets = new Insets(110, 345, 0, 0);
    panel.add(lbUserName, c);

    // --Icons Definitions
    lbNumberProject.setFont(new Font("Ubuntu Condensed", Font.PLAIN, 20));
    lbNumberPlans.setFont(new Font("Ubuntu Condensed", Font.PLAIN, 20));

    iconProject.setPreferredSize(new Dimension(150, 50));
    iconProject.setFocusable(false);
    iconProject.setHorizontalTextPosition(SwingConstants.CENTER);
    iconProject.setVerticalTextPosition(SwingConstants.CENTER);

    ImageIcon imgIconProject =
        new ImageIcon(getClass().getClassLoader().getResource("resources/iconProject.png"));
    iconProject.setBorder(BorderFactory.createEmptyBorder());
    iconProject.setContentAreaFilled(false);
    iconProject.setIcon(imgIconProject);
    iconProject.setIconTextGap(10);
    c.insets = new Insets(507, 250, 0, 0);
    panel.add(iconProject, c);
    c.insets = new Insets(500, 450, 0, 0);
    panel.add(lbNumberProject, c);

    iconPlans.setPreferredSize(new Dimension(150, 50));
    iconPlans.setHorizontalTextPosition(SwingConstants.CENTER);
    iconPlans.setVerticalTextPosition(SwingConstants.CENTER);

    ImageIcon imgIconPlans =
        new ImageIcon(getClass().getClassLoader().getResource("resources/iconPlans.png"));
    iconPlans.setBorder(BorderFactory.createEmptyBorder());
    iconPlans.setContentAreaFilled(false);
    iconPlans.setIcon(imgIconPlans);
    iconPlans.setIconTextGap(10);
    c.insets = new Insets(500, 450, 0, 0);
    panel.add(iconPlans, c);
    c.insets = new Insets(500, 550, 0, 0);
    panel.add(lbNumberPlans, c);

    // --

    this.add(panel);
    RefreshIcons(loggedUser);
  }
예제 #28
0
  public DuckSimButtonView(DuckSimModel modelArg) {
    model = modelArg;

    maxDucks = model.maxDuckCount();
    quackCountPrefix = "NUMBER OF QUACKS: ";
    quackCount = 0;

    quackTimer = new Timer(100, e -> quackTimerUpdate());
    quackCounter = 0;

    box = new Box(BoxLayout.Y_AXIS);
    header = new JPanel();
    duckrow1 = new JPanel();
    duckrow2 = new JPanel();
    duckButtonArray = new JButton[maxDucks];
    for (int i = 0; i < duckButtonArray.length; i++) {
      duckButtonArray[i] = new JButton();
      duckButtonArray[i].setIcon(new ImageIcon("assets/duck.png"));
      duckButtonArray[i].setEnabled(false);
      duckButtonArray[i].setBorderPainted(false);
      duckButtonArray[i].addActionListener(
          e -> {
            JButton button = (JButton) e.getSource();
            quackCounter = 0;
            quackTimer.start();
            quackCount++;
            button.setFont(new Font("Verdana", Font.BOLD, 24));
            button.setForeground(Color.WHITE);
            button.setText(e.getActionCommand());
            button.setHorizontalTextPosition(JButton.CENTER);
            button.setVerticalTextPosition(JButton.CENTER);
            updateButtons();
          });
    }
    createButton = new JButton("CREATE NEW DUCK");
    quackCountLabel = new JLabel(quackCountPrefix + quackCount);

    this.add(box);
    box.add(header);
    box.add(duckrow1);
    box.add(duckrow2);

    // add button and label to header
    header.add(createButton);
    createButton.addActionListener(
        e -> {
          MakeDuckDialog makeDuckDialog = new MakeDuckDialog(model, this);
          makeDuckDialog.setSize(300, 200);
          makeDuckDialog.setVisible(true);
        });
    header.add(quackCountLabel);

    // add buttons to duckrow1
    for (int i = 0; i < maxDucks / 2; i++) {
      duckrow1.add(duckButtonArray[i]);
    }

    // add buttons to duckrow2
    for (int i = maxDucks / 2; i < maxDucks; i++) {
      duckrow2.add(duckButtonArray[i]);
    }
  }
예제 #29
0
  /**
   * The ControlPanel creates all buttons that interact with the main factory simulation.
   *
   * @param mainInterface Provides reference to parent JFrame
   */
  public ControlPanel(MainInterface mainInterface) {
    parentFrame = mainInterface;
    setPreferredSize(new Dimension(280, 669));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    /* Initialize audio
    try {
    	audioPlayer = new AudioPlayer(new File("assets/sounds/pureimagination.wav"));
    	audio.start();
    }
    catch (Exception e){
    	System.out.println("ERROR: Audio cannot be played");
    } */

    // Initialisation of top two buttons, namely jbtnStart and jbtnStop
    jbtnStart = new JButton("Start");
    jbtnStart.setVerticalTextPosition(AbstractButton.CENTER);
    jbtnStart.setHorizontalTextPosition(AbstractButton.LEADING);
    jbtnStart.setActionCommand("startsim");
    jbtnStart.addActionListener(this);
    jbtnStart.setFocusPainted(false);
    jbtnStart.setEnabled(true);

    jbtnStop = new JButton("Stop");
    jbtnStop.setVerticalTextPosition(AbstractButton.CENTER);
    jbtnStop.setHorizontalTextPosition(AbstractButton.TRAILING);
    jbtnStop.setActionCommand("pausesim");
    jbtnStop.addActionListener(this);
    jbtnStop.setFocusPainted(false);
    jbtnStop.setEnabled(false);

    // Initialisation of the vibration speed slider.
    jslVibration = new JSlider(JSlider.HORIZONTAL, vibrMIN, vibrMAX, vibrINI);
    jslVibration.addChangeListener(new VibrationListener());
    jslVibration.setMajorTickSpacing(5);
    jslVibration.setMinorTickSpacing(1);
    jslVibration.setPaintTicks(true);
    jslVibration.setPaintLabels(true);
    jslVibration.setFont(new Font("Dialog", Font.PLAIN, 10));
    jslVibration.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEmptyBorder(),
            "CONVEYOR VIBRATION SPEED",
            TitledBorder.CENTER,
            TitledBorder.TOP,
            new Font("Dialog", Font.PLAIN, 9)));

    // Initialisation of the frame rate slider.
    jslFrameRate = new JSlider(JSlider.HORIZONTAL, frameMIN, frameMAX, frameINI);
    jslFrameRate.addChangeListener(new FrameRateListener());
    jslFrameRate.setMajorTickSpacing(20);
    jslFrameRate.setMinorTickSpacing(4);
    jslFrameRate.setPaintTicks(true);
    jslFrameRate.setPaintLabels(true);
    jslFrameRate.setFont(new Font("Dialog", Font.PLAIN, 10));
    jslFrameRate.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEmptyBorder(),
            "FRAME RATE",
            TitledBorder.CENTER,
            TitledBorder.TOP,
            new Font("Dialog", Font.PLAIN, 9)));

    // Initialisation of the KitSelection and ConsolePanel sub-panels.
    kitSelection = new KitSelection(parentFrame);
    consolePanel = new ConsolePanel(parentFrame);

    // Initialisation of the layout for the start and stop buttons.
    JPanel startStop = new JPanel();
    startStop.setLayout(new FlowLayout(FlowLayout.CENTER));
    startStop.setPreferredSize(new Dimension(200, 30));
    startStop.add(jbtnStart);
    startStop.add(jbtnStop);

    // Initialisation of the combination layout for the buttons and sliders.
    JPanel options = new JPanel();
    options.setLayout(new BoxLayout(options, BoxLayout.Y_AXIS));
    options.setPreferredSize(new Dimension(200, 178));
    options.add(startStop);
    options.add(jslVibration);
    options.add(jslFrameRate);

    // Aesthetic settings and adding all sub-panels to the main control panel.
    options.setBorder(BorderFactory.createTitledBorder("Options"));
    add(options);
    add(kitSelection);
    add(consolePanel);

    // Set a default vibration speed.
    UserData.setVibrationSpeed(this, 2);
  }
예제 #30
0
  public AboutDialog() {
    super(DummyFrame.getDialogParent());

    JLabel lbl = new JLabel("JDownloader");
    lbl.setFont(lbl.getFont().deriveFont(lbl.getFont().getSize() * 2.0f));

    String branch =
        SubConfiguration.getConfig("WEBUPDATE").getStringProperty(WebUpdater.BRANCHINUSE, null);
    final String version;
    if (branch == null) {
      version = "JDownloader Build " + JDUtilities.getRevision();
    } else {
      version = "JDownloader -" + branch + "- Build " + JDUtilities.getRevision();
    }

    JPanel links = new JPanel(new MigLayout("ins 0", "[]push[]push[]push[]"));
    try {
      JButton btn =
          Factory.createButton(
              JDL.L(JDL_PREFIX + "license", "Show license"),
              JDTheme.II("gui.images.premium", 16, 16),
              new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                  String license =
                      JDIO.readFileToString(
                          JDUtilities.getResourceFile("licenses/jdownloader.license"));
                  UserIO.getInstance()
                      .requestMessageDialog(
                          UserIO.STYLE_LARGE | UserIO.NO_ICON | UserIO.NO_COUNTDOWN,
                          JDL.L(JDL_PREFIX + "license.title", "JDownloader License"),
                          license);
                }
              });
      btn.setBorder(null);

      links.add(btn);
      links.add(
          new JLink(
              JDL.L(JDL_PREFIX + "homepage", "Homepage"),
              JDTheme.II("gui.images.config.host", 16, 16),
              new URL("http://www.jdownloader.org/home?lng=en")));
      links.add(
          new JLink(
              JDL.L(JDL_PREFIX + "forum", "Support board"),
              JDTheme.II("gui.images.list", 16, 16),
              new URL("http://board.jdownloader.org")));
      links.add(
          new JLink(
              JDL.L(JDL_PREFIX + "contributers", "Contributers"),
              JDTheme.II("gui.images.accounts", 16, 16),
              new URL("http://jdownloader.org/knowledge/wiki/contributers")));
    } catch (MalformedURLException e1) {
      e1.printStackTrace();
    }

    JButton btn =
        Factory.createButton(
            JDL.L(JDL_PREFIX + "copy", "Copy"),
            JDTheme.II("gui.icons.copy", 16, 16),
            new ActionListener() {

              public void actionPerformed(ActionEvent e) {
                StringBuilder sb = new StringBuilder();
                sb.append(version).append("\r\n");
                sb.append("Java Vendor: ").append(System.getProperty("java.vendor")).append("\r\n");
                sb.append("Java Version: ").append(System.getProperty("java.version"));
                ClipboardHandler.getClipboard().copyTextToClipboard(sb.toString());
              }
            });
    btn.setBorder(null);
    btn.setVerticalTextPosition(JButton.BOTTOM);
    btn.setHorizontalTextPosition(JButton.CENTER);

    this.setLayout(new MigLayout("ins 10, wrap 3", "[]15[]push[right]"));
    this.add(new JLabel(JDImage.getImageIcon("logo/jd_logo_128_128")), "aligny center, spany 6");
    this.add(lbl, "spanx");
    this.add(new JLabel("© AppWork UG (haftungsbeschränkt) 2007-2010"), "spanx");
    this.add(new JLabel(version), "gaptop 10");
    this.add(btn, "aligny center, spany 3");
    this.add(new JLabel("JRE Vendor: " + System.getProperty("java.vendor")));
    this.add(new JLabel("JRE Version: " + System.getProperty("java.version")));
    this.add(new JLabel("Synthetica License Registration Number (#289416475)"), "gaptop 10, spanx");
    this.add(links, "gaptop 15, growx, pushx, spanx");
    this.pack();

    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    this.setTitle(JDL.L(JDL_PREFIX + "title", "About JDownloader"));
    this.setResizable(false);
    this.setLocation(Screen.getCenterOfComponent(DummyFrame.getDialogParent(), this));

    /*
     * Fixes Always-on-Top-Bug in windows. Bugdesc: found in svn
     */
    DummyFrame.getDialogParent().setAlwaysOnTop(true);
    DummyFrame.getDialogParent().setAlwaysOnTop(false);

    this.setVisible(true);
  }