本文整理了Java中javax.swing.JMenuBar.getPreferredSize()
方法的一些代码示例,展示了JMenuBar.getPreferredSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuBar.getPreferredSize()
方法的具体详情如下:
包路径:javax.swing.JMenuBar
类名称:JMenuBar
方法名:getPreferredSize
暂无
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(Math.max(IMAGE_WIDTH, size.width), Math.max(
size.height, IMAGE_HEIGHT));
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
public Dimension getPreferredSize()
{
Dimension size = super.getPreferredSize();
return new Dimension(
Math.max(IMAGE_WIDTH, size.width),
Math.max(size.height, IMAGE_HEIGHT));
}
}
代码示例来源:origin: com.github.insubstantial/substance
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
int iSize = SubstanceSizeUtils.getTitlePaneIconSize();
return new Dimension(Math.max(iSize, size.width), Math.max(
size.height, iSize));
}
}
代码示例来源:origin: com.github.insubstantial/substance
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
int iSize = SubstanceSizeUtils.getTitlePaneIconSize();
return new Dimension(Math.max(iSize, size.width), Math.max(
size.height, iSize));
}
}
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
public Dimension getMaximumSize()
{ // HACK - Not sure why menu takes up 1/2 of screen...?
return new Dimension(super.getMaximumSize().width, super.getPreferredSize().height);
}
};
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
public Dimension getMaximumSize()
{ // HACK - Not sure why menu takes up 1/2 of screen...?
return new Dimension(super.getMaximumSize().width, super.getPreferredSize().height);
}
};
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
public Dimension getMaximumSize()
{ // HACK - Not sure why menu takes up 1/2 of screen...?
return new Dimension(super.getMaximumSize().width, super.getPreferredSize().height);
}
};
代码示例来源:origin: org.java.net.substance/substance
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
int iSize = SubstanceSizeUtils.getTitlePaneIconSize();
return new Dimension(Math.max(iSize, size.width), Math.max(
size.height, iSize));
}
}
代码示例来源:origin: com.jtattoo/JTattoo
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
Image image = getFrameIconImage();
if (image != null) {
int iw = image.getWidth(null);
int ih = image.getHeight(null);
int th = computeHeight();
if (ih > th) {
double scale = (double)th / (double)ih;
iw = (int)(scale * iw);
ih = (int)(scale * ih);
}
return new Dimension(Math.max(iw, size.width), Math.max(ih, size.height));
} else {
return size;
}
}
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/**
* Returns the amount of space the layout would like to have.
*
* @param parent the Container for which this layout manager
* is being used
* @return a Dimension object containing the layout's preferred size
*/
@Override
public Dimension preferredLayoutSize(Container parent) {
Dimension rd, mbd;
Insets i = rootPane.getInsets();
Container contentPane = rootPane.getContentPane();
JMenuBar menuBar = rootPane.getJMenuBar();
if (contentPane.isVisible()) {
rd = contentPane.getPreferredSize();
} else {
rd = new Dimension(0, contentPane.getPreferredSize().height);
}
if (menuBar != null && menuBar.isVisible()) {
mbd = menuBar.getPreferredSize();
} else {
mbd = new Dimension(0, 0);
}
return new Dimension(Math.max(rd.width, mbd.width) + i.left + i.right,
rd.height + mbd.height + i.top + i.bottom);
}
代码示例来源:origin: stackoverflow.com
JMenuBar createCustomMenu() {
final CardLayout layout = new CardLayout();
final JMenuBar menu = new JMenuBar();
menu.setLayout(layout);
// Here you should create the normal, wide menu
JComponent normalMenu = createNormalMenu();
// Here you create the compressed, one button version
JComponent compressedMenu = createCompressedMenu();
menu.add(normalMenu, "normal");
menu.add(compressedMenu, "compressed");
menu.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
if (menu.getPreferredSize().getWidth() > menu.getWidth()) {
layout.show(menu, "compressed");
} else {
layout.show(menu, "normal");
}
}
});
return menu;
}
代码示例来源:origin: org.gephi/desktop-banner
@Override
public Dimension preferredLayoutSize(Container parent) {
int contentWidth = 0;
int menuWidth = 0;
int height = 0;
JRootPane rootPane = (JRootPane) parent;
// hideMenu(rootPane);
Insets insets = parent.getInsets();
height += insets.top + insets.bottom;
Dimension contentSize;
if (rootPane.getContentPane() != null) {
contentSize = rootPane.getContentPane().getPreferredSize();
} else {
contentSize = rootPane.getSize();
}
contentWidth = contentSize.width;
height += contentSize.height;
if (rootPane.getJMenuBar() != null && rootPane.getJMenuBar().isVisible()) {
Dimension menuSize = rootPane.getJMenuBar().getPreferredSize();
height += menuSize.height;
menuWidth = menuSize.width;
}
return new Dimension(Math.max(contentWidth, menuWidth) + insets.left + insets.right, height);
}
代码示例来源:origin: com.jtattoo/JTattoo
mbd = root.getJMenuBar().getPreferredSize();
if (mbd != null) {
mbWidth = mbd.width;
代码示例来源:origin: nl.cloudfarming.client/menu
@Override
public Dimension preferredLayoutSize(Container parent) {
int contentWidth = 0;
int menuWidth = 0;
int height = 0;
JRootPane rootPane = (JRootPane) parent;
hideMenu(rootPane);
Insets insets = parent.getInsets();
height += insets.top + insets.bottom;
Dimension contentSize;
if (rootPane.getContentPane() != null) {
contentSize = rootPane.getContentPane().getPreferredSize();
} else {
contentSize = rootPane.getSize();
}
contentWidth = contentSize.width;
height += contentSize.height;
if (rootPane.getJMenuBar() != null && rootPane.getJMenuBar().isVisible()) {
Dimension menuSize = rootPane.getJMenuBar().getPreferredSize();
height += menuSize.height;
menuWidth = menuSize.width;
}
return new Dimension(Math.max(contentWidth, menuWidth) + insets.left + insets.right, height);
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
Dimension mbd = menuBar.getPreferredSize();
menuBar.setBounds(0, 0, w, mbd.height);
contentY += mbd.height;
代码示例来源:origin: net.java.openjdk.cacio/cacio-shared
insets.top += jmb.getPreferredSize().height;
代码示例来源:origin: org.gephi/desktop-banner
Dimension size = menu.getPreferredSize();
menu.setBounds(x, y, w, size.height);
y += size.height;
代码示例来源:origin: nl.cloudfarming.client/menu
Dimension size = menu.getPreferredSize();
menu.setBounds(x, y, w, size.height);
y += size.height;
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf
Dimension mbd = root.getJMenuBar().getPreferredSize();
root.getJMenuBar().setBounds(0, nextY, w, mbd.height);
nextY += mbd.height;
代码示例来源:origin: com.jtattoo/JTattoo
Dimension mbd = root.getJMenuBar().getPreferredSize();
root.getJMenuBar().setBounds(0, nextY, w, mbd.height);
nextY += mbd.height;
内容来源于网络,如有侵权,请联系作者删除!