0
나는 3 개의 패널을 가진 어플리케이션을 만들었습니다. 상태, btn 및 상단 패널. 일부 단추는 btn 패널에 추가되고 일부 레이블은 상태 패널에 있고 일부 텍스트 필드는 상단 패널에 추가되었습니다. 이 모든 패널은 JFrame에 추가됩니다. 이 모든 것을 JScroller에 넣고 싶었습니다. 나는이 일을하는 방법에 대해 확신하지 못한다. 나는 모든 것을 놓은 방법을 보여주는 코드를 추가했다.JScroll에 패널 추가하기
static FlowLayout topPanelLayout = new FlowLayout();
static GridLayout parentLayout = new GridLayout(0,1);
static GridLayout statusLayout = new GridLayout(2,1);
static JFrame frame = new JFrame("Web API Interface");
static JPanel statusPanel;
static JPanel btnPanel;
static JPanel topPanel; frame.setLayout(parentLayout);
// -- Create Panels
topPanel = new JPanel(topPanelLayout);
statusPanel = new JPanel(statusLayout);
btnPanel = new JPanel(new GridLayout(0,2));
frame.setSize(1100,600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); statusPanel.add(statusLabel);
statusPanel.add(connectionStatusLabel);
statusPanel.add(cidLabel);
// -- add label and textfield at the top panel which is at the top of
// the frame
topPanel.add(new JLabel("Enter IP:"));
topPanel.add(ipAddressField);
// -- 1.) add top panel .... everything goes in order down
frame.getContentPane().add(topPanel);
frame.getContentPane().add(statusPanel);
frame.getContentPane().add(btnPanel);
//Display the window.
frame.setVisible(true);