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());
}
}
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;
}
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()]));
}
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();
}
}
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()));
}
Aggregations