Swing vertical Navigation Menu

2019-06-14 16:11发布

问题:

I am creating desktop application and design using Swing. i have two panels in frame left and right panel, In the left panel I have buttons, So i want that when i click on button from left panel it should display the result in right panel on same frame. Does i need to create another frame with same left panel and create a right panel for the link , or there is a way for above written method have no idea that how to do this. Like Shown in below Image.

回答1:

I'd lay it out like this (there are other ways as well).

Logically

  • BorderLayout
    1. GridBagLayout (LINE_START)
      • GridLayout
        1. Button 1
        2. Button 2
        3. Button 3
        4. Button 4
    2. CardLayout (CENTER)
      • card Panel 1
      • card Panel 2
      • card Panel 3
      • card Panel 4

Visually