我在我的Java應用程序中遇到JMenuBar位置的問題。是否可以移動JMenuBar而不將其添加到JPanel中
我實際上使用article的ComponentResizer.java代碼。
和所有的調整大小工作正常,除了從我的應用程序的北部地區 (未修飾的JFrame)及其角落(北部地區),因爲JMenuBar阻止我從該區域調整大小。
是否有解決方案或者可能是一個黑客移動JMenuBar一點點或啓用調整大小 在北方地區?
我也使用setJMenuBar()
方法將JMenuBar添加到我的應用程序的北部區域。
代碼:
public class MyApp extends JFrame {
private MyApp frame;
private JMenuBar menuBar;
public static void main(String[] args) {
frame = new MyApp();
frame.setUndecorated(true);
frame.setVisible(true);
}
public MyApp(){
initComponents();
}
private void initComponents(){
setTitle("MediaForm");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 673, 482);
menuBar = new JMenuBar();
setJMenuBar(menuBar);
}
}
請編輯您的問題包括[SSCCE(http://sscce.org/)表現出您所描述的問題。無需重複「ComponentResizer」。 – trashgod