use of javax.swing.table.TableColumn in project SE2017_4_tuna by SE-admin.
the class Frame4 method setTableCellRenderer.
private void setTableCellRenderer(JTable table, TableCellRenderer renderer) {
TableColumnModel columnModel = table.getColumnModel();
int columnCount = columnModel.getColumnCount();
for (int i = 0; i < columnCount; i++) {
TableColumn column = columnModel.getColumn(i);
column.setCellRenderer(renderer);
}
}
use of javax.swing.table.TableColumn in project SE2017_4_tuna by SE-admin.
the class MainFrame method setTableCellRenderer.
private void setTableCellRenderer(JTable table, TableCellRenderer renderer) {
TableColumnModel columnModel = table.getColumnModel();
int columnCount = columnModel.getColumnCount();
for (int i = 0; i < columnCount; i++) {
TableColumn column = columnModel.getColumn(i);
column.setCellRenderer(renderer);
}
}
use of javax.swing.table.TableColumn in project intellij-community by JetBrains.
the class SwingUpdaterUI method askUser.
@Override
public Map<String, ValidationResult.Option> askUser(List<ValidationResult> validationResults) throws OperationCancelledException {
Map<String, ValidationResult.Option> result = new HashMap<>();
try {
SwingUtilities.invokeAndWait(() -> {
boolean proceed = true;
for (ValidationResult result1 : validationResults) {
if (result1.options.contains(ValidationResult.Option.NONE)) {
proceed = false;
break;
}
}
final JDialog dialog = new JDialog(myFrame, TITLE, true);
dialog.setLayout(new BorderLayout());
dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setBorder(BUTTONS_BORDER);
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
buttonsPanel.add(Box.createHorizontalGlue());
JButton cancelButton = new JButton(CANCEL_BUTTON_TITLE);
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
isCancelled.set(true);
myCancelButton.setEnabled(false);
dialog.setVisible(false);
}
});
buttonsPanel.add(cancelButton);
if (proceed) {
JButton proceedButton = new JButton(PROCEED_BUTTON_TITLE);
proceedButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.setVisible(false);
}
});
buttonsPanel.add(proceedButton);
dialog.getRootPane().setDefaultButton(proceedButton);
} else {
dialog.getRootPane().setDefaultButton(cancelButton);
}
JTable table = new JTable();
table.setCellSelectionEnabled(true);
table.setDefaultEditor(ValidationResult.Option.class, new MyCellEditor());
table.setDefaultRenderer(Object.class, new MyCellRenderer());
MyTableModel model = new MyTableModel(validationResults);
table.setModel(model);
for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
TableColumn each = table.getColumnModel().getColumn(i);
each.setPreferredWidth(MyTableModel.getColumnWidth(i, new Dimension(600, 400).width));
}
String message = "<html>Some conflicts were found in the installation area.<br><br>";
if (proceed) {
message += "Please select desired solutions from the " + MyTableModel.COLUMNS[MyTableModel.OPTIONS_COLUMN_INDEX] + " column and press " + PROCEED_BUTTON_TITLE + ".<br>" + "If you do not want to proceed with the update, please press " + CANCEL_BUTTON_TITLE + ".</html>";
} else {
message += "Some of the conflicts below do not have a solution, so the patch cannot be applied.<br>" + "Press " + CANCEL_BUTTON_TITLE + " to exit.</html>";
}
JLabel label = new JLabel(message);
label.setBorder(LABEL_BORDER);
dialog.add(label, BorderLayout.NORTH);
dialog.add(new JScrollPane(table), BorderLayout.CENTER);
dialog.add(buttonsPanel, BorderLayout.SOUTH);
dialog.getRootPane().setBorder(FRAME_BORDER);
dialog.setSize(new Dimension(600, 400));
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
result.putAll(model.getResult());
});
} catch (InterruptedException | InvocationTargetException e) {
throw new RuntimeException(e);
}
checkCancelled();
return result;
}
use of javax.swing.table.TableColumn in project zaproxy by zaproxy.
the class TableColumnManager method columnMoved.
@Override
public void columnMoved(TableColumnModelEvent e) {
if (e.getFromIndex() == e.getToIndex()) {
return;
}
// A table column has been moved one position to the left or right
// in the view of the table so we need to update the manager to
// track the new location
int index = e.getToIndex();
TableColumn column = columnModel.getColumn(index);
allColumns.remove(column);
if (index == 0) {
allColumns.add(0, column);
} else {
index--;
TableColumn visibleColumn = columnModel.getColumn(index);
int insertionColumn = allColumns.indexOf(visibleColumn);
allColumns.add(insertionColumn + 1, column);
}
}
use of javax.swing.table.TableColumn in project zaproxy by zaproxy.
the class HttpPanelParamTableView method setEditable.
@Override
public void setEditable(boolean editable) {
if (isEditable != editable) {
if (isEditable) {
table.getColumnModel().removeColumn(table.getColumnModel().getColumn(3));
} else {
TableColumn column = new TableColumn(3, 150, new ComboBoxCellRenderer(comboBoxAddIns), new DefaultCellEditor(comboBoxAddIns));
column.setPreferredWidth(150);
column.setMaxWidth(150);
table.addColumn(column);
}
isEditable = editable;
httpPanelTabularModel.setEditable(editable);
}
}
Aggregations