GridBagConstraints
과 함께 양식을 작성하는 데 어려움이 있습니다. gridy
으로 설정하면 작동하지 않는 것 같습니다. 여기 내 코드는 다음과 같습니다.Java Gridbagconstraints gridy 문제
thisWindow = new GridBagConstraints();
thisWindow.insets = new Insets(5, 5, 5, 5);
thisWindow.weightx = 1.0;
thisWindow.weighty = 1.0;
thisWindow.gridheight = 4;
thisWindow.anchor = GridBagConstraints.NORTHWEST;
//set elements
thisWindow.gridx = 0;
thisWindow.gridy = 0;
charScreen.add(nameLbl, thisWindow);
thisWindow.gridx = 1;
thisWindow.gridy = 0;
charScreen.add(charNameCmb, thisWindow);
thisWindow.gridx = 2;
thisWindow.gridy = 0;
charScreen.add(raceLbl, thisWindow);
thisWindow.gridx = 3;
thisWindow.gridy = 0;
charScreen.add(raceCmb, thisWindow);
thisWindow.gridx = 4;
thisWindow.gridy = 0;
charScreen.add(genderLbl, thisWindow);
thisWindow.gridx = 5;
thisWindow.gridy = 0;
charScreen.add(genderCmb, thisWindow);
//This should be on a new line.
thisWindow.gridx = 0;
thisWindow.gridy = 1;
charScreen.add(levelLbl, thisWindow);
thisWindow.gridx = 1;
thisWindow.gridy = 1;
charScreen.add(levelSpn, thisWindow);
thisWindow.gridx = 2;
thisWindow.gridy = 1;
charScreen.add(charClassLbl, thisWindow);
thisWindow.gridx = 3;
thisWindow.gridy = 1;
charScreen.add(charClassCmb, thisWindow);
thisWindow.gridx = 4;
thisWindow.gridy = 1;
charScreen.add(deityLbl, thisWindow);
thisWindow.gridx = 5;
thisWindow.gridy = 1;
charScreen.add(deityCmb, thisWindow);
thisWindow.gridx = 6;
thisWindow.gridy = 1;
charScreen.add(homelandLbl, thisWindow);
thisWindow.gridx = 7;
thisWindow.gridy = 1;
charScreen.add(homelandTxt, thisWindow);
//This should be on a third line.
thisWindow.gridx = 0;
thisWindow.gridy = 2;
charScreen.add(sizeLbl, thisWindow);
thisWindow.gridx = 1;
thisWindow.gridy = 2;
charScreen.add(sizeTxt, thisWindow);
charScreen.setVisible(true);
나는 다양한 앵커를 사용해 보았지만 아무런 도움이되지 않았습니다. 내가 가지고있는 문제는 두 번째 줄과 세 번째 줄에 있어야하는 두 부분이 모두 첫 줄과 겹쳐져 있다는 것입니다. 이것에 대한 조언은 크게 감사드립니다.
가장 좋은 방법은 우리가 완벽하고 신속하게 이해하는 것이 얻으려면 문제는 당신이 작고 그러나 완전한 프로그램 인 [최소 예제 프로그램] (http://stackoverflow.com/help/mcve)을 작성하고 게시하는 것이라면 될 것입니다 문제를 설명하는 데 필요한 코드 만 필요하므로 수정없이 복사, 붙여 넣기, 컴파일 및 실행할 수 있습니다. –