Example usage for java.awt.event KeyEvent VK_DELETE

List of usage examples for java.awt.event KeyEvent VK_DELETE

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_DELETE.

Prototype

int VK_DELETE

To view the source code for java.awt.event KeyEvent VK_DELETE.

Click Source Link

Document

Constant for the delete key.

Usage

From source file:de.tor.tribes.ui.views.DSWorkbenchSOSRequestAnalyzer.java

/**
 * Creates new form DSWorkbenchSOSRequestAnalyzer
 *//*from w w  w .j a  va2 s.com*/
DSWorkbenchSOSRequestAnalyzer() {
    initComponents();
    centerPanel = new GenericTestPanel(true);
    jSOSPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jSOSInputPanel);
    buildMenu();
    jButton1.setIcon(new ImageIcon("./graphics/big/find.png"));
    capabilityInfoPanel1.addActionListener(DSWorkbenchSOSRequestAnalyzer.this);
    //  KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    //KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    // jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Copy", copy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    // jAttacksTable.registerKeyboardAction(DSWorkbenchSOSRequestAnalyzer.this, "Cut", cut, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttacksTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });

    jAttacksTable.setModel(new DefenseToolModel());
    jAttacksTable.setHighlighters(
            HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jAttacksTable.getColumnExt("Tendenz").setCellRenderer(new TendencyTableCellRenderer());
    jAttacksTable.getColumnExt("Status").setCellRenderer(new DefenseStatusTableCellRenderer());
    //jAttacksTable.getColumnExt("Wall").setCellRenderer(new WallLevellCellRenderer());
    jAttacksTable.getColumnExt("Verlustrate").setCellRenderer(new LossRatioTableCellRenderer());
    jAttacksTable.setDefaultRenderer(Date.class, new DateCellRenderer());
    jAttacksTable.setColumnControlVisible(false);
    jAttacksTable.setDefaultRenderer(Date.class, new DateCellRenderer());
    jAttacksTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jAttacksTable.requestFocus();

    jSupportsTable.setModel(new SupportsModel());
    jSupportsTable.setHighlighters(
            HighlighterFactory.createAlternateStriping(Constants.DS_ROW_A, Constants.DS_ROW_B));
    jSupportsTable.getTableHeader().setDefaultRenderer(new DefaultTableHeaderRenderer());
    jSupportsTable.setDefaultRenderer(Date.class, new ColoredDateCellRenderer());
    jSupportsTable.setDefaultRenderer(Boolean.class,
            new CustomBooleanRenderer(CustomBooleanRenderer.LayoutStyle.SENT_NOTSENT));

    new SupportCountdownThread().start();
    new SupportColorUpdateThread().start();
    jXInfoLabel.setLineWrap(true);

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.sos_analyzer",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java

private void createActions() {

    //file/*from  w  w  w.  j  a v a2  s. co  m*/
    theActionManager.add("print", FileUtils.defaultThemeManager.getImageIcon("print"), "Print...",
            KeyEvent.VK_P, "ctrl P", this);

    //edit

    theActionManager.add("undo", FileUtils.defaultThemeManager.getImageIcon("undo"), "Undo", KeyEvent.VK_U,
            "ctrl Z", this);
    theActionManager.add("redo", FileUtils.defaultThemeManager.getImageIcon("redo"), "Redo", KeyEvent.VK_R,
            "ctrl Y", this);

    theActionManager.add("cut", FileUtils.defaultThemeManager.getImageIcon("cut"), "Cut", KeyEvent.VK_T,
            "ctrl X", this);
    theActionManager.add("copy", FileUtils.defaultThemeManager.getImageIcon("copy"), "Copy", KeyEvent.VK_C,
            "ctrl C", this);
    theActionManager.add("delete", FileUtils.defaultThemeManager.getImageIcon("delete"), "Delete",
            KeyEvent.VK_DELETE, "", this);
    theActionManager.add("screenshot", FileUtils.defaultThemeManager.getImageIcon("screenshot"), "Screenshot",
            KeyEvent.VK_PRINTSCREEN, "PRINTSCREEN", this);

    theActionManager.add("selectall", FileUtils.defaultThemeManager.getImageIcon("selectall"), "Select all",
            KeyEvent.VK_A, "ctrl A", this);
    theActionManager.add("selectnone", FileUtils.defaultThemeManager.getImageIcon("selectnone"), "Select none",
            KeyEvent.VK_E, "ESCAPE", this);

    theActionManager.add("enlarge", FileUtils.defaultThemeManager.getImageIcon("enlarge"),
            "Enlarge selected structures", -1, "", this);
    theActionManager.add("resetsize", FileUtils.defaultThemeManager.getImageIcon("resetsize"),
            "Reset size of selected structures to default value", -1, "", this);
    theActionManager.add("shrink", FileUtils.defaultThemeManager.getImageIcon("shrink"),
            "Shrink selected structures", -1, "", this);

    theActionManager.add("ungroup", FileUtils.defaultThemeManager.getImageIcon("ungroup"),
            "Ungroup selected structures", -1, "", this);
    theActionManager.add("group", FileUtils.defaultThemeManager.getImageIcon("group"),
            "Group selected structures", -1, "", this);

    theActionManager.add("placestructures", FileUtils.defaultThemeManager.getImageIcon("placestructures"),
            "Automatic place all structures", -1, "", this);

    // view
    theActionManager.add("zoomnone", FileUtils.defaultThemeManager.getImageIcon("zoomnone"), "Reset zoom", -1,
            "", this);
    theActionManager.add("zoomin", FileUtils.defaultThemeManager.getImageIcon("zoomin"), "Zoom in", -1, "",
            this);
    theActionManager.add("zoomout", FileUtils.defaultThemeManager.getImageIcon("zoomout"), "Zoom out", -1, "",
            this);

    theActionManager.add("notation=" + GraphicOptions.NOTATION_CFG,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG notation", KeyEvent.VK_C, "", this);
    theActionManager.add("notation=" + GraphicOptions.NOTATION_CFGBW,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG black and white notation", KeyEvent.VK_B, "",
            this);
    theActionManager.add("notation=" + GraphicOptions.NOTATION_CFGLINK,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG with linkage placement notation",
            KeyEvent.VK_L, "", this);
    theActionManager.add("notation=" + GraphicOptions.NOTATION_UOXF,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "UOXF notation", KeyEvent.VK_O, "", this);
    theActionManager.add("notation=" + GraphicOptions.NOTATION_TEXT,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "Text only notation", KeyEvent.VK_T, "", this);

    theActionManager.add("display=" + GraphicOptions.DISPLAY_COMPACT,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "compact view", KeyEvent.VK_O, "", this);
    theActionManager.add("display=" + GraphicOptions.DISPLAY_NORMAL,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "normal view", KeyEvent.VK_N, "", this);
    theActionManager.add("display=" + GraphicOptions.DISPLAY_NORMALINFO,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "normal view with linkage info", KeyEvent.VK_I,
            "", this);
    theActionManager.add("display=" + GraphicOptions.DISPLAY_CUSTOM,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "custom view with user settings", KeyEvent.VK_K,
            "", this);

    theActionManager.add("orientation", getOrientationIcon(), "Change orientation", -1, "", this);

    theActionManager.add("displaysettings", ThemeManager.getEmptyIcon(ICON_SIZE.TINY),
            "Change structure display settings", KeyEvent.VK_S, "", this);
    theActionManager.add("reportsettings", ThemeManager.getEmptyIcon(ICON_SIZE.TINY),
            "Change report display settings", KeyEvent.VK_R, "", this);
}

From source file:de.tor.tribes.ui.views.DSWorkbenchTagFrame.java

/** Creates new form DSWorkbenchTagFrame */
DSWorkbenchTagFrame() {//  ww  w .  jav  a 2  s.c  om
    initComponents();
    centerPanel = new GenericTestPanel();
    jTagPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jTagsPanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);
    jTagsTable.setModel(new TagTableModel());
    jTagsTable.getSelectionModel().addListSelectionListener(DSWorkbenchTagFrame.this);
    jTagsTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });

    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVillageList.registerKeyboardAction(DSWorkbenchTagFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jVillageList.registerKeyboardAction(DSWorkbenchTagFrame.this, "BBCopy_Village", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jTagsTable.registerKeyboardAction(DSWorkbenchTagFrame.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.tag_view",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>

    initialize();
    pack();
}

From source file:org.angnysa.yaba.swing.BudgetFrame.java

private void buildTransactionTable() {
    transactionModel = new TransactionTableModel(service);
    transactionTable = new JTable(transactionModel);
    transactionTable.setRowHeight((int) (transactionTable.getRowHeight() * 1.2));
    transactionTable.getColumnModel().getColumn(TransactionTableModel.COL_END)
            .setCellEditor(new CustomCellEditor(
                    new JFormattedTextField(new OptionalValueFormatter(new JodaLocalDateFormat()))));
    transactionTable.setDefaultEditor(LocalDate.class,
            new CustomCellEditor(new JFormattedTextField(new JodaLocalDateFormat())));
    transactionTable.setDefaultEditor(ReadablePeriod.class,
            new CustomCellEditor(new JFormattedTextField(new OptionalValueFormatter(new JodaPeriodFormat()))));
    transactionTable.setDefaultEditor(Double.class,
            new CustomCellEditor(new JFormattedTextField(NumberFormat.getNumberInstance())));
    transactionTable.setDefaultRenderer(LocalDate.class,
            new FormattedTableCellRenderer(new JodaLocalDateFormat()));
    transactionTable.setDefaultRenderer(ReadablePeriod.class,
            new FormattedTableCellRenderer(new JodaPeriodFormat()));
    transactionTable.setDefaultRenderer(Double.class,
            new FormattedTableCellRenderer(TransactionAmountFormatFactory.getFormat()));
    transactionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    transactionTable.setAutoCreateRowSorter(true);
    transactionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); //$NON-NLS-1$
    transactionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete"); //$NON-NLS-1$
    transactionTable.getActionMap().put("delete", new AbstractAction() { //$NON-NLS-1$
        private static final long serialVersionUID = 1L;

        @Override/*ww  w . j av  a  2s. co  m*/
        public void actionPerformed(ActionEvent e) {

            int row = transactionTable.getSelectedRow();
            if (row >= 0) {
                row = transactionTable.getRowSorter().convertRowIndexToModel(row);
                transactionModel.deleteRow(row);
            }
        }
    });
}

From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java

/**
 * Creates new form DSWorkbenchSelectionFrame
 *//*from ww  w  .  j a  v  a 2  s.  co m*/
DSWorkbenchSelectionFrame() {
    initComponents();
    centerPanel = new GenericTestPanel(true);
    jSelectionPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jSelectionTreePanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);
    treeData = new LinkedList<>();
    jSelectionTree.setCellRenderer(new NodeCellRenderer());

    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Copy", copy,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Delete", delete,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Paste", paste,
            JComponent.WHEN_FOCUSED);
    jSelectionTree.registerKeyboardAction(DSWorkbenchSelectionFrame.this, "Cut", cut, JComponent.WHEN_FOCUSED);
    jSelectionTree.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });
    jSelectionTree.getSelectionModel().addTreeSelectionListener(DSWorkbenchSelectionFrame.this);

    buildTree();

    //<editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.selection_tool",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    //</editor-fold>
}

From source file:de.tor.tribes.ui.views.DSWorkbenchDoItYourselfAttackPlaner.java

/**
 * Creates new form DSWorkbenchDoItYourselflAttackPlaner
 *///from  w  ww. j  av a2s  .c  o  m
DSWorkbenchDoItYourselfAttackPlaner() {
    initComponents();

    jAttackTable.setModel(new DoItYourselfAttackTableModel());
    jAttackTable.getSelectionModel().addListSelectionListener(DSWorkbenchDoItYourselfAttackPlaner.this);

    jArriveTime.setDate(Calendar.getInstance().getTime());
    jNewArriveSpinner.setDate(Calendar.getInstance().getTime());
    capabilityInfoPanel1.addActionListener(this);
    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Paste", paste,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.registerKeyboardAction(DSWorkbenchDoItYourselfAttackPlaner.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jAttackTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //no find
        }
    });

    DoItYourselfCountdownThread thread = new DoItYourselfCountdownThread();
    thread.start();

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.manual_attack_planer",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
    pack();
}

From source file:de.codesourcery.jasm16.ide.ui.views.WorkspaceExplorer.java

private JPanel createPanel() {
    treeModel = createTreeModel();//from ww w  .ja  va2s  .  c o  m
    tree.setModel(treeModel);
    setColors(tree);
    tree.setRootVisible(false);

    //      for (int i = 0; i < tree.getRowCount(); i++) {
    //         tree.expandRow(i);
    //      }

    tree.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                final WorkspaceTreeNode selection = getSelectedNode();
                if (selection != null) {
                    deleteResource(selection);
                }
            } else if (e.getKeyCode() == KeyEvent.VK_F5) {
                refreshWorkspace(null);
            }
        }
    });

    tree.addMouseListener(new MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                final TreePath path = tree.getPathForLocation(e.getX(), e.getY());
                if (path != null) {
                    final WorkspaceTreeNode selected = (WorkspaceTreeNode) path.getLastPathComponent();
                    final IAssemblyProject project = getProject(selected);
                    try {
                        if (project != null) {
                            onTreeNodeLeftClick(project, selected);
                        } else {
                            System.err.println("Unable to locate project for " + selected);
                        }
                    } catch (IOException e1) {
                        LOG.error("mouseClicked(): Internal error", e1);
                    }
                }
            }
        }
    });

    final TreeSelectionListener selectionListener = new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {

        }
    };

    tree.getSelectionModel().addTreeSelectionListener(selectionListener);

    tree.setCellRenderer(new DefaultTreeCellRenderer() {

        public Color getTextSelectionColor() {
            return Color.GREEN;
        };

        public java.awt.Color getTextNonSelectionColor() {
            return Color.GREEN;
        };

        public Color getBackgroundSelectionColor() {
            return Color.BLACK;
        };

        public Color getBackgroundNonSelectionColor() {
            return Color.BLACK;
        };

        public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {

            java.awt.Component result = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
                    row, hasFocus);

            String label = value.toString();
            Color color = getTextColor();
            if (value instanceof WorkspaceTreeNode) {
                if (value instanceof ProjectNode) {
                    final ProjectNode projectNode = (ProjectNode) value;
                    final IAssemblyProject project = projectNode.getValue();
                    label = project.getName();

                    if (project.isClosed()) {
                        color = Color.LIGHT_GRAY;
                    } else {
                        if (projectNode.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                    }
                } else if (value instanceof FileNode) {
                    FileNode fn = (FileNode) value;
                    label = fn.getValue().getName();
                    switch (fn.type) {
                    case DIRECTORY:
                        if (fn.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                        break;
                    case OBJECT_FILE:
                        label = "[O] " + label;
                        break;
                    case EXECUTABLE:
                        label = "[E] " + label;
                        break;
                    case SOURCE_CODE:
                        label = "[S] " + label;
                        if (fn.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                        break;
                    default:
                        // ok
                    }
                }
            }
            setForeground(color);
            setText(label);
            return result;
        };

    });

    setupPopupMenu();

    final JScrollPane pane = new JScrollPane(tree);
    setColors(pane);

    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());
    GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);
    setColors(result);
    result.add(pane, cnstrs);
    return result;
}

From source file:dataviewer.DataViewer.java

/**
 * Creates new form DataViewer/*  ww w .j  a va2s.  c om*/
 */
public DataViewer() {
    try {
        for (Enum ee : THREAD.values()) {
            t[ee.ordinal()] = new Thread();
        }
        initComponents();
        DropTarget dropTarget = new DropTarget(tr_files, new DropTargetListenerImpl());
        TreeSelectionListener treeSelectionListener = new TreeSelectionListener() {

            @Override
            public void valueChanged(TreeSelectionEvent e) {
                javax.swing.JTree tree = (javax.swing.JTree) e.getSource();
                TreePath path = tree.getSelectionPath();
                Object[] pnode = (Object[]) path.getPath();
                String name = pnode[pnode.length - 1].toString();
                String ex = getExtension(name);
                if (ex.equals(".txt") || ex.equals(".dat") || ex.equals(".csv") || ex.equals(".tsv")) {
                    selected_file = name;
                } else {
                    selected_file = "";
                }
            }
        };
        tr_files.addTreeSelectionListener(treeSelectionListener);

        tr_files.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent evt) {
                if (evt.getClickCount() >= 2) {
                    if (!"".equals(selected_file)) {
                        //count_data();
                        read_data();
                    } else {
                        TreePath path = tr_files.getSelectionPath();
                        if (path.getLastPathComponent().toString().equals(cur_path)) {
                            cur_path = (new File(cur_path)).getParent();
                        } else {
                            cur_path = cur_path + File.separator + path.getLastPathComponent().toString();
                        }
                        fill_tree();
                    }
                }
            }
        });

        tr_files.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent evt) {
                if (evt.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
                    cur_path = (new File(cur_path)).getParent();
                    fill_tree();
                } else if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                    if (!"".equals(selected_file)) {
                        //count_data();
                        read_data();
                    } else {
                        TreePath path = tr_files.getSelectionPath();
                        if (path.getLastPathComponent().toString().equals(cur_path)) {
                            cur_path = (new File(cur_path)).getParent();
                        } else {
                            cur_path = cur_path + File.separator + path.getLastPathComponent().toString();
                        }
                        fill_tree();
                    }
                } else if (evt.getKeyCode() == KeyEvent.VK_DELETE) {

                    if (!"".equals(selected_file)) {
                        String name = cur_path + File.separator + selected_file;
                        if ((new File(name)).isFile()) {
                            int dialogResult = JOptionPane.showConfirmDialog(null,
                                    "Selected file [" + selected_file
                                            + "] will be removed and not recoverable.",
                                    "Are you sure?", JOptionPane.YES_NO_OPTION);
                            if (dialogResult == JOptionPane.YES_OPTION) {
                                (new File(name)).delete();
                                fill_tree();
                            }
                        }

                    } else {
                        JOptionPane.showMessageDialog(null,
                                "For safety concern, removing folder is not supported.", "Information",
                                JOptionPane.ERROR_MESSAGE);
                    }
                }
            }
        });

        tr_files.setCellRenderer(new MyTreeCellRenderer());
        p_count.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

        //tp_menu.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ctrl1, "tab_read");
        //tp_menu.getActionMap().put("tab_read", (Action) new ActionListenerImpl());
        //tp_menu.setMnemonicAt(0, KeyEvent.VK_1);
        //tp_menu.setMnemonicAt(1, KeyEvent.VK_2);
        /*InputMap inputMap = tp_menu.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
         ActionMap actionMap = tp_menu.getActionMap();
                
         KeyStroke ctrl1 = KeyStroke.getKeyStroke("ctrl 1");
         inputMap.put(ctrl1, "tab_read");
         actionMap.put("tab_read", new AbstractAction() {
                
         @Override
         public void actionPerformed(ActionEvent arg0) {
         tp_menu.setSelectedIndex(0);
         }
         });
                
         KeyStroke ctrl2 = KeyStroke.getKeyStroke("ctrl 2");
         inputMap.put(ctrl2, "tab_analyze");
         actionMap.put("tab_analyze", new AbstractAction() {
                
         @Override
         public void actionPerformed(ActionEvent arg0) {
         tp_menu.setSelectedIndex(1);
         }
         });*/
        config();
    } catch (Exception e) {
        txt_count.setText(e.getMessage());
    }
}

From source file:com.callidusrobotics.swing.SwingConsole.java

@Override
public String getline(final int maxLen, final Color foreground, final Color background)
        throws ArrayIndexOutOfBoundsException {
    final StringBuffer stringBuffer = new StringBuffer(maxLen);

    boolean keepPolling = true;
    while (keepPolling) {
        if (stringBuffer.length() < maxLen) {
            showCursor();//ww  w. j av a2s . co  m
        } else {
            hideCursor();
        }
        render();

        final char input = getKeyTyped();
        switch (input) {
        case KeyEvent.VK_ENTER:
            keepPolling = false;
            break;

        case KeyEvent.VK_BACK_SPACE:
            if (stringBuffer.length() > 0) {
                stringBuffer.deleteCharAt(stringBuffer.length() - 1);
                moveCursor(cursorRow, cursorCol - 1);
                print(cursorRow, cursorCol, ' ', background, background);
            }
            break;

        case KeyEvent.CHAR_UNDEFINED:
        case KeyEvent.VK_DELETE:
        case KeyEvent.VK_ESCAPE:
            // ignore these characters
            break;

        default:
            if (stringBuffer.length() < maxLen) {
                stringBuffer.append(input);
                print(cursorRow, cursorCol, input, foreground, background);
                moveCursor(cursorRow, cursorCol + 1);
            }
        }
    }

    hideCursor();
    render();

    return stringBuffer.toString();
}

From source file:de.tor.tribes.ui.views.DSWorkbenchReTimerFrame.java

/** Creates new form DSWorkbenchReTimerFrame */
DSWorkbenchReTimerFrame() {//from  www  .  j  a  v a  2 s .  co  m
    initComponents();

    centerPanel = new GenericTestPanel(true);
    jReTimePanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jideRetimeTabbedPane);
    jideRetimeTabbedPane.setTabShape(JideTabbedPane.SHAPE_OFFICE2003);
    jideRetimeTabbedPane.setTabColorProvider(JideTabbedPane.ONENOTE_COLOR_PROVIDER);
    jideRetimeTabbedPane.setBoldActiveTab(true);
    jideRetimeTabbedPane.addTab("Festlegen des Angriffs", jInputPanel);
    jideRetimeTabbedPane.addTab("Errechnete Gegenangriffe", jResultPanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);
    KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK, false);
    jResultTable.registerKeyboardAction(DSWorkbenchReTimerFrame.this, "Copy", copy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultTable.registerKeyboardAction(DSWorkbenchReTimerFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultTable.registerKeyboardAction(DSWorkbenchReTimerFrame.this, "Delete", delete,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultTable.registerKeyboardAction(DSWorkbenchReTimerFrame.this, "Cut", cut,
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jResultTable.getActionMap().put("find", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //ignore find
        }
    });
    jCommandArea.setPrompt("<Angriffsbefehl hier einfgen>");
    jResultTable.getSelectionModel().addListSelectionListener(DSWorkbenchReTimerFrame.this);
    jPossibleUnits.setCellRenderer(new UnitListCellRenderer());
    jPossibleUnits.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                updateAttackBBView();
            }
        }
    });

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.retime_tool",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
}