how to increase JFrame size according to number of JPanel(table) rows in swing

后端 未结 1 340
面向向阳花
面向向阳花 2021-01-23 12:07

I have swing application which does following:

public void init() {
    jFrame = new JFrame();
...
    jFrame.add(sortingDataInputComponent.asComponent()); 
...
         


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-23 12:50

    Implement the Scrollable interface in the component to which you add rows and override getPreferredScrollableViewportSize() as shown here for JTable and here for JList. Invoking pack() on the enclosing Window will cause it to be "sized to fit the preferred size and layouts of its subcomponents."

    0 讨论(0)
提交回复
热议问题