javax.swing.JButton.getPreferredSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(269)

本文整理了Java中javax.swing.JButton.getPreferredSize()方法的一些代码示例,展示了JButton.getPreferredSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.getPreferredSize()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:getPreferredSize

JButton.getPreferredSize介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

  1. new Dimension(0, Math.max(nameLabel.getPreferredSize().height, deleteButton.getPreferredSize().height)));
  2. add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  3. new Insets(5, 0, 0, 5), 0, 0));

代码示例来源:origin: libgdx/libgdx

  1. new Dimension(0, Math.max(nameLabel.getPreferredSize().height, deleteButton.getPreferredSize().height)));
  2. add(titlePanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
  3. new Insets(5, 0, 0, 5), 0, 0));

代码示例来源:origin: libgdx/libgdx

  1. public void layoutContainer (Container parent) {
  2. Dimension buttonSize = upButton.getPreferredSize();
  3. int upButtonX = getWidth() - buttonSize.width * 3 - 6 - 5;
  4. upButton.setBounds(upButtonX, 0, buttonSize.width, buttonSize.height);
  5. downButton.setBounds(getWidth() - buttonSize.width * 2 - 3 - 5, 0, buttonSize.width, buttonSize.height);
  6. deleteButton.setBounds(getWidth() - buttonSize.width - 5, 0, buttonSize.width, buttonSize.height);
  7. Dimension labelSize = nameLabel.getPreferredSize();
  8. nameLabel.setBounds(5, buttonSize.height / 2 - labelSize.height / 2, getWidth() - 5, labelSize.height);
  9. }

代码示例来源:origin: libgdx/libgdx

  1. public void layoutContainer (Container parent) {
  2. Dimension buttonSize = upButton.getPreferredSize();
  3. int upButtonX = getWidth() - buttonSize.width * 3 - 6 - 5;
  4. upButton.setBounds(upButtonX, 0, buttonSize.width, buttonSize.height);
  5. downButton.setBounds(getWidth() - buttonSize.width * 2 - 3 - 5, 0, buttonSize.width, buttonSize.height);
  6. deleteButton.setBounds(getWidth() - buttonSize.width - 5, 0, buttonSize.width, buttonSize.height);
  7. Dimension labelSize = nameLabel.getPreferredSize();
  8. nameLabel.setBounds(5, buttonSize.height / 2 - labelSize.height / 2, getWidth() - 5, labelSize.height);
  9. }

代码示例来源:origin: kiegroup/optaplanner

  1. solvePanel.add(terminateSolvingEarlyButton, "terminateSolvingEarlyAction");
  2. solveButton.setMinimumSize(terminateSolvingEarlyButton.getMinimumSize());
  3. solveButton.setPreferredSize(terminateSolvingEarlyButton.getPreferredSize());

代码示例来源:origin: groovy/groovy-core

  1. REPLACE_ALL_BUTTON.getPreferredSize() :
  2. REPLACE_BUTTON.getPreferredSize();
  3. FIND_BUTTON.setPreferredSize(d);
  4. REPLACE_BUTTON.setPreferredSize(d);

代码示例来源:origin: kiegroup/optaplanner

  1. private void defineGrid(ScrabbleSolution solution) {
  2. JButton footprint = SwingUtils.makeSmallButton(new JButton("99"));
  3. int footprintWidth = footprint.getPreferredSize().width;
  4. gridPanel.defineColumnHeaderByKey(HEADER_COLUMN);
  5. for (int x = 0; x < solution.getGridWidth(); x++) {
  6. gridPanel.defineColumnHeader(x, footprintWidth);
  7. }
  8. gridPanel.defineRowHeaderByKey(HEADER_ROW);
  9. for (int y = 0; y < solution.getGridHeight(); y++) {
  10. gridPanel.defineRowHeader(y);
  11. }
  12. gridPanel.defineRowHeader(null); // Unassigned
  13. }

代码示例来源:origin: kiegroup/optaplanner

  1. private void defineGrid(TravelingTournament travelingTournament) {
  2. JButton footprint = SwingUtils.makeSmallButton(new JButton("MMMMM"));
  3. int footprintWidth = footprint.getPreferredSize().width;
  4. teamsPanel.defineColumnHeaderByKey(HEADER_COLUMN); // Day header
  5. for (Team team : travelingTournament.getTeamList()) {
  6. teamsPanel.defineColumnHeader(team, footprintWidth);
  7. }
  8. teamsPanel.defineColumnHeader(null, footprintWidth); // Unassigned
  9. teamsPanel.defineRowHeaderByKey(HEADER_ROW); // Team header
  10. for (Day day : travelingTournament.getDayList()) {
  11. teamsPanel.defineRowHeader(day);
  12. }
  13. teamsPanel.defineRowHeader(null); // Unassigned day
  14. }

代码示例来源:origin: kiegroup/optaplanner

  1. private void defineGrid(Examination examination) {
  2. JButton footprint = SwingUtils.makeSmallButton(new JButton("99999999"));
  3. int footprintWidth = footprint.getPreferredSize().width;
  4. roomsPanel.defineColumnHeaderByKey(HEADER_COLUMN); // Period header
  5. for (Room room : examination.getRoomList()) {
  6. roomsPanel.defineColumnHeader(room, footprintWidth);
  7. }
  8. roomsPanel.defineColumnHeader(null, footprintWidth); // Unassigned
  9. roomsPanel.defineRowHeaderByKey(HEADER_ROW); // Room header
  10. for (Period period : examination.getPeriodList()) {
  11. roomsPanel.defineRowHeader(period);
  12. }
  13. roomsPanel.defineRowHeader(null); // Unassigned period
  14. }

代码示例来源:origin: kiegroup/optaplanner

  1. private void defineGrid(PatientAdmissionSchedule patientAdmissionSchedule) {
  2. JButton footprint = SwingUtils.makeSmallButton(new JButton("Patient9999"));
  3. int footprintWidth = footprint.getPreferredSize().width;
  4. timeTablePanel.defineColumnHeaderByKey(HEADER_COLUMN_GROUP2); // Department Header
  5. timeTablePanel.defineColumnHeaderByKey(HEADER_COLUMN_GROUP1); // Room Header
  6. timeTablePanel.defineColumnHeaderByKey(HEADER_COLUMN); // Bed Header
  7. for (Night night : patientAdmissionSchedule.getNightList()) {
  8. timeTablePanel.defineColumnHeader(night, footprintWidth);
  9. }
  10. timeTablePanel.defineRowHeaderByKey(HEADER_ROW); // Night header
  11. timeTablePanel.defineRowHeader(null); // Unassigned bed
  12. for (Bed bed : patientAdmissionSchedule.getBedList()) {
  13. timeTablePanel.defineRowHeader(bed);
  14. }
  15. }

代码示例来源:origin: kiegroup/optaplanner

  1. private void defineGrid(TennisSolution tennisSolution) {
  2. JButton footprint = SwingUtils.makeSmallButton(new JButton("999999"));
  3. int footprintWidth = footprint.getPreferredSize().width;
  4. datesPanel.defineColumnHeaderByKey(HEADER_COLUMN);
  5. for (Day day : tennisSolution.getDayList()) {
  6. datesPanel.defineColumnHeader(day, footprintWidth);
  7. }
  8. datesPanel.defineColumnHeaderByKey(TRAILING_HEADER_COLUMN); // Assignment count
  9. datesPanel.defineRowHeaderByKey(HEADER_ROW);
  10. for (Team team : tennisSolution.getTeamList()) {
  11. datesPanel.defineRowHeader(team);
  12. }
  13. datesPanel.defineRowHeader(null); // Unassigned
  14. confrontationsPanel.defineColumnHeaderByKey(HEADER_COLUMN);
  15. for (Team team : tennisSolution.getTeamList()) {
  16. confrontationsPanel.defineColumnHeader(team);
  17. }
  18. confrontationsPanel.defineRowHeaderByKey(HEADER_ROW);
  19. for (Team team : tennisSolution.getTeamList()) {
  20. confrontationsPanel.defineRowHeader(team);
  21. }
  22. }

代码示例来源:origin: kiegroup/optaplanner

  1. private void defineGrid(CourseSchedule courseSchedule) {
  2. JButton footprint = SwingUtils.makeSmallButton(new JButton("LinLetGre1-0"));
  3. int footprintWidth = footprint.getPreferredSize().width;

代码示例来源:origin: kiegroup/optaplanner

  1. private void defineGrid(InvestmentSolution solution) {
  2. JButton footprint = SwingUtils.makeSmallButton(new JButton("99999999"));
  3. int footprintWidth = footprint.getPreferredSize().width;

代码示例来源:origin: org.netbeans.api/org-openide-awt

  1. @Override
  2. public Dimension getPreferredSize() {
  3. Component[] comps = getAllComponents();
  4. Insets insets = getInsets();
  5. int width = null == insets ? 0 : insets.left + insets.right;
  6. int height = null == insets ? 0 : insets.top + insets.bottom;
  7. for (int i = 0; i < comps.length; i++) {
  8. Component comp = comps[i];
  9. if (!comp.isVisible()) {
  10. continue;
  11. }
  12. width += getOrientation() == HORIZONTAL ? comp.getPreferredSize().width : comp.getPreferredSize().height;
  13. height = Math.max( height, getOrientation() == HORIZONTAL ? comp.getPreferredSize().height : comp.getPreferredSize().width );
  14. }
  15. if(overflowToolbar.getComponentCount() > 0) {
  16. width += getOrientation() == HORIZONTAL ? overflowButton.getPreferredSize().width : overflowButton.getPreferredSize().height;
  17. }
  18. Dimension dim = getOrientation() == HORIZONTAL ? new Dimension(width, height) : new Dimension(height, width);
  19. return dim;
  20. }

代码示例来源:origin: magefree/mage

  1. needButtonSizeW = Math.max(needButtonSizeW, button.getPreferredSize().width);

代码示例来源:origin: winder/Universal-G-Code-Sender

  1. if (button.getPreferredSize().width > maxWidth) maxWidth = button.getPreferredSize().width;
  2. if (button.getPreferredSize().height > maxHeight) maxHeight = button.getPreferredSize().height;

代码示例来源:origin: org.netbeans.api/org-openide-awt

  1. int sizeSoFar = 0;
  2. int maxSize = getOrientation() == HORIZONTAL ? getWidth() : getHeight();
  3. int overflowButtonSize = getOrientation() == HORIZONTAL ? overflowButton.getPreferredSize().width : overflowButton.getPreferredSize().height;
  4. int showingButtons = 0; // all that return true from isVisible()
  5. int visibleButtons = 0; // all visible that fit into the given space (maxSize)

代码示例来源:origin: freeplane/freeplane

  1. private int getPreferredWidth(JButton[] buttons) {
  2. double maxButtonWidth = 0;
  3. for (JButton button : buttons) {
  4. final Dimension size = button.getPreferredSize();
  5. if (size.getWidth() > maxButtonWidth)
  6. maxButtonWidth = size.getWidth();
  7. }
  8. // activate/deactivate exclude each other -> -1
  9. int spacer = ButtonsInCellRenderer.BUTTON_SPACER;
  10. return (int) ((buttons.length - 1) * (maxButtonWidth + spacer)) + spacer;
  11. }

代码示例来源:origin: stackoverflow.com

  1. JButton button = new JButton("+");
  2. Dimension size = button.getPreferredSize();
  3. size.x += 6;
  4. size.y += 6;
  5. button.setPreferredSize(size);
  6. Rectangle rectangle = new Rectangle(3, 3, size.x - 3, size.y - 3);
  7. ScreenImage buttonImage = ScreenImage(button, rectangle);
  8. ImageIcon icon = new ImageIcon(buttonImage);
  9. JButton plus = new JButton(icon);
  10. plus.setBorder( ... );

代码示例来源:origin: protegeproject/protege

  1. public Dimension preferredLayoutSize(Container parent) {
  2. Insets insets = parent.getInsets();
  3. Dimension dim = tabbedPane.getPreferredSize();
  4. int totalWidth = insets.left + insets.right + 2 * dim.width + button.getPreferredSize().width;
  5. int totalHeight = insets.top + insets.bottom + dim.height;
  6. return new Dimension(totalWidth, totalHeight);
  7. }

相关文章

JButton类方法