javax.swing.JPanel.setMaximumSize()方法的使用及代码示例

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

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

JPanel.setMaximumSize介绍

暂无

代码示例

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

JPanel a = new JPanel();
 JPanel b = new JPanel();
 JPanel c = new JPanel();
 a.setBackground( Color.RED );
 b.setBackground( Color.GREEN  );
 c.setBackground( Color.BLUE );
 a.setMaximumSize( new Dimension(  10, 10) );
 b.setMaximumSize( new Dimension(  50, 10) );
 a.setAlignmentX( Component.LEFT_ALIGNMENT );//0.0
 b.setAlignmentX( Component.LEFT_ALIGNMENT );//0.0
 c.setAlignmentX( Component.LEFT_ALIGNMENT );//0.0
 JPanel panel = new JPanel();
 panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
 panel.add(a);
 panel.add(b);
 panel.add(c); 
 int result = JOptionPane.showConfirmDialog(null, panel, "Please enter values.", JOptionPane.OK_CANCEL_OPTION);

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

private void contract()
{
  if (pluginPanel == null)
  {
    return;
  }
  pluginPanel.onDeactivate();
  navContainer.setMinimumSize(new Dimension(0, 0));
  navContainer.setMaximumSize(new Dimension(0, 0));
  navContainer.setPreferredSize(new Dimension(0, 0));
  navContainer.revalidate();
  giveClientFocus();
  frame.contractBy(pluginPanel.getWrappedPanel().getPreferredSize().width);
  pluginPanel = null;
}

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

panelControl = new javax.swing.JPanel();
lblCount = new javax.swing.JLabel();
lblLandCount = new javax.swing.JLabel();
setMinimumSize(new java.awt.Dimension(30, 30));
setPreferredSize((!Beans.isDesignTime()) ?
    (GUISizeHelper.editorCardDimension)
    : (new Dimension(600, 600)));
setRequestFocusEnabled(false);
panelControl.setMaximumSize(new java.awt.Dimension(32767, 23));
panelControl.setMinimumSize(new java.awt.Dimension(616, 23));
panelControl.setName(""); // NOI18N

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

JPanel container = new JPanel();
container .setLayout(new BoxLayout(container , BoxLayout.Y_AXIS));

JPanel childTop = new JPanel();
JPanel childCenter = new JPanel();
JPanel childBottom = new JPanel();

childTop.setMaximumSize(...);
childBottom.setMaximumSize(...);

container.add(childTop);
container.add(Box.createVerticalGlue());
container.add(childCenter);
container.add(Box.createVerticalGlue());
container.add(childBottom);

代码示例来源:origin: pentaho/mondrian

jScrollPaneXML = new JScrollPane(jEditorPaneXML);
jPanelXML.setLayout(new java.awt.BorderLayout());
jPanelXML.add(jScrollPaneXML, java.awt.BorderLayout.CENTER);
jPanelXML.add(targetLabel2, java.awt.BorderLayout.NORTH);
jPanelXML.add(validStatusLabel2, java.awt.BorderLayout.SOUTH);
jPanelXML.setMaximumSize(jPanel1.getMaximumSize());
jPanelXML.setPreferredSize(jPanel1.getPreferredSize());
      "Select Join or Table Hierarchy"));
  listEditor.setPreferredSize(
    new java.awt.Dimension(
      listEditor.getPreferredSize().width,
      24)); // Do not remove this

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

JComponent createVisibleComponent(Dimension d) {
  JPanel panel = new JPanel();
  panel.setMinimumSize(d);
  panel.setMaximumSize(d);
  panel.setPreferredSize(d);

  return panel;
}

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

private JPanel getTest1(){
   MigLayout layout = new MigLayout("debug");
   JPanel content = new JPanel(layout);
   content.setMaximumSize(new Dimension(getCenterPanel().getWidth(), 40));
   JCheckBox a1 = new JCheckBox("d");
   content.add(a1, "gapright 10, height 30, width 250, cell 0 0");
   JLabel label = new JLabel();
   label.setBackground(Color.RED);
   label.setOpaque(true);
   content.add(label, "gapright 10, height 30, width 30, cell 1 0");
   JButton btn = new JButton("try again");
   content.add(btn,"height 30, width 80, cell 2 0" );
   return content;
 }

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

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JPanel firstPanel = new JPanel();
firstPanel.setLayout(new GridLayout(4, 4));
firstPanel.setMaximumSize(new Dimension(400, 400));
JButton btn;
for (int i=1; i<=4; i++) {
  for (int j=1; j<=4; j++) {
    btn = new JButton();
    btn.setPreferredSize(new Dimension(100, 100));
    firstPanel.add(btn);
JPanel secondPanel = new JPanel();
secondPanel.setLayout(new GridLayout(5, 13));
secondPanel.setMaximumSize(new Dimension(520, 200));
for (int i=1; i<=5; i++) {
  for (int j=1; j<=13; j++) {
    btn = new JButton();
    btn.setPreferredSize(new Dimension(40, 40));
    secondPanel.add(btn);
mainPanel.add(firstPanel);
mainPanel.add(secondPanel);
frame.setContentPane(mainPanel);

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

public static Component createGap(final int width, final boolean isElastic) {
  final JPanel panel = new JPanel();
  panel.setMinimumSize(new Dimension(width, 0));
  if (!isElastic) {
   panel.setMaximumSize(new Dimension(width, 1000));
  }
  return panel;
 }
}

代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-core

public JComponent build() {
 final JPanel panel = this.isOptimizedDrawingEnabled ? new JPanel() : new JPanel() {
  private static final long serialVersionUID = 1L;
  @Override
  public boolean isOptimizedDrawingEnabled() {
   return false;
  }
 };
 panel.setSize(this.size);
 panel.setMinimumSize(this.minimumSize);
 panel.setMaximumSize(this.maximumSize);
 panel.setPreferredSize(this.preferredSize);
 panel.setBorder(this.border);
 if (this.backGroundColor != null) {
  panel.setBackground(this.backGroundColor);
 }
 if (this.layoutManager != null) {
  panel.setLayout(this.layoutManager);
 }
 if (this.layoutManager == null && this.components.size() == 1) {
  panel.setLayout(new GridLayout(1, 1));
 }
 for (final ObjectPair<Component, Object> pair : this.components) {
  panel.add(pair.getFirstObject(), pair.getSecondObject());
 }
 reset();
 return panel;
}

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

JPanel centerPanel = new JPanel(new BoxLayout());  
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS)); // Y_AXIS will cause the components to be added vertically
centerPanel.add(openReportSelection);
centerPanel.add(closeButton);
centerPanel.setMaximumSize(new Dimension(100, 60)); // Set the maximum horizontal and vertical distances used, as BoxLayouts expand to fill the provided area

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

navContainer.setMinimumSize(new Dimension(width, 0));
navContainer.setMaximumSize(new Dimension(width, Integer.MAX_VALUE));
navContainer.setPreferredSize(new Dimension(width, 0));
navContainer.revalidate();
cardLayout.show(navContainer, button.getTooltip());

代码示例来源:origin: org.ihtsdo/wb-api

private void doRun(final I_EncodeBusinessProcess process, final I_Work worker) {
  try {
    termFactory = Terms.get();
    config = (I_ConfigAceFrame) termFactory.getActiveAceFrameConfig();
    JPanel wfSheet = config.getWorkflowDetailsSheet();
    Component[] components = wfSheet.getComponents();
    for (int i = 0; i < components.length; i++) {
      wfSheet.remove(components[i]);
    }
    wfSheet.setLayout(new GridLayout(1, 1));
    NewRefsetGroupingPanel innerPanel = new NewRefsetGroupingPanel();
    wfSheet.setSize(innerPanel.getPreferredSize());
    wfSheet.setPreferredSize(innerPanel.getPreferredSize());
    wfSheet.setMaximumSize(innerPanel.getMaximumSize());
    wfSheet.setMinimumSize(innerPanel.getMinimumSize());
    wfSheet.add(innerPanel);
    wfSheet.validate();
    wfSheet.repaint();
  } catch (Exception e) {
    ex = e;
  }
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

private void initRightPanel(Container pane) {
  JPanel rightPanel = new JPanel();
  rightPanel.setLayout(new BorderLayout());
  pane.add(rightPanel, BorderLayout.LINE_END);
  rightPanel.add(rightPanelTabs, BorderLayout.LINE_END);
  rightPanelTabs.addTab("annotations", amScrollPane);
  Dimension size = new Dimension(200, 1600);
  mdScrollPane.setPreferredSize(size);
  rightPanelTabs.setMaximumSize(size);
  rightPanel.setMaximumSize(size);

代码示例来源:origin: edu.toronto.cs.savant/savant-core

public final JPanel getPadding(int ps) {
  JPanel p = new JPanel();
  Dimension d = new Dimension(ps, ps);
  p.setMaximumSize(d);
  p.setMinimumSize(d);
  p.setPreferredSize(d);
  p.setOpaque(false);
  return p;
}

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

JComponent createNavigationBox() {
  JButton btnPresent = TranslatedElementFactory.createButtonWithIcon(startPresentationAction, "StartPresentationAction.icon", "slide.present");
  JButton btnStop = TranslatedElementFactory.createButtonWithIcon(stopPresentationAction, "StopPresentationAction.icon", "slide.stop");
  JButton btnFirst = TranslatedElementFactory.createButtonWithIcon(showFirstSlideAction, "ShowFirstSlideAction.icon", "slide.first");
  JButton btnPrevious = TranslatedElementFactory.createButtonWithIcon(showPreviousSlideAction, "ShowPreviousSlideAction.icon", "slide.previous");
  JButton btnNext = TranslatedElementFactory.createButtonWithIcon(showNextSlideAction, "ShowNextSlideAction.icon", "slide.next");
  JButton btnLast = TranslatedElementFactory.createButtonWithIcon(showLastSlideAction, "ShowLastSlideAction.icon", "slide.last");
  JPanel slideButtons = new JPanel(new GridLayout(2, 4));
  Box slideBox = Box.createHorizontalBox();
  TranslatedElementFactory.createTitledBorder(slideBox, "slide.presentation");
  slideButtons.add(new JPanel());
  slideButtons.add(btnPresent);
  slideButtons.add(btnStop);
  slideButtons.add(new JPanel());
  slideButtons.add(btnFirst);
  slideButtons.add(btnPrevious);
  slideButtons.add(btnNext);
  slideButtons.add(btnLast);
  slideButtons.setAlignmentX(Box.CENTER_ALIGNMENT);
  slideButtons.setMaximumSize(slideButtons.getPreferredSize());
  slideBox.add(Box.createHorizontalGlue());
  slideBox.add(slideButtons);
  slideBox.add(Box.createHorizontalGlue());
  return slideBox;
}

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

JPanel centerPanel = new JPanel(new GridLayout(1,0); // The "0" parameter specifies as many rows as needed, but only one column
centerPanel.add(openReportSelection);
centerPanel.add(closeButton);
centerPanel.setMaximumSize(new Dimension(100, 60)); // GridLayouts will also expand to fill the entire area, so you'll probably want some size parameters.

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

private void setGUISize() {
  jSplitPane0.setDividerSize(GUISizeHelper.dividerBarSize);
  jSplitPane1.setDividerSize(GUISizeHelper.dividerBarSize);
  jSplitPane2.setDividerSize(GUISizeHelper.dividerBarSize);
  stackObjects.setCardDimension(GUISizeHelper.handCardDimension);
  txtSpellsCast.setFont(new Font(GUISizeHelper.gameDialogAreaFont.getFontName(), Font.BOLD, GUISizeHelper.gameDialogAreaFont.getSize()));
  txtHoldPriority.setFont(new Font(GUISizeHelper.gameDialogAreaFont.getFontName(), Font.BOLD, GUISizeHelper.gameDialogAreaFont.getSize()));
  GUISizeHelper.changePopupMenuFont(popupMenuTriggerOrder);
  int newStackWidth = pnlHelperHandButtonsStackArea.getWidth() * GUISizeHelper.stackWidth / 100;
  if (newStackWidth < 410) {
    newStackWidth = 410;
  }
  Dimension newDimension = new Dimension(pnlHelperHandButtonsStackArea.getWidth() - newStackWidth, GUISizeHelper.handCardDimension.height + GUISizeHelper.scrollBarSize);
  handContainer.setPreferredSize(newDimension);
  handContainer.setMaximumSize(newDimension);
  newDimension = new Dimension(newStackWidth, STACK_MIN_CARDS_OFFSET_Y + GUISizeHelper.handCardDimension.height + GUISizeHelper.scrollBarSize);
  stackObjects.setPreferredSize(newDimension);
  stackObjects.setMinimumSize(newDimension);
  stackObjects.setMaximumSize(newDimension);
  newDimension = new Dimension(newStackWidth, (int) pnlShortCuts.getPreferredSize().getHeight());
  pnlShortCuts.setPreferredSize(newDimension);
  pnlShortCuts.setMinimumSize(newDimension);
  pnlShortCuts.setMaximumSize(newDimension);
}

代码示例来源:origin: igniterealtime/Smack

JPanel informationPanel = new JPanel();
informationPanel.setLayout(new BoxLayout(informationPanel, BoxLayout.Y_AXIS));
JPanel versionPanel = new JPanel();
versionPanel.setLayout(new BoxLayout(versionPanel, BoxLayout.X_AXIS));
versionPanel.setMaximumSize(new Dimension(2000, 31));
versionPanel.add(new JLabel(" Smack version: "));
JFormattedTextField field = new JFormattedTextField(SmackConfiguration.getVersion());
field.setEditable(false);
field.setBorder(null);
versionPanel.add(field);
informationPanel.add(versionPanel);
JPanel iqProvidersPanel = new JPanel();
iqProvidersPanel.setLayout(new GridLayout(1, 1));
iqProvidersPanel.setBorder(BorderFactory.createTitledBorder("Installed IQ Providers"));

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

JFrame frame = new JFrame ("Test");
frame.setSize (new Dimension (500, 500));
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

Container contentPane = frame.getContentPane ();
contentPane.setLayout (new BoxLayout (contentPane, BoxLayout.PAGE_AXIS));

JPanel row = new JPanel();
row.setBackground (Color.RED);
row.setLayout(new BoxLayout(row, BoxLayout.LINE_AXIS));
row.setMinimumSize (new Dimension (100, 100));
row.setPreferredSize (new Dimension (250, 200));
row.setMaximumSize (new Dimension (500, 300));
contentPane.add(row);

frame.setVisible (true);

相关文章

JPanel类方法