コード例 #1
0
  private void initComponents() {
    // Message - JLabel
    lblMessage =
        new JLabel(
            String.format(
                "An unexpected error has occurred: %s",
                e == null ? "Unexpected exception" : e.getMessage()));
    lblMessage.setIcon(icon);
    lblMessage.setPreferredSize(new Dimension(360, 40));
    lblMessage.setBorder(BorderFactory.createLineBorder(Color.red));

    // txtTrace - ExceptionTracePane
    txtTrace = new ExceptionTracePane();
    txtTrace.setBackground(new Color(92, 0, 0));
    txtTrace.setException(e);

    // srlTrace - JScrollPane
    JPanel traceWrapper = new JPanel(new BorderLayout());
    traceWrapper.add(txtTrace, BorderLayout.CENTER);
    srlTrace = new JScrollPane(traceWrapper);
    srlTrace.setPreferredSize(new Dimension(360, 200));
    srlTrace.setVisible(false);

    // btnDetails - JButton
    btnDetails = new JButton(new DetailsButtonAction());
    btnDetails.setPreferredSize(new Dimension(100, 40));

    // btnClose - JButton
    btnClose = new JButton(new CloseButtonAction());
    btnClose.setDefaultCapable(true);
    btnClose.setPreferredSize(new Dimension(100, 40));
  }
コード例 #2
0
  public ConnectDialogue(JFrame owner, String title, Properties p) {
    super(owner, title, true);
    setSize(300, 200);
    setLocation(250, 200);
    props = new Properties(p); // set properties in this class to the ones passed in
    ok.setPreferredSize(new Dimension(75, 25));
    ok.addActionListener(this);
    cancel.setPreferredSize(new Dimension(75, 25));
    cancel.addActionListener(this);

    JPanel cpanel = new JPanel(); // Grid layout with text fields
    JPanel cpanel2 = new JPanel();

    // Add items to the Content Panel
    cpanel.setLayout(new GridLayout(5, 2));

    cpanel.add(lhost);
    cpanel.add(host);
    cpanel.add(lport);
    cpanel.add(port);
    cpanel.add(ldatabase);
    cpanel.add(database);
    cpanel.add(luser);
    cpanel.add(user);
    cpanel.add(lpass);
    cpanel.add(pass);

    cpanel2.add(ok);
    cpanel2.add(cancel);

    add(cpanel, BorderLayout.NORTH);
    add(cpanel2, BorderLayout.SOUTH);
  }
コード例 #3
0
  /**
   * Builds reading lists tab.
   *
   * @return component.
   */
  protected JComponent buildReadingListsTab() {
    // Wording
    JComponent wording = msg(Strings.message("guide.dialog.readinglists.wording"));

    // Buttons
    Dimension btnSize = new Dimension(20, 20);
    btnAddReadingList.setPreferredSize(btnSize);
    btnRemoveList.setPreferredSize(btnSize);
    FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
    JPanel bbar = new JPanel(layout);
    bbar.add(btnAddReadingList);
    bbar.add(btnRemoveList);
    layout.setHgap(0);
    layout.setVgap(0);

    // Panel
    BBFormBuilder builder = new BBFormBuilder("0:grow");
    builder.setDefaultDialogBorder();

    builder.append(wording);
    builder.appendUnrelatedComponentsGapRow(2);
    builder.appendRow("min:grow");
    builder.append(new JScrollPane(tblReadingLists), 1, CellConstraints.FILL, CellConstraints.FILL);
    builder.append(bbar);

    return builder.getPanel();
  }
コード例 #4
0
ファイル: ButtonPanel.java プロジェクト: Dent2/port-scanner
 public ButtonPanel(String scanButtonLabel, String resetButtonLabel) {
   super();
   scanButton = new JButton(scanButtonLabel);
   scanButton.setPreferredSize(SIZE);
   add(scanButton);
   add(Box.createRigidArea(MARGIN));
   resetButton = new JButton(resetButtonLabel);
   resetButton.setPreferredSize(SIZE);
   add(resetButton);
 }
コード例 #5
0
  public WelcomePane(String bannerMessage, ActionListener mainFrameActionListener) {

    this.setLayout(new GridBagLayout());
    GridBagConstraints bc = new GridBagConstraints();

    // adding bannerJLable to the WelcomePane
    JLabel bannerJLabel;
    bannerJLabel = new JLabel(bannerMessage);

    bc.gridy = 0;
    bc.gridx = 0;

    bc.gridwidth = 2;
    bc.weightx = 2;
    bc.weighty = 2;
    bc.anchor = GridBagConstraints.CENTER;
    this.add(bannerJLabel, bc);
    // ///////////////////////////////////////////////

    // adding signInButton to WelcomePane
    signInButton = new JButton("Sign-In");
    signInButton.setEnabled(false);
    signInButton.setPreferredSize(new Dimension(200, 50));

    bc.gridy = 1;
    bc.gridx = 0;

    bc.gridwidth = 1;
    bc.anchor = GridBagConstraints.CENTER;
    this.add(signInButton, bc);
    // ///////////////////////////////////////////////

    // adding orderAsGuestButton to WelcomePane
    orderAsGuestButton = new JButton("Order As Guest");
    orderAsGuestButton.setPreferredSize(new Dimension(200, 50));

    bc.gridy = 1;
    bc.gridx = 1;

    bc.gridwidth = 1;
    bc.weighty = 1;
    bc.anchor = GridBagConstraints.CENTER;
    this.add(orderAsGuestButton, bc);
    // ///////////////////////////////////////////////

    /// sets the actionListener to the MainFrame which implements ActionListener
    orderAsGuestButton.addActionListener(mainFrameActionListener);
  } // ends WelcomePane Constructor
コード例 #6
0
ファイル: JRootApp.java プロジェクト: jhanysel/SysNeo-POS
  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();
    }
  }
コード例 #7
0
ファイル: BoardFrame.java プロジェクト: jjchee/mancala
  /**
   * Constructor that takes model as a parameter
   *
   * @param model
   */
  public BoardFrame(Model model) {
    this.model = model;
    data = model.getData();
    gameOver = false;
    initScreen();
    setLayout(new BorderLayout());
    setLocation(300, 200);

    // undoBtn is a controller that resets the turn and last state of board
    undoBtn = new JButton("Undo : " + this.model.getUndoCounter());
    undoBtn.setPreferredSize(new Dimension(80, 50));

    undoBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (BoardFrame.this.model.getUndoCounter() != 0) {
              BoardFrame.this.model.undo();
              undoBtn.setText("Undo : " + BoardFrame.this.model.getUndoCounter());
            } else ;
          }
        });
    JPanel undoPanel = new JPanel();
    undoPanel.add(undoBtn);
    // end of undoBtn code

    add(boardPanel, BorderLayout.CENTER);
    add(undoPanel, BorderLayout.SOUTH);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setResizable(false);
    setVisible(true);
  }
コード例 #8
0
ファイル: BlueJTheme.java プロジェクト: tordf/Greenfoot
  /**
   * Get a standard BlueJ "continue" button.
   *
   * @return A JButton that says "Continue"
   */
  public static JButton getContinueButton() {
    computeButtonWidths();

    JButton continueButton = new JButton(getContinueLabel());
    // try to make the OK, cancel and continue  buttons have equal size
    continueButton.setPreferredSize(okCancelDimension);
    return continueButton;
  }
コード例 #9
0
ファイル: SearchManager2.java プロジェクト: steog88/jabref
 /** force the search button to be large enough for the longer of the two texts */
 private void setSearchButtonSizes() {
   search.setText(Globals.lang("Search specified field(s)"));
   Dimension size1 = search.getPreferredSize();
   search.setText(Globals.lang("Search all fields"));
   Dimension size2 = search.getPreferredSize();
   size2.width = Math.max(size1.width, size2.width);
   search.setMinimumSize(size2);
   search.setPreferredSize(size2);
 }
コード例 #10
0
 public MenuButtonAcqMode(Color color, String toolTip) {
   back = new JButton(null, new ColoredIcon(Color.black));
   back.setPreferredSize(new Dimension(22, 22));
   setMainButton(back);
   setPopupMenu(new ColorPanel(back));
   setPopupLocation(MenuedButton.BELOW);
   setSelectedColor(color);
   setToolTipText(toolTip);
 }
コード例 #11
0
ファイル: MyButton.java プロジェクト: hsfm/Verschiedenes
 /* create a new button and add the respective coordinates */
 public void createNewButton(int x, int y) {
   this.x = x; // Autoboxing!
   this.y = y;
   button = new JButton();
   button.setPreferredSize(new Dimension(20, 20));
   // for leftclicks
   button.setActionCommand(this.x.toString() + " " + this.y.toString());
   // for rightclicks
   button.setName(this.x.toString() + " " + this.y.toString());
 }
コード例 #12
0
ファイル: JSpinner.java プロジェクト: suvarchal/IDV
 /**
  * _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;
 }
コード例 #13
0
  public void layoutComponents() {
    setLayout(new BorderLayout());
    add(main, BorderLayout.CENTER);

    if (popperIsVisible) {
      if (getPopperButtonLocation() == RIGHT) {
        popper.setPreferredSize(new Dimension(14, main.getHeight()));
        add(popper, BorderLayout.EAST);
      } else if (getPopperButtonLocation() == BOTTOM) {
        popper.setPreferredSize(new Dimension(main.getWidth(), 14));
        add(popper, BorderLayout.SOUTH);

        setPopperArrowDirection(DOWN);
        setPopupLocation(popper.getX(), popper.getY() + popper.getHeight() + 5);
      }
    }

    Utilities.updateView(this);
  }
コード例 #14
0
    public MainFrame() {
      try {
        mainPanel.setLayout(new BorderLayout());
        mainPanel.setBorder(BorderFactory.createEmptyBorder(9, 9, 9, 9));
        mainPanel.add(outputContainer, java.awt.BorderLayout.CENTER);
        outputArea.setLineWrap(true);
        outputContainer.add(new JScrollPane(outputArea), java.awt.BorderLayout.CENTER);
        outputContainer.setBorder(new javax.swing.border.TitledBorder("Results"));

        this.getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);

        java.util.ArrayList<JButton> btns = new java.util.ArrayList<JButton>();
        {
          JPanel westPanel = new JPanel(new GridLayout(0, 1, 0, 10));
          westPanel.setBorder(BorderFactory.createEmptyBorder(9, 9, 9, 9));
          JPanel opsPanel = new JPanel(new GridLayout(6, 1));
          opsPanel.setBorder(new javax.swing.border.TitledBorder("Operations"));

          for (Action action : operations) {
            JPanel p = new JPanel(new BorderLayout());
            JButton jb = new JButton(action);
            btns.add(jb);
            p.add(jb, BorderLayout.NORTH);
            opsPanel.add(p);
          }

          westPanel.add(opsPanel);
          controlContainer.add(westPanel, BorderLayout.CENTER);
        }

        this.getContentPane().add(controlContainer, BorderLayout.WEST);
        this.pack();

        Dimension dim = btns.get(0).getSize();
        for (JButton btn : btns) {
          btn.setPreferredSize(dim);
        }

        java.awt.Dimension prefSize = this.getPreferredSize();
        prefSize.setSize(prefSize.getWidth(), 1.1 * prefSize.getHeight());
        this.setSize(prefSize);

        java.awt.Dimension parentSize;
        java.awt.Point parentLocation = new java.awt.Point(0, 0);
        parentSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        int x = parentLocation.x + (parentSize.width - prefSize.width) / 2;
        int y = parentLocation.y + (parentSize.height - prefSize.height) / 2;
        this.setLocation(x, y);
        this.setResizable(true);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
コード例 #15
0
ファイル: THA.java プロジェクト: tlulu/Tetris-Platformer
 public Mode(int x, int y) {
   this.setSize(x, y);
   try {
     intro = new ImageIcon("introScreen.jpg");
   } catch (Exception e) {
   }
   m1.setPreferredSize(new Dimension(150, 40));
   m2.setPreferredSize(new Dimension(150, 40));
   back.setPreferredSize(new Dimension(80, 40));
   l.setPreferredSize(new Dimension(150, 100));
   l.setFont(new Font("Serif", Font.BOLD, 60));
   l.setForeground(Color.yellow);
   m1.addActionListener(this);
   m2.addActionListener(this);
   back.addActionListener(this);
   this.setLayout(new FlowLayout(FlowLayout.CENTER, this.getWidth(), 100));
   this.add(l);
   this.add(m1);
   this.add(m2);
   this.add(back);
 }
コード例 #16
0
ファイル: MancalaPanel.java プロジェクト: meckila/Mancala
  /*Creates the East section of the mancala board. Contains Collection Pit*/
  private JPanel eastBoardPanel() {
    JPanel eastPanel = new JPanel();
    eastPanel.setOpaque(false);
    eastPanel.setPreferredSize(new Dimension(150, 600));

    b6 = new JButton(String.valueOf(game.board.getPitAt(6).getCount()));
    b6.setPreferredSize(new Dimension(100, 330));
    b6.setFont(new Font("Belta Regular", Font.BOLD, 32));
    b6.setBackground(new Color(214, 162, 173));
    eastPanel.add(b6);
    return eastPanel;
  }
コード例 #17
0
ファイル: MancalaPanel.java プロジェクト: meckila/Mancala
  // Panel below board (Contains Label Indicating Player 1's turn
  private JPanel southWindowPanel() {
    JPanel lab1Panel = new JPanel();
    lab1Panel.setLayout(new BorderLayout());
    lab1Panel.setPreferredSize(new Dimension(300, 150));
    lab1Panel.setOpaque(false);
    statusLabel1 = new JLabel("Player 1's Turn", JLabel.CENTER);
    statusLabel1.setForeground(new Color(203, 159, 0));
    statusLabel1.setFont(new Font("Belta Regular", Font.ITALIC, 45));

    lab1Panel.add(statusLabel1, BorderLayout.CENTER);

    JPanel eastContainer = new JPanel();
    eastContainer.setLayout(new BorderLayout());
    eastContainer.setOpaque(false);
    eastContainer.setPreferredSize(new Dimension(200, 300));

    JPanel btnPanel = new JPanel();
    btnPanel.setOpaque(false);
    btnPanel.setPreferredSize(new Dimension(300, 60));
    eastContainer.add(btnPanel, BorderLayout.SOUTH);

    // Add help button to panel
    instructBtn.setPreferredSize(new Dimension(50, 40));
    instructBtn.setBorder(BorderFactory.createLineBorder(Color.black, 5));
    instructBtn.addActionListener(new ButtonListener());
    btnPanel.add(instructBtn);

    // Add restart button to panel
    restartBtn.setPreferredSize(new Dimension(100, 40));
    restartBtn.setBorder(BorderFactory.createLineBorder(Color.black, 5));
    restartBtn.addActionListener(new ButtonListener()); // Add Action Listener (Reset Game)
    btnPanel.add(restartBtn);

    JPanel westContainer = new JPanel();
    westContainer.setPreferredSize(new Dimension(200, 300));
    westContainer.setOpaque(false);
    lab1Panel.add(westContainer, BorderLayout.WEST);
    lab1Panel.add(eastContainer, BorderLayout.EAST);
    return lab1Panel;
  }
コード例 #18
0
ファイル: EditorTabs.java プロジェクト: kenygia/solarus
    /**
     * Constructor.
     *
     * @param title the title of the tab component
     * @param editor the editor of the tab (used to close the tab)
     */
    public TabComponent(final AbstractEditorPanel editor) {

      setLayout(new BorderLayout());
      setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
      setOpaque(false);

      // title
      title = new JLabel(editor.getTitle());
      title.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
      add(title, BorderLayout.WEST);

      // close
      final JButton close = new JButton(Project.getEditorImageIconOrEmpty("icon_cross.png"));
      close.setPreferredSize(new Dimension(16, 16));
      close.setUI(new BasicButtonUI());
      close.setBorderPainted(false);
      close.setOpaque(false);
      close.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
              removeEditor(editor, true);
            }
          });
      close.addMouseListener(
          new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent me) {}

            @Override
            public void mousePressed(MouseEvent me) {}

            @Override
            public void mouseReleased(MouseEvent me) {}

            @Override
            public void mouseEntered(MouseEvent me) {

              close.setBorderPainted(true);
            }

            @Override
            public void mouseExited(MouseEvent me) {

              close.setBorderPainted(false);
            }
          });
      add(close, BorderLayout.EAST);
    }
コード例 #19
0
  private JPanel logowaniePanel() {
    FormLayout layout3 =
        new FormLayout(
            "245px, 29px, 64px, 10px, 75px, 10px, 19px, 36px, 246px",
            "159px, 35px, 15px, 35px, 10px, 35px, 37px, 155px"); // musi byc 500px
    logowaniePanel = new JPanel(layout3);
    // logowaniePanel = new FormDebugPanel(layout3);
    CellConstraints cc = new CellConstraints();
    Color c = new Color(153, 180, 209);
    logowaniePanel.setBackground(c);
    JLabel label = new JLabel("LOGOWANIE");
    Font font = new Font("Arial", Font.BOLD, 34);
    Font font2 = new Font("Arial", Font.PLAIN, 16);

    label.setFont(font);
    JLabel l1 = new JLabel("Login: "******"Hasło: ", JLabel.TRAILING);
    l2.setFont(font2);
    tx1 = new JTextField();
    tx2 = new JPasswordField();

    buttonOK = new JButton("ok");
    buttonOK.setPreferredSize(new Dimension(55, 37));
    buttonOK.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String password = new String(tx2.getText());
            if (tx1.getText().equals("admin") && password.equals("admin")) {
              CardLayout c1 = (CardLayout) (utworzPanel.getLayout());
              c1.show(utworzPanel, "card2");
            } else if (tx1.getText().equals("kibic") && password.equals("kibic")) {
              CardLayout c1 = (CardLayout) (utworzPanel.getLayout());
              c1.show(utworzPanel, "card3");
            } else if (tx1.getText().equals("pracownik") && password.equals("pracownik")) {
              CardLayout c1 = (CardLayout) (utworzPanel.getLayout());
              c1.show(utworzPanel, "card4");
            }
          }
        });

    logowaniePanel.add(label, cc.xyw(2, 2, 7, CellConstraints.CENTER, CellConstraints.CENTER));
    logowaniePanel.add(l1, cc.xy(3, 4));
    logowaniePanel.add(l2, cc.xy(3, 6));
    logowaniePanel.add(tx1, cc.xy(5, 4, CellConstraints.FILL, CellConstraints.FILL));
    logowaniePanel.add(tx2, cc.xy(5, 6, CellConstraints.FILL, CellConstraints.FILL));
    logowaniePanel.add(buttonOK, cc.xyw(7, 7, 2));
    return logowaniePanel;
  }
コード例 #20
0
ファイル: THA.java プロジェクト: tlulu/Tetris-Platformer
 public TitleScreen(int x, int y) {
   this.setSize(x, y);
   try {
     intro = new ImageIcon("introScreen.jpg");
     tetris = new ImageIcon("tetrisWord.png");
   } catch (Exception e) {
   }
   ;
   start.setPreferredSize(new Dimension(80, 40));
   highScore.setPreferredSize(new Dimension(150, 40));
   instructions.setPreferredSize(new Dimension(150, 40));
   exit.setPreferredSize(new Dimension(80, 40));
   start.addActionListener(this);
   highScore.addActionListener(this);
   instructions.addActionListener(this);
   exit.addActionListener(this);
   this.add(Box.createRigidArea(new Dimension(10, this.getHeight() / 2 - 50)));
   this.setLayout(new FlowLayout(FlowLayout.CENTER, this.getWidth(), 25));
   this.add(start);
   this.add(instructions);
   this.add(highScore);
   this.add(exit);
 }
コード例 #21
0
ファイル: THA.java プロジェクト: tlulu/Tetris-Platformer
 public Difficulty(int x, int y) {
   this.setSize(x, y);
   try {
     intro = new ImageIcon("introScreen.jpg");
   } catch (Exception e) {
   }
   easy.setPreferredSize(new Dimension(100, 40));
   medium.setPreferredSize(new Dimension(100, 40));
   hard.setPreferredSize(new Dimension(100, 40));
   back.setPreferredSize(new Dimension(80, 40));
   l.setPreferredSize(new Dimension(250, 100));
   l.setFont(new Font("Serif", Font.BOLD, 50));
   l.setForeground(Color.yellow);
   easy.addActionListener(this);
   medium.addActionListener(this);
   hard.addActionListener(this);
   back.addActionListener(this);
   this.setLayout(new FlowLayout(FlowLayout.CENTER, this.getWidth(), 75));
   this.add(l);
   this.add(easy);
   this.add(medium);
   this.add(hard);
   this.add(back);
 }
コード例 #22
0
ファイル: THA.java プロジェクト: tlulu/Tetris-Platformer
 public Instruction(int x, int y) {
   this.setSize(x, y);
   try {
     intro = new ImageIcon("introScreen.jpg");
   } catch (Exception e) {
   }
   this.add(Box.createRigidArea(new Dimension(10, 15)));
   this.setLayout(new FlowLayout(FlowLayout.CENTER, this.getWidth(), 25));
   for (int i = 0; i < allIns.length; i++) {
     allIns[i].setFont(new Font("Serif", Font.BOLD, 18));
     allIns[i].setForeground(Color.yellow);
     this.add(allIns[i]);
   }
   back.setPreferredSize(new Dimension(80, 40));
   back.addActionListener(this);
   this.add(back);
 }
コード例 #23
0
 protected void setButtonsSize() {
   int nMaxWidth = 0, nMaxHeight = 0;
   Dimension objSize;
   Iterator objIterator = buttons.values().iterator();
   while (objIterator.hasNext()) {
     JButton objButton = (JButton) objIterator.next();
     objButton.setPreferredSize(null);
     objSize = objButton.getPreferredSize();
     nMaxWidth = Math.max(nMaxWidth, objSize.width);
     nMaxHeight = Math.max(nMaxHeight, objSize.height);
   }
   objSize = new Dimension(nMaxWidth, nMaxHeight);
   d = objSize;
   objIterator = buttons.values().iterator();
   while (objIterator.hasNext()) {
     ((JButton) objIterator.next()).setPreferredSize(objSize);
   }
 }
コード例 #24
0
  private JPanel createButton(String num, String desc, boolean enabled) {
    JPanel pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 8, 0));
    pane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

    JButton btn = new JButton("Tutorial" + num);
    btn.setPreferredSize(new Dimension(120, 25));
    btn.addActionListener(this);
    btn.setEnabled(enabled);
    btn.setFont(new Font("Verdana", Font.BOLD, 12));

    JLabel label = new JLabel(desc);
    label.setFont(new Font("Verdana", Font.PLAIN, 11));

    pane.add(btn);
    pane.add(label);

    return pane;
  }
コード例 #25
0
ファイル: MyDateChooseBtn.java プロジェクト: singleD/se2
    private void initButton() {
      int actionCommandId = 1;
      for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {
          JButton numberButton = new JButton();
          numberButton.setBorder(BorderFactory.createEmptyBorder());
          numberButton.setHorizontalAlignment(SwingConstants.CENTER);
          numberButton.setActionCommand(String.valueOf(actionCommandId));

          numberButton.addMouseListener(this);

          numberButton.setBackground(palletTableColor);
          numberButton.setForeground(dateFontColor);
          numberButton.setText(String.valueOf(actionCommandId));
          numberButton.setPreferredSize(new Dimension(25, 25));
          daysButton[i][j] = numberButton;
          actionCommandId++;
        }
      }
    }
コード例 #26
0
ファイル: SwingComponentUtils.java プロジェクト: piopawlu/ols
  /**
   * Creates a button pane in which the given buttons are neatly aligned with proper spacings.
   *
   * @param aButtons the buttons to add to the created button pane, will be added in the given
   *     order.
   * @return the button pane, never <code>null</code>.
   */
  public static JComponent createButtonPane(final JButton... aButtons) {
    if ((aButtons == null) || (aButtons.length < 1)) {
      throw new IllegalArgumentException("Need at least one button!");
    }

    final JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(
        BorderFactory.createEmptyBorder(
            BUTTONS_PADDING_TOP,
            BUTTONS_PADDING_LEFT,
            BUTTONS_PADDING_BOTTOM,
            BUTTONS_PADDING_RIGHT));

    buttonPane.add(Box.createHorizontalGlue());

    // we want equally sized buttons, so we are recording preferred sizes while
    // adding the buttons and set them to the maximum afterwards...
    int width = 1;
    int height = 1;

    for (JButton button : aButtons) {
      width = Math.max(width, button.getPreferredSize().width);
      height = Math.max(height, button.getPreferredSize().height);

      buttonPane.add(Box.createHorizontalStrut(BUTTONS_SPACING_DEFAULT));
      buttonPane.add(button);
    }

    buttonPane.add(Box.createHorizontalStrut(BUTTONS_SPACING_DEFAULT));

    final Dimension newDims = new Dimension(width, height);

    // everything added; let's set all sizes
    for (final JButton button : aButtons) {
      button.setPreferredSize(newDims);
    }

    return buttonPane;
  }
コード例 #27
0
 private void initProgressFrame() {
   progressFrame = new JFrame("Progress");
   JPanel mainPanel = new JPanel();
   mainPanel.setLayout(new BorderLayout());
   progressBar = new JProgressBar();
   progressBar.setMinimum(0);
   progressBar.setMaximum(100);
   progressBar.setPreferredSize(new Dimension(500, 25));
   JPanel progressPanel = new JPanel();
   progressPanel.add(progressBar);
   progressPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
   mainPanel.add(progressPanel, BorderLayout.NORTH);
   textArea = new JTextArea();
   textArea.setRows(20);
   textArea.setEditable(false);
   JScrollPane scrollPane = new JScrollPane(textArea);
   scrollPane.setBorder(new EmptyBorder(10, 10, 10, 10));
   mainPanel.add(scrollPane, BorderLayout.CENTER);
   doneButton = new JButton("Done");
   doneButton.setPreferredSize(new Dimension(495, 25));
   doneButton.setEnabled(false);
   doneButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           doneButton.setEnabled(false);
           progressFrame.setVisible(false);
           optionsFrame.setVisible(true);
         }
       });
   JPanel donePanel = new JPanel();
   donePanel.setLayout(new BorderLayout());
   donePanel.add(doneButton, BorderLayout.CENTER);
   donePanel.setBorder(new EmptyBorder(0, 10, 10, 10));
   mainPanel.add(donePanel, BorderLayout.SOUTH);
   progressFrame.getContentPane().add(mainPanel);
   progressFrame.pack();
   progressFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
コード例 #28
0
  /**
   * If the add button is pressed, this function creates a spot for it in the scroll pane, and tells
   * the restaurant panel to add a new person.
   *
   * @param name name of new person
   */
  public void addPerson(String name, boolean isHungry) {
    if (name != null) {
      JButton button = new JButton(name);
      button.setBackground(Color.white);

      Dimension paneSize = scrollPane.getSize();
      Dimension buttonSize =
          new Dimension(
              (paneSize.width / NUM_BUTTONS_COLS) - BUTTON_WIDTH_ADJUST,
              paneSize.height / NUM_BUTTONS_ROWS);
      button.setPreferredSize(buttonSize);
      button.setMinimumSize(buttonSize);
      button.setMaximumSize(buttonSize);
      button.addActionListener(this);
      list.add(button);
      view.add(button);
      if (isHungry)
        restPanel.addPerson(null, "Hungry" + type, name, 50); // puts hungry customer on list
      else restPanel.addPerson(null, type, name, 50); // puts customer on list
      //        restPanel.showInfo(type, name);//puts hungry button on panel
      validate();
    }
  }
コード例 #29
0
  /**
   * Displays a modal dialog with one button for each entry in the {@link GraphicGenerator} clipart
   * library. Clicking on a button sets that entry into the {@link ATTR_CLIPART_NAME} parameter.
   */
  private void displayClipartDialog() {
    Window window = SwingUtilities.getWindowAncestor(myPanel);
    final JDialog dialog = new JDialog(window, Dialog.ModalityType.DOCUMENT_MODAL);
    FlowLayout layout = new FlowLayout();
    dialog.getRootPane().setLayout(layout);
    int count = 0;
    for (Iterator<String> iter = GraphicGenerator.getClipartNames(); iter.hasNext(); ) {
      final String name = iter.next();
      try {
        JButton btn = new JButton();

        btn.setIcon(new ImageIcon(GraphicGenerator.getClipartIcon(name)));
        Dimension d = new Dimension(CLIPART_ICON_SIZE, CLIPART_ICON_SIZE);
        btn.setMaximumSize(d);
        btn.setPreferredSize(d);
        btn.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                myTemplateState.put(ATTR_CLIPART_NAME, name);
                dialog.setVisible(false);
                update();
              }
            });
        dialog.getRootPane().add(btn);
        count++;
      } catch (IOException e) {
        LOG.error(e);
      }
    }
    int size =
        (int) (Math.sqrt(count) + 1) * (CLIPART_ICON_SIZE + layout.getHgap())
            + CLIPART_DIALOG_BORDER * 2;
    dialog.setSize(size, size + DIALOG_HEADER);
    dialog.setLocationRelativeTo(window);
    dialog.setVisible(true);
  }
コード例 #30
0
  ApplicationFrame() {
    super("Ecuatii Neliniare");

    setSize(frameWidth, frameHeight);
    setDefaultCloseOperation(this.EXIT_ON_CLOSE);

    panel.setOpaque(true);
    getContentPane().add(panel);
    addComponentListener(this);

    for (int i = 0; i < Methods.length; i++) ChooseMethod.addItem(Methods[i]);
    buttonPanel.add(ChooseMethod);

    buttonPanel.setOpaque(true);
    JButton buttonAdd = new JButton("Aplica...");
    buttonAdd.setPreferredSize(new Dimension(125, 25));
    buttonAdd.addActionListener(this);
    buttonPanel.add(buttonAdd);

    unitXSlider.setMinorTickSpacing(5);
    unitXSlider.setPaintTicks(true);
    unitXSlider.addChangeListener(this);
    unitYSlider.setMinorTickSpacing(5);
    unitYSlider.setPaintTicks(true);
    unitYSlider.addChangeListener(this);
    buttonPanel.add(unitXSlider);
    buttonPanel.add(unitYSlider);

    Border padding = BorderFactory.createEmptyBorder(0, 20, 20, 20);
    panel.setBorder(padding);
    panel.add(buttonPanel, BorderLayout.NORTH);
    panel.add(graph, BorderLayout.CENTER);

    pack();

    setVisible(true);
  }