Search in sources :

Example 1 with LayerListCellRenderer

use of org.pepsoft.worldpainter.LayerListCellRenderer in project WorldPainter by Captain-Chaos.

the class CombinedLayerEditor method configureTable.

private void configureTable() {
    tableLayers.setModel(tableModel);
    TableColumn layerColumn = tableLayers.getColumnModel().getColumn(COLUMN_LAYER);
    JComboBox layerCellEditor = new JComboBox(allLayers.toArray());
    layerCellEditor.setRenderer(new LayerListCellRenderer());
    layerColumn.setCellEditor(new DefaultCellEditor(layerCellEditor));
    layerColumn.setCellRenderer(new LayerTableCellRenderer());
    SpinnerModel factorSpinnerModel = new SpinnerNumberModel(100, 1, 1500, 1);
    tableLayers.getColumnModel().getColumn(COLUMN_FACTOR).setCellEditor(new JSpinnerTableCellEditor(factorSpinnerModel));
}
Also used : LayerListCellRenderer(org.pepsoft.worldpainter.LayerListCellRenderer) LayerTableCellRenderer(org.pepsoft.worldpainter.layers.LayerTableCellRenderer) TableColumn(javax.swing.table.TableColumn) JSpinnerTableCellEditor(org.pepsoft.worldpainter.themes.JSpinnerTableCellEditor)

Example 2 with LayerListCellRenderer

use of org.pepsoft.worldpainter.LayerListCellRenderer in project WorldPainter by Captain-Chaos.

the class AddLayerDialog method initComponents.

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    comboBoxLayer = new javax.swing.JComboBox();
    jLabel3 = new javax.swing.JLabel();
    spinnerFactor = new javax.swing.JSpinner();
    jLabel4 = new javax.swing.JLabel();
    checkBoxHide = new javax.swing.JCheckBox();
    buttonCancel = new javax.swing.JButton();
    buttonOK = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Add Layer");
    jLabel1.setText("Select the layer to add:");
    jLabel2.setText("Layer:");
    comboBoxLayer.setModel(new DefaultComboBoxModel(allLayers.toArray()));
    comboBoxLayer.setRenderer(new LayerListCellRenderer());
    jLabel3.setText("Factor:");
    spinnerFactor.setModel(new javax.swing.SpinnerNumberModel(100, 1, 1500, 1));
    jLabel4.setText("%");
    checkBoxHide.setText("Hide from panel:");
    checkBoxHide.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
    buttonCancel.setText("Cancel");
    buttonCancel.addActionListener(this::buttonCancelActionPerformed);
    buttonOK.setText("OK");
    buttonOK.addActionListener(this::buttonOKActionPerformed);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel1).addGroup(layout.createSequentialGroup().addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(comboBoxLayer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18).addComponent(jLabel3).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(spinnerFactor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(0, 0, 0).addComponent(jLabel4).addGap(18, 18, 18).addComponent(checkBoxHide))).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(buttonOK).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(buttonCancel).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel1).addGap(18, 18, 18).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(comboBoxLayer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel3).addComponent(spinnerFactor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel4).addComponent(checkBoxHide)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(buttonCancel).addComponent(buttonOK)).addContainerGap()));
    pack();
}
Also used : LayerListCellRenderer(org.pepsoft.worldpainter.LayerListCellRenderer) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Aggregations

LayerListCellRenderer (org.pepsoft.worldpainter.LayerListCellRenderer)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 TableColumn (javax.swing.table.TableColumn)1 LayerTableCellRenderer (org.pepsoft.worldpainter.layers.LayerTableCellRenderer)1 JSpinnerTableCellEditor (org.pepsoft.worldpainter.themes.JSpinnerTableCellEditor)1