그림과 같이 대화 상자가 열릴 때 버튼 막대가 제대로 표시되지 않는 경우가 있습니다. DefaultTableModel
을위한 awt 프레임을 임베드해야했기 때문에 레이아웃 문제가 발생했다고 생각합니다.JFace 글리치가있는 글리치 대화 상자 버튼 막대
이 문제를 해결하는 방법은 없나요? 또는 jface checkboxtableviewer를 사용해야하나요, 그 좋은 예를 찾을 수 없었습니다.
public class FunctionMaskDialog extends Dialog implements TableModelListener{
private Boolean[] functionChecked;
private JTable table;
private Table table_1;
/**
* Constructor Create the dialog.
*
* @param parentShell
*/
public FunctionMaskDialog(Shell parentShell) {
super(parentShell);
}
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("Function Mask");
}
/**
* Create contents of the button bar.
*
* @param parent
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
getButton(IDialogConstants.OK_ID).addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setFunctionCheckedArray();
}
});
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
getButton(IDialogConstants.CANCEL_ID).addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
}
/**
* Create contents of the dialog.
*
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite container = new Composite(parent, SWT.EMBEDDED);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Frame frame = SWT_AWT.new_Frame(container);
frame.setLayout(null);
frame.setBackground(new Color(240, 240, 240));
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(30, 30, 494, 400);
// Table
table = new JTable();
scrollPane.setViewportView(table);
this.createFunctionTaskTable(table);
frame.add(scrollPane);
return container;
}
/**
* Return the initial size of the dialog.
*/
@Override
protected Point getInitialSize() {
return new Point(600, 530);
}
private void createFunctionTaskTable(JTable table){
// Model for Table
@SuppressWarnings("serial")
DefaultTableModel model = new DefaultTableModel() {
public Class<?> getColumnClass(int column) {
switch (column) {
case 0:
return Boolean.class;
case 1:
return String.class;
default:
return String.class;
}
}
@Override
public boolean isCellEditable(int row, int column) {
if (column == 1)
return false;
else
return true;
}
};
table.setModel(model);
model.addColumn("Select");
model.addColumn("Function Name");
table.getColumnModel().getColumn(0).setPreferredWidth(94);
table.getColumnModel().getColumn(1).setPreferredWidth(400);
// initialize chked array according to the size of task list.
functionChecked = GanttFrame.getFunctionCheckedArray();
model.addTableModelListener(this);
// Data Rows
for (int i = 0; i < GanttFrame.getFunctionTaskList().size(); i++) {
model.addRow(new Object[0]);
model.setValueAt(functionChecked[i], i, 0);
model.setValueAt(GanttFrame.getFunctionTaskList().get(i).getTaskName(), i, 1); // initialize the function names
}
}
private void setFunctionCheckedArray(){
Boolean[] tempArray = functionChecked;
for (int i = 0; i < table.getRowCount(); i++) {
functionChecked[i] = Boolean.valueOf(table.getValueAt(i, 0).toString());
}
if (!tempArray.equals(functionChecked)){
GanttFrame.setFunctionCheckedArray(functionChecked);
}
}
@Override
public void tableChanged(TableModelEvent event) {
DefaultTableModel model = (DefaultTableModel)event.getSource();
if (event.getColumn() == 0){
if (event.getFirstRow() == 0){
}
}
}
}