Java Code Examples for javax.swing.JButton#getWidth()

The following examples show how to use javax.swing.JButton#getWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequireJsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
        public void mouseClicked(MouseEvent e) {
            Point p = new Point(e.getX(), e.getY());
            int row = table.rowAtPoint(p);
            int col = table.columnAtPoint(p);
            Object value = table.getValueAt(row, col);
            if (isSupportEnabled && value instanceof LocalPathCell) {
                Rectangle cellRect = table.getCellRect(row, col, false);
                LocalPathCell localPathCell = (LocalPathCell) value;
                JButton button = localPathCell.getButton();
                if (e.getX() > (cellRect.x + cellRect.width - button.getWidth())) {
                    //inside changeButton
                    FileObject projectDirectory = project.getProjectDirectory();
                    File newLocation = browseAction(".",
                            "Select somethings", false, FileUtil.toFile(projectDirectory));
                    if (newLocation != null) {
                        localPathCell.setPath(findRelativePath(projectDirectory, FileUtil.toFileObject(newLocation)));
                    }
//                    validateFields();
                }
            }
        }
 
Example 2
Source File: RunAsWebAdvanced.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
    Point p = new Point(e.getX(), e.getY());
    int row = table.rowAtPoint(p);
    int col = table.columnAtPoint(p);
    Object value = table.getValueAt(row, col);
    if (value instanceof LocalPathCell) {
        Rectangle cellRect = table.getCellRect(row, col, false);
        LocalPathCell localPathCell = (LocalPathCell) value;
        JButton button = localPathCell.getButton();
        if (e.getX() > (cellRect.x + cellRect.width - button.getWidth())) {
            //inside changeButton
            File newLocation = Utils.browseLocationAction(LastUsedFolders.DEBUGGER_PATH_MAPPING,
                    NbBundle.getMessage(RunAsWebAdvanced.class, "LBL_SelectProjectFolder"), FileUtil.toFile(ProjectPropertiesSupport.getSourcesDirectory(project)));
            if (newLocation != null) {
                localPathCell.setPath(newLocation.getAbsolutePath());
            }
            validateFields();
        }
    }
}
 
Example 3
Source File: KeymapPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean showPopupMenu(int row, int col, int x, int y) {
    JTable table = actionsTable;
    
    if (col != 1) {
        return false;
    }
    
    Object valueAt = table.getValueAt(row, col);
    ShortcutCellPanel scCell = (ShortcutCellPanel) table.getCellRenderer(row, col).getTableCellRendererComponent(table, valueAt, true, true, row, col);
    Rectangle cellRect = table.getCellRect(row, col, false);
    JButton button = scCell.getButton();
    if (x < 0  || x > (cellRect.x + cellRect.width - button.getWidth())) { //inside changeButton
        boolean isShortcutSet = scCell.getTextField().getText().length() != 0;
        final ShortcutPopupPanel panel = (ShortcutPopupPanel) popup.getComponents()[0];
        panel.setDisplayAddAlternative(isShortcutSet);
        panel.setRow(row);

        if (x == -1 || y == -1) {
            x = button.getX() + 1;
            y = button.getY() + 1;
        }
        panel.setCustomProfile(keymapModel.getMutableModel().isCustomProfile(keymapModel.getMutableModel().getCurrentProfile()));
        popup.show(table, x, y);
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                panel.requestFocus();
            }
        });
        popup.requestFocus();
        return true;
    }
    return false;
}