Javaでこのカスタムレイアウトを行う方法を教えてもらえますか? 北jpanel gridlayoutにメニューバーを追加し、中央jpanel gridlayoutにボタン+グラフを追加してから、それらをborderlayoutを持つフレームに追加しようとしましたが、何も表示されません。前もって感謝します
class {
JFrame frame ;
static JGraph jgraph ;
final mxGraph graph = new mxGraph() ;
JPanel jpanel = new JPanel() ;
...
public void GraphD() {
JPanel middlePanel = new JPanel (new GridLayout (2, 0));
middlePanel.add(graphComponent);
frame.add (middlePanel、BorderLayout.CENTER); }
public void imgbtn() {
JPanel middlePanel = new JPanel (new GridLayout (2, 0));
JButton imgbtn = new JButton("Export as Image") ;
middlePanel.add(imgbtn);
frame.add (middlePanel, BorderLayout.CENTER);
public void Menu() {
JPanel northPanel = new JPanel (new GridLayout (1, 0));
JMenuBar menuBar;
JMenu menu, submenu;
JMenuItem menuItem;
menuBar = new JMenuBar();
menu = new JMenu("A Menu");
menu.setMnemonic(KeyEvent.VK_A);
menu.getAccessibleContext().setAccessibleDescription(
"The only menu in this program that has menu items");
menuBar.add(menu);
menuItem = new JMenuItem("Option A",
KeyEvent.VK_T);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_1, ActionEvent.ALT_MASK));
menuItem.getAccessibleContext().setAccessibleDescription(
"This doesn't really do anything");
menu.add(menuItem);
menu.addSeparator();
submenu = new JMenu("A submenu");
submenu.setMnemonic(KeyEvent.VK_S);
menuItem = new JMenuItem("An item in the submenu");
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_2, ActionEvent.ALT_MASK));
submenu.add(menuItem);
menuItem = new JMenuItem("Another item");
submenu.add(menuItem);
menu.add(submenu);
northPanel.add(menuBar);
frame.add (northPanel, BorderLayout.CENTER);
}
public static void main(String[] args)
{
GUIquery frame = new GUIquery();
frame.setLayout (new BorderLayout ());
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 320);
frame.setVisible(true);
}
}