use of java.awt.event.WindowAdapter in project zaproxy by zaproxy.
the class ScanProgressDialog method initialize.
private void initialize() {
this.setSize(new Dimension(580, 504));
JTabbedPane tabbedPane = new JTabbedPane();
JPanel tab1 = new JPanel();
tab1.setLayout(new GridBagLayout());
JPanel hostPanel = new JPanel();
hostPanel.setLayout(new GridBagLayout());
hostPanel.add(new JLabel(Constant.messages.getString("ascan.progress.label.host")), LayoutHelper.getGBC(0, 0, 1, 0.4D));
hostPanel.add(getHostSelect(), LayoutHelper.getGBC(1, 0, 1, 0.6D));
tab1.add(hostPanel, LayoutHelper.getGBC(0, 0, 3, 1.0D, 0.0D));
tab1.add(getJScrollPane(), LayoutHelper.getGBC(0, 1, 3, 1.0D, 1.0D));
JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
buttonsPanel.add(getCopyToClipboardButton());
buttonsPanel.add(getCloseButton());
tab1.add(buttonsPanel, LayoutHelper.getGBC(0, 2, 3, 1.0D));
tabbedPane.insertTab(Constant.messages.getString("ascan.progress.tab.progress"), null, tab1, null, 0);
this.add(tabbedPane);
int mins = extension.getScannerParam().getMaxChartTimeInMins();
if (mins > 0) {
// Treat zero mins as disabled
JPanel tab2 = new JPanel();
tab2.setLayout(new GridBagLayout());
// Name not shown, so no need to i18n
this.seriesTotal = new TimeSeries("TotalResponses");
final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesTotal);
this.series100 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.1xx"));
this.series200 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.2xx"));
this.series300 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.3xx"));
this.series400 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.4xx"));
this.series500 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.5xx"));
long maxAge = mins * 60;
this.seriesTotal.setMaximumItemAge(maxAge);
this.series100.setMaximumItemAge(maxAge);
this.series200.setMaximumItemAge(maxAge);
this.series300.setMaximumItemAge(maxAge);
this.series400.setMaximumItemAge(maxAge);
this.series500.setMaximumItemAge(maxAge);
dataset.addSeries(series100);
dataset.addSeries(series200);
dataset.addSeries(series300);
dataset.addSeries(series400);
dataset.addSeries(series500);
chart = createChart(dataset);
// Set up some vaguesly sensible colours
// Totals
chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.BLACK);
// 100: Info
chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.GRAY);
// 200: OK
chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GREEN);
// 300: Info
chart.getXYPlot().getRenderer(0).setSeriesPaint(3, Color.BLUE);
// 400: Bad req
chart.getXYPlot().getRenderer(0).setSeriesPaint(4, Color.MAGENTA);
// 500: Internal error
chart.getXYPlot().getRenderer(0).setSeriesPaint(5, Color.RED);
final ChartPanel chartPanel = new ChartPanel(chart);
tab2.add(chartPanel, LayoutHelper.getGBC(0, 0, 1, 1.0D, 1.0D));
tabbedPane.insertTab(Constant.messages.getString("ascan.progress.tab.chart"), null, tab2, null, 1);
}
// Stop the updating thread when the window is closed
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
stopThread = true;
}
});
}
use of java.awt.event.WindowAdapter in project L42 by ElvisResearchGroup.
the class Frame method createNew.
private static Frame createNew(String wName, String html, int x, int y) {
FutureTask<Frame> future = new FutureTask<>(() -> {
final Frame frame = new Frame(Frame.extractTitle(html));
JFXPanel jfxPanel = new JFXPanel();
frame.createHtmlContent(jfxPanel, html);
frame.getContentPane().add(jfxPanel);
frame.setMinimumSize(new Dimension(x, y));
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
Frame.close(wName);
}
});
frame.setVisible(true);
return frame;
});
SwingUtilities.invokeLater(future);
try {
return future.get();
} catch (ExecutionException e) {
throw propagateException(e.getCause());
} catch (InterruptedException e) {
throw propagateException(e);
}
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class NoResizeEventOnDMChangeTest method testFSWindow.
private static void testFSWindow(final GraphicsDevice gd, final DisplayMode[] dms, final Window fsWin) {
System.out.println("Testing FS window: " + fsWin);
Component c = new Canvas() {
@Override
public void paint(Graphics g) {
g.setColor(Color.blue);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.magenta);
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
g.setColor(Color.red);
g.drawString("FS Window : " + fsWin, 50, 50);
DisplayMode dm = getGraphicsConfiguration().getDevice().getDisplayMode();
g.drawString("Display Mode: " + dm.getWidth() + "x" + dm.getHeight(), 50, 75);
}
};
fsWin.add("Center", c);
fsWin.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
fsWin.dispose();
if (fsWin.getOwner() != null) {
fsWin.getOwner().dispose();
}
}
});
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
gd.setFullScreenWindow(fsWin);
}
});
} catch (Exception ex) {
}
sleep(1000);
final ResizeEventChecker r1 = new ResizeEventChecker();
final ResizeEventChecker r2 = new ResizeEventChecker();
if (gd.isDisplayChangeSupported()) {
fsWin.addComponentListener(r1);
c.addComponentListener(r2);
for (final DisplayMode dm1 : dms) {
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
System.err.printf("----------- Setting DM %dx%d:\n", dm1.getWidth(), dm1.getHeight());
try {
gd.setDisplayMode(dm1);
r1.incDmChanges();
r2.incDmChanges();
} catch (IllegalArgumentException iae) {
}
}
});
} catch (Exception ex) {
}
for (int i = 0; i < 3; i++) {
fsWin.repaint();
sleep(1000);
}
}
fsWin.removeComponentListener(r1);
c.removeComponentListener(r2);
}
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
gd.setFullScreenWindow(null);
fsWin.dispose();
if (fsWin.getOwner() != null) {
fsWin.getOwner().dispose();
}
}
});
} catch (Exception ex) {
}
System.out.printf("FS Window: resizes=%d, dm changes=%d\n", r1.getResizes(), r1.getDmChanges());
System.out.printf("Component: resizes=%d, dm changes=%d\n", r2.getResizes(), r2.getDmChanges());
if (r1.getResizes() < r1.getDmChanges()) {
throw new RuntimeException("FS Window didn't receive all resizes!");
}
if (r2.getResizes() < r2.getDmChanges()) {
throw new RuntimeException("Component didn't receive all resizes!");
}
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class TooMuchWheelRotationEventsTest method createUI.
private static void createUI() {
final JFrame mainFrame = new JFrame("Trackpad scrolling test");
GridBagLayout layout = new GridBagLayout();
JPanel mainControlPanel = new JPanel(layout);
JPanel resultButtonPanel = new JPanel(layout);
GridBagConstraints gbc = new GridBagConstraints();
JPanel testPanel = createTestPanel();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainControlPanel.add(testPanel, gbc);
JTextArea instructionTextArea = new JTextArea();
instructionTextArea.setText(INSTRUCTIONS);
instructionTextArea.setEditable(false);
instructionTextArea.setBackground(Color.white);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainControlPanel.add(instructionTextArea, gbc);
JButton passButton = new JButton("Pass");
passButton.setActionCommand("Pass");
passButton.addActionListener((ActionEvent e) -> {
testResult = true;
mainFrame.dispose();
countDownLatch.countDown();
});
JButton failButton = new JButton("Fail");
failButton.setActionCommand("Fail");
failButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mainFrame.dispose();
countDownLatch.countDown();
}
});
gbc.gridx = 0;
gbc.gridy = 0;
resultButtonPanel.add(passButton, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
resultButtonPanel.add(failButton, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
mainControlPanel.add(resultButtonPanel, gbc);
mainFrame.add(mainControlPanel);
mainFrame.pack();
mainFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
mainFrame.dispose();
countDownLatch.countDown();
}
});
mainFrame.setVisible(true);
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method doTest.
private static void doTest(Runnable action) {
String description = " A TexturePaint graphics will be shown on console.\n" + " The same graphics is sent to printer.\n" + " Please verify if TexturePaint shading is printed.\n" + " If none is printed, press FAIL else press PASS";
final JDialog dialog = new JDialog();
dialog.setTitle("printSelectionTest");
JTextArea textArea = new JTextArea(description);
textArea.setEditable(false);
final JButton testButton = new JButton("Start Test");
final JButton passButton = new JButton("PASS");
passButton.setEnabled(false);
passButton.addActionListener((e) -> {
f.dispose();
dialog.dispose();
pass();
});
final JButton failButton = new JButton("FAIL");
failButton.setEnabled(false);
failButton.addActionListener((e) -> {
f.dispose();
dialog.dispose();
fail();
});
testButton.addActionListener((e) -> {
testButton.setEnabled(false);
action.run();
passButton.setEnabled(true);
failButton.setEnabled(true);
});
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(textArea, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(testButton);
buttonPanel.add(passButton);
buttonPanel.add(failButton);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
dialog.add(mainPanel);
dialog.pack();
dialog.setVisible(true);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.out.println("main dialog closing");
testGeneratedInterrupt = false;
mainThread.interrupt();
}
});
}
Aggregations