Search in sources :

Example 76 with MouseEvent

use of java.awt.event.MouseEvent in project adempiere by adempiere.

the class PDFViewerBean method createActionButton.

protected JButton createActionButton(Action action, String text, String image, String tooltip) {
    final ImageIcon icon = new ImageIcon(getClass().getResource(image));
    final double colorFactor = 0.9;
    final RGBImageFilter filter = new RGBImageFilter() {

        public int filterRGB(int x, int y, int rgb) {
            final int alpha = (rgb >> 24) & 0xff;
            final int red = (rgb >> 16) & 0xff;
            final int green = (rgb >> 8) & 0xff;
            final int blue = (rgb) & 0xff;
            return ((int) (alpha * colorFactor) << 24) | ((int) (red * colorFactor) << 16) | ((int) (green * colorFactor) << 8) | ((int) (blue * colorFactor));
        }
    };
    final ImageIcon darkerIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(icon.getImage().getSource(), filter)));
    final JButton result = new JButton();
    result.setAction(action);
    result.setText(text);
    result.setIcon(darkerIcon);
    result.setBorderPainted(false);
    result.setHorizontalTextPosition(SwingConstants.CENTER);
    result.setVerticalTextPosition(SwingConstants.BOTTOM);
    result.setMnemonic(0);
    result.setToolTipText(tooltip);
    final Dimension dim = result.getPreferredSize();
    result.setMaximumSize(new Dimension(32, dim.height));
    result.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent me) {
            result.setBorderPainted(true);
            result.setIcon(icon);
        }

        public void mouseExited(MouseEvent me) {
            result.setBorderPainted(false);
            result.setIcon(darkerIcon);
        }
    });
    result.setBorderPainted(false);
    result.setFocusPainted(false);
    return result;
}
Also used : ImageIcon(javax.swing.ImageIcon) RGBImageFilter(java.awt.image.RGBImageFilter) MouseEvent(java.awt.event.MouseEvent) FilteredImageSource(java.awt.image.FilteredImageSource) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension)

Example 77 with MouseEvent

use of java.awt.event.MouseEvent in project adempiere by adempiere.

the class VSortTab method jbInit.

/**
	 * 	Static Layout
	 * 	@throws Exception
	 */
private void jbInit() throws Exception {
    this.setLayout(mainLayout);
    //
    noLabel.setText("No");
    yesLabel.setText("Yes");
    for (MouseMotionListener mml : noList.getMouseMotionListeners()) noList.removeMouseMotionListener(mml);
    for (MouseMotionListener mml : yesList.getMouseMotionListeners()) yesList.removeMouseMotionListener(mml);
    MouseListener mouseListener = new MouseAdapter() {

        public void mouseClicked(MouseEvent me) {
            if (me.getClickCount() > 1) {
                JList list = (JList) me.getComponent();
                Point p = me.getPoint();
                int index = list.locationToIndex(p);
                if (index > -1 && list.getCellBounds(index, index).contains(p))
                    migrateValueAcrossLists(me);
            }
        }
    };
    yesList.addMouseListener(mouseListener);
    noList.addMouseListener(mouseListener);
    //
    yesList.setCellRenderer(listRenderer);
    noList.setCellRenderer(listRenderer);
    ActionListener actionListener = new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            migrateValueAcrossLists(ae);
        }
    };
    bAdd.setIcon(Env.getImageIcon("Detail24.gif"));
    bAdd.setMargin(new Insets(2, 2, 2, 2));
    bAdd.addActionListener(actionListener);
    bRemove.setIcon(Env.getImageIcon("Parent24.gif"));
    bRemove.setMargin(new Insets(2, 2, 2, 2));
    bRemove.addActionListener(actionListener);
    MouseInputListener crossListMouseListener = new DragListener();
    yesList.addMouseListener(crossListMouseListener);
    yesList.addMouseMotionListener(crossListMouseListener);
    noList.addMouseListener(crossListMouseListener);
    noList.addMouseMotionListener(crossListMouseListener);
    actionListener = new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            migrateValueWithinYesList(ae);
        }
    };
    bUp.setIcon(Env.getImageIcon("Previous24.gif"));
    bUp.setMargin(new Insets(2, 2, 2, 2));
    bUp.addActionListener(actionListener);
    bDown.setIcon(Env.getImageIcon("Next24.gif"));
    bDown.setMargin(new Insets(2, 2, 2, 2));
    bDown.addActionListener(actionListener);
    MouseMotionListener yesListMouseMotionListener = new MouseMotionAdapter() {

        public void mouseDragged(MouseEvent me) {
            JList list = (JList) me.getComponent();
            Point p = me.getPoint();
            int index = list.locationToIndex(p);
            if (index > -1 && list.getCellBounds(index, index).contains(p))
                migrateValueWithinYesList(me);
        }
    };
    yesList.addMouseMotionListener(yesListMouseMotionListener);
    //	Yamel Senih, 2015-11-13
    //	Maximize Panel when the window is resized
    yesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    noList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    this.add(noLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.add(yesLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.add(bDown, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
    this.add(noPane, new GridBagConstraints(0, 1, 1, 3, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    this.add(yesPane, new GridBagConstraints(2, 1, 1, 3, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    this.add(bUp, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
    this.add(bAdd, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
    this.add(bRemove, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
//	End Yamel Senih
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) Point(java.awt.Point) MouseMotionListener(java.awt.event.MouseMotionListener) Point(java.awt.Point) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseListener(java.awt.event.MouseListener) ActionListener(java.awt.event.ActionListener) MouseInputListener(javax.swing.event.MouseInputListener) JList(javax.swing.JList)

Example 78 with MouseEvent

use of java.awt.event.MouseEvent in project adempiere by adempiere.

the class Viewer method dynInit.

//	jbInit
/**
	 * 	Dynamic Init
	 */
private void dynInit() {
    createMenu();
    comboZoom.setSelectedIndex(m_viewPanel.getZoomLevel());
    comboZoom.addActionListener(this);
    //	Change Listener to set Page no
    //pb comment this out so that scrolling works normally
    //centerScrollPane.getViewport().addChangeListener(this);
    // end pb
    //	Default summary from print format
    summary.setSelected(m_reportEngine.getPrintFormat().isSummary());
    //FR 201156
    summary.addActionListener(this);
    //	Max Page
    m_pageMax = m_viewPanel.getPageCount();
    spinnerModel.setMaximum(new Integer(m_pageMax));
    spinner.addChangeListener(this);
    fillComboReport(m_reportEngine.getPrintFormat().get_ID());
    //	View Panel Mouse Listener
    m_viewPanel.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e))
                mouse_clicked(e, true);
            else if (e.getClickCount() > 1)
                mouse_clicked(e, false);
        }
    });
    //	fill Drill Options (Name, TableName)
    comboDrill.addItem(new ValueNamePair(null, ""));
    String sql = "SELECT t.AD_Table_ID, t.TableName, e.PrintName, NULLIF(e.PO_PrintName,e.PrintName) " + "FROM AD_Column c " + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)" + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)" + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')" + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName) " + "WHERE c.AD_Table_ID=? AND c.IsKey='Y' " + "ORDER BY 3";
    boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Element");
    if (trl)
        sql = "SELECT t.AD_Table_ID, t.TableName, et.PrintName, NULLIF(et.PO_PrintName,et.PrintName) " + "FROM AD_Column c" + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)" + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)" + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')" + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName)" + " INNER JOIN AD_Element_Trl et ON (e.AD_Element_ID=et.AD_Element_ID) " + "WHERE c.AD_Table_ID=? AND c.IsKey='Y'" + " AND et.AD_Language=? " + "ORDER BY 3";
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID());
        if (trl)
            pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            String tableName = rs.getString(2);
            String name = rs.getString(3);
            String poName = rs.getString(4);
            if (poName != null)
                name += "/" + poName;
            comboDrill.addItem(new ValueNamePair(tableName, name));
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    if (comboDrill.getItemCount() == 1) {
        labelDrill.setVisible(false);
        comboDrill.setVisible(false);
    } else
        comboDrill.addActionListener(this);
    revalidate();
}
Also used : MouseEvent(java.awt.event.MouseEvent) SQLException(java.sql.SQLException) MouseAdapter(java.awt.event.MouseAdapter) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 79 with MouseEvent

use of java.awt.event.MouseEvent in project adempiere by adempiere.

the class WFActivity method jbInit.

//	dynInit
/**
	 * 	Static Init.
	 * 	Called after Dynamic Init
	 * 	@throws Exception
	 */
private void jbInit() throws Exception {
    int width = 150;
    centerPanel.setLayout(centerLayout);
    fNode.setReadWrite(false);
    fDescription.setReadWrite(false);
    fDescription.setPreferredSize(new Dimension(width, 40));
    fHelp.setReadWrite(false);
    fHelp.setPreferredSize(new Dimension(width, 40));
    fHistory.setReadWrite(false);
    fHistory.setPreferredSize(new Dimension(width, 80));
    fTextMsg.setPreferredSize(new Dimension(width, 40));
    //
    // bPrevious.addActionListener(this);
    // bNext.addActionListener(this);
    selTable.setModel(selTableModel);
    //  0-ID
    selTable.setColumnClass(0, IDColumn.class, false, " ");
    //  1-Priority
    selTable.setColumnClass(1, Integer.class, true);
    //  2-AD_WF_Node_ID
    selTable.setColumnClass(2, String.class, true);
    //  3-Summary
    selTable.setColumnClass(3, String.class, true);
    selTable.getSelectionModel().addListSelectionListener(this);
    // Listen the Column Move Event
    selTable.getColumnModel().addColumnModelListener(new TableColumnModelListener() {

        public void columnMoved(TableColumnModelEvent e) {
            if (columnValue == -1)
                columnValue = e.getFromIndex();
            columnNewValue = e.getToIndex();
        }

        @Override
        public void columnAdded(TableColumnModelEvent e) {
        }

        @Override
        public void columnMarginChanged(ChangeEvent e) {
        }

        @Override
        public void columnRemoved(TableColumnModelEvent e) {
        }

        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
        }
    });
    //Listen the mouse released Moved
    selTable.getTableHeader().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            if (columnValue != -1 && (columnValue == 0 || columnNewValue == 0))
                selTable.moveColumn(columnNewValue, columnValue);
            columnValue = -1;
            columnNewValue = -1;
        }
    });
    bZoom.addActionListener(this);
    bOK.addActionListener(this);
    //
    this.setLayout(new BorderLayout());
    this.add(centerPanel, BorderLayout.CENTER);
    this.add(statusBar, BorderLayout.SOUTH);
    //
    //	answers.setOpaque(false);
    answers.add(fAnswerText);
    answers.add(fAnswerList);
    answers.add(fAnswerButton);
    fAnswerButton.addActionListener(this);
    //
    int row = 0;
    selPane.setPreferredSize(new Dimension(width, 60));
    selPane.setMinimumSize(new Dimension(100, 60));
    centerPanel.add(selPane, new GridBagConstraints(0, row, 4, 1, 0.3, 0.3, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0));
    centerPanel.add(lNode, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
    centerPanel.add(fNode, new GridBagConstraints(1, row, 3, 2, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
    centerPanel.add(lDesctiption, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
    centerPanel.add(fDescription, new GridBagConstraints(1, row, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
    centerPanel.add(lHelp, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(2, 10, 5, 5), 0, 0));
    centerPanel.add(fHelp, new GridBagConstraints(1, row, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 5, 10), 0, 0));
    centerPanel.add(lHistory, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
    centerPanel.add(fHistory, new GridBagConstraints(1, row, 3, 1, 0.5, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 0, 5, 10), 0, 0));
    centerPanel.add(lAnswer, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 10, 5, 5), 0, 0));
    centerPanel.add(answers, new GridBagConstraints(1, row, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 5, 5), 0, 0));
    centerPanel.add(bZoom, new GridBagConstraints(3, row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 10, 10), 0, 0));
    centerPanel.add(lTextMsg, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(5, 10, 5, 5), 0, 0));
    centerPanel.add(fTextMsg, new GridBagConstraints(1, row, 3, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 10), 0, 0));
    centerPanel.add(lForward, new GridBagConstraints(0, ++row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 10, 5, 5), 0, 0));
    centerPanel.add(fForward, new GridBagConstraints(1, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 5, 0), 0, 0));
    centerPanel.add(lOptional, new GridBagConstraints(2, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 5, 5, 5), 0, 0));
    centerPanel.add(bOK, new GridBagConstraints(3, row, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 5, 5, 10), 0, 0));
}
Also used : TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) TableColumnModelListener(javax.swing.event.TableColumnModelListener) GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) ChangeEvent(javax.swing.event.ChangeEvent) BorderLayout(java.awt.BorderLayout) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension)

Example 80 with MouseEvent

use of java.awt.event.MouseEvent in project adempiere by adempiere.

the class BOMTreeFactory method buildTree.

protected void buildTree(PO po, StorageReasoner reasoner) {
    this.reasoner = reasoner;
    tree = new JTree(buildStructure(po, reasoner)) {

        public String getToolTipText(MouseEvent event) {
            return msg.getToolTipText(event);
        }

        ;
    };
    tree.setCellRenderer(new BOMTreeCellRenderer(getNodeMapping()));
    msg = new BOMMessenger(tree);
}
Also used : JTree(javax.swing.JTree) MouseEvent(java.awt.event.MouseEvent)

Aggregations

MouseEvent (java.awt.event.MouseEvent)918 MouseAdapter (java.awt.event.MouseAdapter)595 Dimension (java.awt.Dimension)183 JPanel (javax.swing.JPanel)174 ActionEvent (java.awt.event.ActionEvent)172 JLabel (javax.swing.JLabel)169 Point (java.awt.Point)143 ActionListener (java.awt.event.ActionListener)123 BorderLayout (java.awt.BorderLayout)119 JScrollPane (javax.swing.JScrollPane)113 JButton (javax.swing.JButton)109 KeyEvent (java.awt.event.KeyEvent)85 ChangeEvent (javax.swing.event.ChangeEvent)85 ChangeListener (javax.swing.event.ChangeListener)83 Insets (java.awt.Insets)79 MouseListener (java.awt.event.MouseListener)72 KeyAdapter (java.awt.event.KeyAdapter)65 JPopupMenu (javax.swing.JPopupMenu)64 JSlider (javax.swing.JSlider)63 GridBagConstraints (java.awt.GridBagConstraints)62