다른 모든 사람들과 반대되는 문제가있는 것 같습니다. JDialog에는 기본적으로 최소화 및 최대화 버튼이 있습니다. 최대화 버튼을 누르면 대화 상자가 최대화되지만 내용은 최대화됩니다. 거대한 대화 상자를 중심으로 동일한 크기로 유지됩니다. 가장자리를 잡고 대화 상자의 크기를 조정할 때도 마찬가지입니다.JDialog가 최대화시 재 레이아웃을 수행하지 않음
WindowStateListener를 추가하려고 시도했지만 결코 호출되지 않습니다. WindowListener를 추가했습니다. 이것은 Open/Close/Activate/Deactivate에서만 호출됩니다.
그래서 대화 상자의 내용을 대화 상자로 다시 가져 오거나 최대화 단추를 제거 할 수 있어야합니다. (최소화 버튼을 없애고 싶습니다.)
대화 상자의 컨트롤이 데이터 블록에서 동적으로 만들어 지므로 pack()을 수행하므로 함께 일할 초기 크기가 없습니다.
자, 여기 코드가 있습니다. 생성 된 모든 UI 패널도 GridBagLayouts에 있습니다.
public class FastAccessDialog extends JDialog implements BeanActionListener {
private static final long serialVersionUID = 1L;
private static final Cursor waitCursor = new Cursor(Cursor.WAIT_CURSOR);
private Cursor oldCursor;
private JPanel cmdOutput;
private JScrollPane cmdOutputScroll;
public FastAccessDialog(Frame owner, ObjectName bean, String methodName) throws InstanceNotFoundException, IntrospectionException,
ReflectionException, IOException {
super(owner);
setResizable(true);
setModal(false);
setTitle(BeanUtil.cleanUpCamelCase(methodName));
boolean enabled = (UIHintUtil.isEnabled(bean) == EnableState.ENABLED);
// Find the BeanOperationInfo for that method.
MBeanInfo info = JMXConnectionSingleton.getInstance().getMBeanInfo(bean);
MBeanOperationInfo[] operations = info.getOperations();
JComponent comp = null;
for (MBeanOperationInfo opInfo : operations) {
if (opInfo.getName().equals(methodName)) {
comp = OperationsManager.getInstance().createControls(bean, opInfo, this, true, enabled);
break;
}
}
if (comp == null) {
throw new IllegalArgumentException("Unknown method name: " + methodName);
}
Container cont = getContentPane();
cont.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
cont.add(comp, gbc);
cont.validate();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
pack();
}
});
return;
}
... other methods invoked when an operation is performed ...
... none of which are invoked before having the re-size problem ...
}
일부 코드를 게시하여 진행 상황을 볼 수 있습니다. 이것은 일반적으로 올바른 LayoutManager를 사용하고 올바르게 구성하는 것과 관련이 있습니다. –
더 나은 도움을 받으려면 [SSCCE] (http://sscce.org/)를 게시하십시오. –