use of java.awt.Component in project zaproxy by zaproxy.
the class PopupMenuUtils method insertSeparatorIfNeeded.
/**
* Inserts a separator at the given {@code position} if it exists a non separator menu component at the given
* {@code position} and if there isn't, already, a separator immediately before the insert {@code position} (to prevent
* consecutive separators).
*
* @param popupMenu the pop up menu that will be processed
* @param position the position where a separator might be inserted
* @return {@code true} if the separator was inserted, {@code false} otherwise.
* @see javax.swing.JPopupMenu.Separator
*/
public static boolean insertSeparatorIfNeeded(JPopupMenu popupMenu, int position) {
final int menuComponentCount = popupMenu.getComponentCount();
if (menuComponentCount == 0 || position <= 0 || position > menuComponentCount) {
return false;
}
final Component currentComponent = popupMenu.getComponent(position);
if (isPopupMenuSeparator(currentComponent)) {
return false;
}
final Component previousComponent = popupMenu.getComponent(position - 1);
if (isPopupMenuSeparator(previousComponent)) {
return false;
}
popupMenu.insert(new JPopupMenu.Separator(), position);
return true;
}
use of java.awt.Component in project nhin-d by DirectProject.
the class ButtonSelector method actionPerformed.
public void actionPerformed(ActionEvent event) {
//System.out.println("Event"+event.getActionCommand());
if (event.getActionCommand().equalsIgnoreCase("Create Bundle")) {
Component[] data = pane.getComponents();
JTextField anchorDir = (JTextField) data[4];
JTextField metaDataFile = (JTextField) data[7];
JTextField destDir = (JTextField) data[10];
JTextField bundleName = (JTextField) data[13];
CreateUnSignedPKCS7 unCert = new CreateUnSignedPKCS7();
error = unCert.getParameters(anchorDir.getText(), metaDataFile.getText(), destDir.getText(), bundleName.getText());
JTextPane feedback = (JTextPane) data[16];
feedback.setText(error);
} else if (event.getActionCommand().equalsIgnoreCase("Create Signed Bundle")) {
Component[] data = pane.getComponents();
JTextField anchorDir = (JTextField) data[4];
JTextField metaDataFile = (JTextField) data[7];
JTextField certificateDir = (JTextField) data[10];
JPasswordField passkey = (JPasswordField) data[13];
//String passVal=new String();
//System.out.println("The password:"+String.copyValueOf(passkey.getPassword()));
JTextField destDir = (JTextField) data[15];
JTextField bundleName = (JTextField) data[18];
CreateSignedPKCS7 unCert = new CreateSignedPKCS7();
error = unCert.getParameters(anchorDir.getText(), metaDataFile.getText(), certificateDir.getText(), String.copyValueOf(passkey.getPassword()), destDir.getText(), bundleName.getText());
//System.out.println("The destination file path is:"+error);
JTextPane feedback = (JTextPane) data[21];
feedback.setText(error);
} else {
Component[] data = pane.getComponents();
JTextField trustBundle = (JTextField) data[4];
ViewTrustBundlePKCS7 unCert = new ViewTrustBundlePKCS7();
error = unCert.getParameters(trustBundle.getText());
new PreviewTrustBundle(error);
PreviewTrustBundle.createAndShowGUI();
//JTextPane feedback = (JTextPane) data[8];
//feedback.setText(error);
}
}
use of java.awt.Component in project zaproxy by zaproxy.
the class HttpPanelSyntaxHighlightTextArea method saveConfiguration.
public void saveConfiguration(String key, FileConfiguration fileConfiguration) {
fileConfiguration.setProperty(key + ANTI_ALIASING, Boolean.valueOf(this.getAntiAliasingEnabled()));
Component c = getParent();
if (c instanceof JViewport) {
c = c.getParent();
if (c instanceof RTextScrollPane) {
final RTextScrollPane scrollPane = (RTextScrollPane) c;
fileConfiguration.setProperty(key + SHOW_LINE_NUMBERS, Boolean.valueOf(scrollPane.getLineNumbersEnabled()));
}
}
fileConfiguration.setProperty(key + WORD_WRAP, Boolean.valueOf(this.getLineWrap()));
fileConfiguration.setProperty(key + HIGHLIGHT_CURRENT_LINE, Boolean.valueOf(this.getHighlightCurrentLine()));
fileConfiguration.setProperty(key + FADE_CURRENT_HIGHLIGHT_LINE, Boolean.valueOf(this.getFadeCurrentLineHighlight()));
fileConfiguration.setProperty(key + SHOW_WHITESPACE_CHARACTERS, Boolean.valueOf(this.isWhitespaceVisible()));
fileConfiguration.setProperty(key + SHOW_NEWLINE_CHARACTERS, Boolean.valueOf(this.getEOLMarkersVisible()));
fileConfiguration.setProperty(key + MARK_OCCURRENCES, Boolean.valueOf(this.getMarkOccurrences()));
fileConfiguration.setProperty(key + ROUNDED_SELECTION_EDGES, Boolean.valueOf(this.getRoundedSelectionEdges()));
fileConfiguration.setProperty(key + BRACKET_MATCHING, Boolean.valueOf(this.isBracketMatchingEnabled()));
fileConfiguration.setProperty(key + ANIMATED_BRACKET_MATCHING, Boolean.valueOf(this.getAnimateBracketMatching()));
}
use of java.awt.Component in project zaproxy by zaproxy.
the class HttpPanelSyntaxHighlightTextArea method loadConfiguration.
public void loadConfiguration(String key, FileConfiguration fileConfiguration) {
setAntiAliasingEnabled(fileConfiguration.getBoolean(key + ANTI_ALIASING, this.getAntiAliasingEnabled()));
Component c = getParent();
if (c instanceof JViewport) {
c = c.getParent();
if (c instanceof RTextScrollPane) {
final RTextScrollPane scrollPane = (RTextScrollPane) c;
scrollPane.setLineNumbersEnabled(fileConfiguration.getBoolean(key + SHOW_LINE_NUMBERS, scrollPane.getLineNumbersEnabled()));
}
}
setLineWrap(fileConfiguration.getBoolean(key + WORD_WRAP, this.getLineWrap()));
setHighlightCurrentLine(fileConfiguration.getBoolean(key + HIGHLIGHT_CURRENT_LINE, this.getHighlightCurrentLine()));
setFadeCurrentLineHighlight(fileConfiguration.getBoolean(key + FADE_CURRENT_HIGHLIGHT_LINE, this.getFadeCurrentLineHighlight()));
setWhitespaceVisible(fileConfiguration.getBoolean(key + SHOW_WHITESPACE_CHARACTERS, this.isWhitespaceVisible()));
setEOLMarkersVisible(fileConfiguration.getBoolean(key + SHOW_NEWLINE_CHARACTERS, this.getEOLMarkersVisible()));
setMarkOccurrences(fileConfiguration.getBoolean(key + MARK_OCCURRENCES, this.getMarkOccurrences()));
setRoundedSelectionEdges(fileConfiguration.getBoolean(key + ROUNDED_SELECTION_EDGES, this.getRoundedSelectionEdges()));
setBracketMatchingEnabled(fileConfiguration.getBoolean(key + BRACKET_MATCHING, this.isBracketMatchingEnabled()));
setAnimateBracketMatching(fileConfiguration.getBoolean(key + ANIMATED_BRACKET_MATCHING, this.getAnimateBracketMatching()));
}
use of java.awt.Component in project jdk8u_jdk by JetBrains.
the class Test7194184 method testKeyBoardAccess.
private static void testKeyBoardAccess() throws Exception {
Robot robot = new Robot();
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeLater(new Test7194184());
toolkit.realSync();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
selectedColor = colorChooser.getColor();
Component recentSwatchPanel = Util.findSubComponent(colorChooser, "RecentSwatchPanel");
if (recentSwatchPanel == null) {
throw new RuntimeException("RecentSwatchPanel not found");
}
recentSwatchPanel.requestFocusInWindow();
}
});
toolkit.realSync();
// Tab to move the focus to MainSwatch
Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
// Select the color on right
Util.hitKeys(robot, KeyEvent.VK_RIGHT);
Util.hitKeys(robot, KeyEvent.VK_RIGHT);
Util.hitKeys(robot, KeyEvent.VK_SPACE);
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame.dispose();
if (selectedColor == colorChooser.getColor()) {
throw new RuntimeException("JColorChooser misses keyboard accessibility");
}
}
});
}
Aggregations