メニュー項目の最小幅を設定しようとしましたが、動作しません。ここにアイテムを作成する私の機能があります:JMenuItem setMinimumSizeが機能しない
private JMenuItem newItem(String text, String iconPath) {
JMenuItem myMenuItem;
if (iconPath == null || iconPath.isEmpty()) {
myMenuItem = new JMenuItem(text);
}
else {
ImageIcon icon = new ImageIcon(iconPath);
myMenuItem = new JMenuItem(text, icon);
}
// this would work, but then setMaximumSize doesn't have any effect
// myMenuItem.setPreferredSize(new Dimension(250,20));
myMenuItem.setMinimumSize(new Dimension(250,20));
myMenuItem.setMaximumSize(new Dimension(350,20));
return myMenuItem;
}
私は間違っていますか?
PS。私は&が
ところで、 "iconPath ==" ""比較は機能しません。 – Bombe
ああ、そうです:)。ありがとう!だから私は文字列comparasionはJavaで静的ではないことを忘れて、言語をスクリプトに使用します。 – stefita
使用しているJavaのバージョンは?どのオペレーティングシステムを使用していますか?どのルックアンドフィールを使用していますか? –