Search in sources :

Example 76 with JCheckBox

use of javax.swing.JCheckBox in project aima-java by aimacode.

the class MapViewFrame method initToolbar.

/**
	 * Defines the functionality of the toolbar by adding components to it.
	 * Override to customize!
	 */
protected void initToolbar() {
    toolbar.setFloatable(false);
    loadButton = new JButton("Load");
    loadButton.setToolTipText("Load Map (<ctrl> bounding box mode, <shift> overview mode)");
    loadButton.addActionListener(this);
    toolbar.add(loadButton);
    saveButton = new JButton("Save");
    saveButton.setToolTipText("Save Visible Map");
    saveButton.addActionListener(this);
    toolbar.add(saveButton);
    statisticsButton = new JButton("Statistics");
    statisticsButton.setToolTipText("Show Map Statistics");
    statisticsButton.addActionListener(this);
    toolbar.add(statisticsButton);
    sidebarCheckBox = new JCheckBox("Sidebar");
    sidebarCheckBox.addActionListener(this);
    sidebarCheckBox.setSelected(false);
    showSidebar(false);
    toolbar.add(sidebarCheckBox);
    InfoField infoField = new InfoField(view, getMap());
    view.addMapViewEventListener(infoField.getMapViewEventListener());
    getMap().addMapDataEventListener(infoField.getMapDataEventListener());
    toolbar.add(infoField);
}
Also used : JCheckBox(javax.swing.JCheckBox) JButton(javax.swing.JButton)

Example 77 with JCheckBox

use of javax.swing.JCheckBox in project adempiere by adempiere.

the class VBOMDrop method actionPerformed.

//	getPreferredSize
/**************************************************************************
	 *	Action Listener
	 *  @param e event
	 */
public void actionPerformed(ActionEvent e) {
    log.config(e.getActionCommand());
    Object source = e.getSource();
    //	Toggle Qty Enabled
    if (source instanceof JCheckBox || source instanceof JRadioButton) {
        cmd_selection(source);
        //	need to de-select the others in group	
        if (source instanceof JRadioButton) {
            //	find Button Group
            Iterator it = m_buttonGroups.values().iterator();
            while (it.hasNext()) {
                ButtonGroup group = (ButtonGroup) it.next();
                Enumeration en = group.getElements();
                while (en.hasMoreElements()) {
                    //	We found the group
                    if (source == en.nextElement()) {
                        Enumeration info = group.getElements();
                        while (info.hasMoreElements()) {
                            Object infoObj = info.nextElement();
                            if (source != infoObj)
                                cmd_selection(infoObj);
                        }
                    }
                }
            }
        }
    } else //	Product / Qty
    if (source == productField || source == productQty) {
        m_qty = (BigDecimal) productQty.getValue();
        KeyNamePair pp = (KeyNamePair) productField.getSelectedItem();
        m_product = MProduct.get(Env.getCtx(), pp.getKey());
        createMainPanel();
        sizeIt();
    } else //	Order
    if (source == orderField) {
        KeyNamePair pp = (KeyNamePair) orderField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (invoiceField != null)
            invoiceField.setReadWrite(!valid);
        if (projectField != null)
            projectField.setReadWrite(!valid);
    } else //	Invoice
    if (source == invoiceField) {
        KeyNamePair pp = (KeyNamePair) invoiceField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (orderField != null)
            orderField.setReadWrite(!valid);
        if (projectField != null)
            projectField.setReadWrite(!valid);
    } else //	Project
    if (source == projectField) {
        KeyNamePair pp = (KeyNamePair) projectField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (orderField != null)
            orderField.setReadWrite(!valid);
        if (invoiceField != null)
            invoiceField.setReadWrite(!valid);
    } else //	OK
    if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
        if (cmd_save())
            dispose();
    } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
        dispose();
    //	Enable OK
    boolean OK = m_product != null;
    if (OK) {
        KeyNamePair pp = null;
        if (orderField != null)
            pp = (KeyNamePair) orderField.getSelectedItem();
        if ((pp == null || pp.getKey() <= 0) && invoiceField != null)
            pp = (KeyNamePair) invoiceField.getSelectedItem();
        if ((pp == null || pp.getKey() <= 0) && projectField != null)
            pp = (KeyNamePair) projectField.getSelectedItem();
        OK = (pp != null && pp.getKey() > 0);
    }
    confirmPanel.getOKButton().setEnabled(OK);
}
Also used : JCheckBox(javax.swing.JCheckBox) JRadioButton(javax.swing.JRadioButton) Enumeration(java.util.Enumeration) ButtonGroup(javax.swing.ButtonGroup) Iterator(java.util.Iterator) KeyNamePair(org.compiere.util.KeyNamePair) BigDecimal(java.math.BigDecimal)

Example 78 with JCheckBox

use of javax.swing.JCheckBox in project adempiere by adempiere.

the class VBOMDrop method addDisplay.

//	addBOMLine
/**
	 * 	Add Line to Display
	 *	@param parentM_Product_ID parent product
	 *	@param M_Product_ID product
	 *	@param bomType bom type
	 *	@param name name
	 *	@param lineQty qty
	 */
private void addDisplay(int parentM_Product_ID, int M_Product_ID, String bomType, String name, String feature, BigDecimal lineQty) {
    log.fine("M_Product_ID=" + M_Product_ID + ",Type=" + bomType + ",Name=" + name + ",feature=" + feature + ",Qty=" + lineQty);
    //
    boolean selected = true;
    if (MPPProductBOMLine.COMPONENTTYPE_Component.equals(bomType)) {
        String title = "";
        JCheckBox cb = new JCheckBox(title);
        cb.setSelected(true);
        cb.setEnabled(false);
        //	cb.addActionListener(this);		//	will not change
        m_selectionList.add(cb);
        this.add(cb, new ALayoutConstraint(m_bomLine++, 0));
    } else if (MPPProductBOMLine.COMPONENTTYPE_Option.equals(bomType)) {
        //String title = Msg.getMsg(Env.getCtx(), "Optional");
        JCheckBox cb = new JCheckBox(feature);
        cb.setSelected(false);
        selected = false;
        cb.addActionListener(this);
        m_selectionList.add(cb);
        this.add(cb, new ALayoutConstraint(m_bomLine++, 0));
    } else if (MPPProductBOMLine.COMPONENTTYPE_Variant.equals(bomType)) {
        //String title = Msg.getMsg(Env.getCtx(), "Variant") + " " + bomType;
        JRadioButton b = new JRadioButton(feature);
        String groupName = feature + "_" + String.valueOf(parentM_Product_ID) + "_" + bomType;
        ButtonGroup group = (ButtonGroup) m_buttonGroups.get(groupName);
        if (group == null) {
            log.fine("ButtonGroup=" + groupName);
            group = new ButtonGroup();
            m_buttonGroups.put(groupName, group);
            group.add(b);
            //	select first one
            b.setSelected(true);
        } else {
            group.add(b);
            b.setSelected(false);
            selected = false;
        }
        b.addActionListener(this);
        m_selectionList.add(b);
        this.add(b, new ALayoutConstraint(m_bomLine++, 0));
    }
    //	Add to List & display
    m_productList.add(new Integer(M_Product_ID));
    VNumber qty = new VNumber("Qty", true, false, true, DisplayType.Quantity, name);
    qty.setValue(lineQty);
    qty.setReadWrite(selected);
    m_qtyList.add(qty);
    CLabel label = new CLabel(name);
    label.setLabelFor(qty);
    this.add(label);
    this.add(qty);
}
Also used : JCheckBox(javax.swing.JCheckBox) CLabel(org.compiere.swing.CLabel) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) VNumber(org.compiere.grid.ed.VNumber)

Example 79 with JCheckBox

use of javax.swing.JCheckBox in project adempiere by adempiere.

the class MiniTable method prepareRenderer.

public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component c = super.prepareRenderer(renderer, row, column);
    JComponent jc = (JComponent) c;
    if (c == null)
        return c;
    //  Row is selected
    Color selectedColor = AdempierePLAF.getFieldBackground_Selected();
    //  Even row
    Color normalColor = AdempierePLAF.getFieldBackground_Normal();
    //  Odd row
    Color backColor = AdempierePLAF.getInfoBackground();
    //  Lead row border
    Color borderColor = AdempierePLAF.getFieldBackground_Mandatory();
    CompoundBorder cb = null;
    ListSelectionModel rsm = this.getSelectionModel();
    boolean readOnly = !this.isCellEditable(row, column);
    if (!(row == rsm.getLeadSelectionIndex())) {
        if (//  Highlighted but not the lead
        rsm.isSelectedIndex(row)) {
            c.setBackground(selectedColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, selectedColor));
        } else if (//  Not selected but even in number
        row % 2 == 0) {
            c.setBackground(normalColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, normalColor));
        } else //  Not selected and odd in number
        {
            // If not shaded, match the table's background
            c.setBackground(backColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, backColor));
        }
        //  Buttons and checkboxes need to have the border turned on
        if (c.getClass().equals(JCheckBox.class)) {
            ((JCheckBox) c).setBorderPainted(false);
        } else if (c.getClass().equals(JButton.class)) {
            ((JButton) c).setBorderPainted(false);
        }
    } else {
        if (c.getClass().equals(JCheckBox.class)) {
            ((JCheckBox) c).setBorderPainted(true);
        } else if (c.getClass().equals(JButton.class)) {
            ((JButton) c).setBorderPainted(true);
        }
        //  Define border - compond border maintains the spacing of 1px around the field
        if (column == 0) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 0, 0, 1)), new MatteBorder(1, 1, 1, 0, borderColor));
        } else if (column == this.getColumnCount() - 1) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 0)), new MatteBorder(1, 0, 1, 1, borderColor));
        } else {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 1)), new MatteBorder(1, 0, 1, 0, borderColor));
        }
        //  Set border
        jc.setBorder(cb);
        //  Set background color
        if (!readOnly && this.isRowChecked(row))
            c.setBackground(normalColor);
        else
            c.setBackground(selectedColor);
    }
    return c;
}
Also used : JCheckBox(javax.swing.JCheckBox) MatteBorder(javax.swing.border.MatteBorder) Insets(java.awt.Insets) Color(java.awt.Color) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) ListSelectionModel(javax.swing.ListSelectionModel) CompoundBorder(javax.swing.border.CompoundBorder) Component(java.awt.Component) JComponent(javax.swing.JComponent) EmptyBorder(javax.swing.border.EmptyBorder)

Example 80 with JCheckBox

use of javax.swing.JCheckBox in project adempiere by adempiere.

the class VProductConfigurationBOM method actionPerformed.

//	getPreferredSize
/**************************************************************************
	 *	Action Listener
	 *  @param e event
	 */
public void actionPerformed(ActionEvent e) {
    log.config(e.getActionCommand());
    Object source = e.getSource();
    //	Toggle Qty Enabled
    if (source instanceof JCheckBox || source instanceof JRadioButton) {
        cmd_selection(source);
        //	need to de-select the others in group	
        if (source instanceof JRadioButton) {
            //	find Button Group
            Iterator it = m_buttonGroups.values().iterator();
            while (it.hasNext()) {
                ButtonGroup group = (ButtonGroup) it.next();
                Enumeration en = group.getElements();
                while (en.hasMoreElements()) {
                    //	We found the group
                    if (source == en.nextElement()) {
                        Enumeration info = group.getElements();
                        while (info.hasMoreElements()) {
                            Object infoObj = info.nextElement();
                            if (source != infoObj)
                                cmd_selection(infoObj);
                        }
                    }
                }
            }
        }
    } else //	Product / Qty
    if (source == productField || source == productQty) {
        m_qty = (BigDecimal) productQty.getValue();
        KeyNamePair pp = (KeyNamePair) productField.getSelectedItem();
        m_product = MProduct.get(Env.getCtx(), pp.getKey());
        createMainPanel();
        sizeIt();
    } else //	Order
    if (source == orderField) {
        KeyNamePair pp = (KeyNamePair) orderField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (invoiceField != null)
            invoiceField.setReadWrite(!valid);
        if (projectField != null)
            projectField.setReadWrite(!valid);
    } else //	Invoice
    if (source == invoiceField) {
        KeyNamePair pp = (KeyNamePair) invoiceField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (orderField != null)
            orderField.setReadWrite(!valid);
        if (projectField != null)
            projectField.setReadWrite(!valid);
    } else //	Project
    if (source == projectField) {
        KeyNamePair pp = (KeyNamePair) projectField.getSelectedItem();
        boolean valid = (pp != null && pp.getKey() > 0);
        //
        if (orderField != null)
            orderField.setReadWrite(!valid);
        if (invoiceField != null)
            invoiceField.setReadWrite(!valid);
    } else //	OK
    if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
        if (cmd_save())
            dispose();
    } else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
        dispose();
    //	Enable OK
    boolean OK = m_product != null;
    if (OK) {
        KeyNamePair pp = null;
        if (orderField != null)
            pp = (KeyNamePair) orderField.getSelectedItem();
        if ((pp == null || pp.getKey() <= 0) && invoiceField != null)
            pp = (KeyNamePair) invoiceField.getSelectedItem();
        if ((pp == null || pp.getKey() <= 0) && projectField != null)
            pp = (KeyNamePair) projectField.getSelectedItem();
        OK = (pp != null && pp.getKey() > 0);
    }
    confirmPanel.getOKButton().setEnabled(OK);
}
Also used : JCheckBox(javax.swing.JCheckBox) JRadioButton(javax.swing.JRadioButton) Enumeration(java.util.Enumeration) ButtonGroup(javax.swing.ButtonGroup) Iterator(java.util.Iterator) org.eevolution.form.bom.nodeUserObject(org.eevolution.form.bom.nodeUserObject) KeyNamePair(org.compiere.util.KeyNamePair) BigDecimal(java.math.BigDecimal)

Aggregations

JCheckBox (javax.swing.JCheckBox)491 JPanel (javax.swing.JPanel)199 JLabel (javax.swing.JLabel)155 JButton (javax.swing.JButton)108 ActionEvent (java.awt.event.ActionEvent)98 ActionListener (java.awt.event.ActionListener)93 JTextField (javax.swing.JTextField)88 GridBagConstraints (java.awt.GridBagConstraints)82 GridBagLayout (java.awt.GridBagLayout)77 Insets (java.awt.Insets)66 BorderLayout (java.awt.BorderLayout)63 Dimension (java.awt.Dimension)59 BoxLayout (javax.swing.BoxLayout)56 JScrollPane (javax.swing.JScrollPane)38 ItemEvent (java.awt.event.ItemEvent)37 ItemListener (java.awt.event.ItemListener)34 FlowLayout (java.awt.FlowLayout)33 JComboBox (javax.swing.JComboBox)33 JRadioButton (javax.swing.JRadioButton)32 Box (javax.swing.Box)30