Search in sources :

Example 11 with Component

use of java.awt.Component in project zaproxy by zaproxy.

the class FindDialog method find.

private void find() {
    JTextComponent txtComp = lastInvoker;
    if (txtComp == null) {
        JFrame parent = (JFrame) (this.getParent());
        Component c = parent.getMostRecentFocusOwner();
        if (c instanceof JTextComponent) {
            txtComp = (JTextComponent) c;
        }
    }
    // ZAP: Check if a JTextComponent was really found.
    if (txtComp == null) {
        return;
    }
    try {
        String findText = txtFind.getText().toLowerCase();
        String txt = txtComp.getText().toLowerCase();
        int startPos = txt.indexOf(findText, txtComp.getCaretPosition());
        // Enable Wrap Search
        if (startPos <= 0) {
            txtComp.setCaretPosition(0);
            startPos = txt.indexOf(findText, txtComp.getCaretPosition());
        }
        int length = findText.length();
        if (startPos > -1) {
            txtComp.select(startPos, startPos + length);
            txtComp.requestFocus();
            txtFind.requestFocus();
        } else {
            Toolkit.getDefaultToolkit().beep();
        }
    } catch (Exception e) {
        System.out.println("Exception: " + e.getMessage());
    }
}
Also used : JFrame(javax.swing.JFrame) JTextComponent(javax.swing.text.JTextComponent) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent) HeadlessException(java.awt.HeadlessException)

Example 12 with Component

use of java.awt.Component in project zaproxy by zaproxy.

the class ExtensionBreak method getMenuAddHttpBreakpoint.

private ZapMenuItem getMenuAddHttpBreakpoint() {
    if (menuHttpBreakpoint == null) {
        menuHttpBreakpoint = new ZapMenuItem("menu.tools.brk.custom", KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
        menuHttpBreakpoint.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                // Check to see if anything is selected in the main tabs
                String url = "";
                Component c = View.getSingleton().getMainFrame().getFocusOwner();
                if (c != null) {
                    if (c instanceof JList) {
                        // Handles the history list and similar
                        @SuppressWarnings("rawtypes") Object sel = ((JList) c).getSelectedValue();
                        try {
                            if (sel != null && sel instanceof HistoryReference && ((HistoryReference) sel).getURI() != null) {
                                url = ((HistoryReference) sel).getURI().toString();
                            }
                        } catch (Exception e1) {
                        // Ignore
                        }
                    } else if (c instanceof JTree) {
                        // Handles the Sites tree
                        TreePath path = ((JTree) c).getSelectionPath();
                        try {
                            if (path != null && path.getLastPathComponent() instanceof SiteNode) {
                                url = ((SiteNode) path.getLastPathComponent()).getHistoryReference().getURI().toString();
                            }
                        } catch (Exception e1) {
                        // Ignore
                        }
                    }
                }
                httpBreakpoints.handleAddBreakpoint(url);
            }
        });
    }
    return menuHttpBreakpoint;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) MalformedURLException(java.net.MalformedURLException) HistoryReference(org.parosproxy.paros.model.HistoryReference) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) Component(java.awt.Component) JList(javax.swing.JList) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 13 with Component

use of java.awt.Component in project processing by processing.

the class Toolkit method setMenuMnemonics.

/**
   * As setMenuMnemonics(JMenuItem...).
   */
public static void setMenuMnemonics(JPopupMenu menu) {
    ArrayList<JMenuItem> items = new ArrayList<JMenuItem>();
    for (Component c : menu.getComponents()) {
        if (c instanceof JMenuItem)
            items.add((JMenuItem) c);
    }
    setMenuMnemonics(items.toArray(new JMenuItem[items.size()]));
}
Also used : ArrayList(java.util.ArrayList) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Example 14 with Component

use of java.awt.Component in project AozoraEpub3 by hmdev.

the class AozoraEpub3Applet method setConvertEnabled.

/** 変換中に操作不可にするコンポーネントのenabledを設定 */
private void setConvertEnabled(boolean enabled) {
    for (Component c : this.topPanel.getComponents()) this.setEnabledAll(c, enabled);
    for (Component c : this.jTabbedPane.getComponents()) this.setEnabledAll(c, enabled);
    jRadioVertical.getComponent(0).setEnabled(enabled);
    jRadioHorizontal.getComponent(0).setEnabled(enabled);
    //変換中に操作不可にしないもの
    if (!enabled)
        this.jCheckConfirm.setEnabled(true);
    this.jButtonCancel.setEnabled(!enabled);
    //disabledになっているものは再チェック
    if (enabled) {
        this.setProfileMoveEnable();
    }
}
Also used : Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent)

Example 15 with Component

use of java.awt.Component in project openblocks by mikaelhg.

the class MiniMap method paint.

/**
     * @modifies this.bounds && this.blockCanvas && this.blocks && this.comments
     * @effects 1] Point this.blockCanvas to whatever current block
     * 			   canvas is in Workspace
     * 			2] Reset this.bounds to maintain aspect ratio and be
     * 			   16 pixels away from upper-right edge corner &&
     * 			3] Rerender this.blocks and this.comment toreflect
     * 			   real-time relative positions and dimension
     */
public void paint(Graphics g) {
    //should paint super first then reset canvas.
    //using new canvas, find new height and ratio.
    super.paint(g);
    // draw shadow border
    for (int i = 0; i < BORDER_WIDTH; i++) {
        g.setColor(new Color(200, 200, 150, 50 * (i + 1)));
        g.drawRect(i, i, this.getWidth() - 1 - 2 * i, this.getHeight() - 1 - 2 * i);
    }
    //Aspect-Ratio Logic
    this.blockCanvas = workspace.getBlockCanvas();
    //MUST CAST MAPHEIGHT TO DOUBLE!!
    this.transformX = (double) (MAPWIDTH) / this.getCanvas().getWidth();
    this.transformY = (double) (MAPHEIGHT) / this.getCanvas().getHeight();
    g.translate(5, 5);
    for (Page page : this.blockCanvas.getPages()) {
        Color pageColor = page.getPageColor();
        g.setColor(new Color(pageColor.getRed(), pageColor.getGreen(), pageColor.getBlue(), 200));
        Rectangle pageRect = rescaleRect(page.getJComponent().getBounds());
        g.fillRect(pageRect.x, pageRect.y, pageRect.width, pageRect.height);
        g.setColor(Color.white);
        g.clipRect(pageRect.x, pageRect.y, pageRect.width, pageRect.height);
        g.drawString(page.getPageName(), pageRect.x + 1, pageRect.height - 3);
        if (page.getIcon() != null && expand) {
            g.drawImage(page.getIcon(), pageRect.x + 1, pageRect.height - 28, 15, 15, null);
        }
        g.setClip(null);
        for (Component component : page.getJComponent().getComponents()) {
            //re-render this.blocks and this.comments
            if (component instanceof RenderableBlock && component != null && component.isVisible()) {
                if (((RenderableBlock) component).isSearchResult()) {
                    g.setColor(Color.yellow);
                } else {
                    g.setColor(((RenderableBlock) component).getBLockColor());
                }
                drawBoundingBox(g, component);
            } else if (component instanceof Comment && component.isVisible()) {
                g.setColor(Color.yellow);
                drawBoundingBox(g, component);
            }
        }
    }
    for (Component component : this.getCanvas().getComponents()) {
        if (component instanceof PageDivider) {
            g.setColor(Color.GRAY);
            Rectangle dividerRect = rescaleRect(component.getBounds());
            g.fillRect(dividerRect.x, dividerRect.y, dividerRect.width + 1, dividerRect.height);
        }
    }
    for (Component component : workspace.getComponentsInLayer(Workspace.DRAGGED_BLOCK_LAYER)) {
        if (component instanceof RenderableBlock && component != null && component.isVisible()) {
            g.setColor(((RenderableBlock) component).getBLockColor());
            drawBoundingBox(g, component);
        } else if (component instanceof Comment && component.isVisible()) {
            g.setColor(Color.yellow);
            drawBoundingBox(g, component);
        }
    }
    g.setColor(Color.red);
    g.drawRect(rescaleX(blockCanvas.getHorizontalModel().getValue()), rescaleY(blockCanvas.getVerticalModel().getValue()), rescaleX(blockCanvas.getWidth()), rescaleY(blockCanvas.getHeight()));
}
Also used : Comment(edu.mit.blocks.renderable.Comment) RenderableBlock(edu.mit.blocks.renderable.RenderableBlock) Color(java.awt.Color) Rectangle(java.awt.Rectangle) JComponent(javax.swing.JComponent) Component(java.awt.Component) Point(java.awt.Point)

Aggregations

Component (java.awt.Component)645 JComponent (javax.swing.JComponent)163 Dimension (java.awt.Dimension)81 JLabel (javax.swing.JLabel)65 JPanel (javax.swing.JPanel)60 Insets (java.awt.Insets)55 Point (java.awt.Point)55 TableCellRenderer (javax.swing.table.TableCellRenderer)47 Container (java.awt.Container)46 JScrollPane (javax.swing.JScrollPane)42 JTable (javax.swing.JTable)36 JButton (javax.swing.JButton)35 BorderLayout (java.awt.BorderLayout)34 GridBagConstraints (java.awt.GridBagConstraints)34 JTextComponent (javax.swing.text.JTextComponent)34 GridBagLayout (java.awt.GridBagLayout)33 Color (java.awt.Color)32 JList (javax.swing.JList)31 TableColumn (javax.swing.table.TableColumn)31 MouseEvent (java.awt.event.MouseEvent)27