/** * Show a dialog indicating that JMeter threads are stopping on a particular * host. * * @param host * the host where JMeter threads are stopping */ public void showStoppingMessage(String host) { if (stoppingMessage != null){ stoppingMessage.dispose(); } stoppingMessage = new EscapeDialog(this, JMeterUtils.getResString("stopping_test_title"), true); //$NON-NLS-1$ String label = JMeterUtils.getResString("stopping_test"); //$NON-NLS-1 if (!StringUtils.isEmpty(host)) { label = label + JMeterUtils.getResString("stopping_test_host")+ ": " + host; } JLabel stopLabel = new JLabel(label); //$NON-NLS-1$$NON-NLS-2$ stopLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); stoppingMessage.getContentPane().add(stopLabel); stoppingMessage.pack(); ComponentUtil.centerComponentInComponent(this, stoppingMessage); SwingUtilities.invokeLater(() -> { if (stoppingMessage != null) { stoppingMessage.setVisible(true); } }); }
/** * Use this static method if you want to center and set its position * compared to the size of the current users screen size. Valid percent is * between +-(0-100) minus is treated as plus, bigger than 100 is always set * to 100. * * @param component * the component you want to center and set size on * @param percentOfScreen * the percent of the current screensize you want the component * to be */ public static void centerComponentInWindow(Component component, int percentOfScreen) { if (percentOfScreen < 0) { centerComponentInWindow(component, -percentOfScreen); return; } if (percentOfScreen > 100) { centerComponentInWindow(component, 100); return; } double percent = percentOfScreen / 100.d; Rectangle bounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getBounds(); component.setSize((int) (bounds.getWidth() * percent), (int) (bounds.getHeight() * percent)); centerComponentInWindow(component); }
/** * Display result in popup * @param result String */ private static final void showResult(String result) { EscapeDialog messageDialog = new EscapeDialog(GuiPackage.getInstance().getMainFrame(), JMeterUtils.getResString("export_transactions_title"), true); //$NON-NLS-1$ Container contentPane = messageDialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(new JLabel( JMeterUtils.getResString("export_transactions_exported_property"), SwingConstants.CENTER), BorderLayout.NORTH);//$NON-NLS-1$ JSyntaxTextArea syntaxTextArea = JSyntaxTextArea.getInstance(10, 80, true); syntaxTextArea.setText(result); syntaxTextArea.setCaretPosition(0); contentPane.add(JTextScrollPane.getInstance(syntaxTextArea), BorderLayout.CENTER); messageDialog.pack(); ComponentUtil.centerComponentInComponent(GuiPackage.getInstance().getMainFrame(), messageDialog); SwingUtilities.invokeLater(() -> messageDialog.setVisible(true)); }
/** * @return {@link JDialog} Help window and initializes it if necessary */ private static JDialog initHelpWindow() { if (helpWindow == null) { helpWindow = new EscapeDialog(new Frame(),// independent frame to // allow it to be overlaid // by the main frame JMeterUtils.getResString("help"),//$NON-NLS-1$ false); helpWindow.getContentPane().setLayout(new GridLayout(1, 1)); helpWindow.getContentPane().removeAll(); helpWindow.getContentPane().add(scroller); ComponentUtil.centerComponentInWindow(helpWindow, 60); } return helpWindow; }
true, collector.getSaveConfig()); d.pack(); ComponentUtil.centerComponentInComponent(GuiPackage.getInstance() .getMainFrame(), d); d.setVisible(true);
ComponentUtil.centerComponentInWindow(this);
@Override public void actionPerformed(ActionEvent e) { SavePropertyDialog d = new SavePropertyDialog( GuiPackage.getInstance().getMainFrame(), JMeterUtils.getResString("sample_result_save_configuration"), // $NON-NLS-1$ true, collector.getSaveConfig()); d.pack(); ComponentUtil.centerComponentInComponent(GuiPackage.getInstance().getMainFrame(), d); d.setVisible(true); } });
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final) templateList.setValues(TemplateManager.getInstance().getTemplateNames()); templateList.addChangeListener(this); reloadTemplateButton.addActionListener(this); reloadTemplateButton.setFont(FONT_SMALL); this.getContentPane().setLayout(new BorderLayout(10, 0)); JPanel templateBar = new JPanel(new BorderLayout()); templateBar.add(templateList, BorderLayout.CENTER); JPanel reloadBtnBar = new JPanel(); reloadBtnBar.add(reloadTemplateButton); templateBar.add(reloadBtnBar, BorderLayout.EAST); this.getContentPane().add(templateBar, BorderLayout.NORTH); helpDoc.setContentType("text/html"); //$NON-NLS-1$ helpDoc.setEditable(false); helpDoc.addHyperlinkListener(this); this.getContentPane().add(scroller, BorderLayout.CENTER); applyTemplateButton.addActionListener(this); cancelButton.addActionListener(this); // Bottom buttons bar JPanel actionBtnBar = new JPanel(new FlowLayout()); actionBtnBar.add(applyTemplateButton); actionBtnBar.add(cancelButton); this.getContentPane().add(actionBtnBar, BorderLayout.SOUTH); this.pack(); this.setMinimumSize(new Dimension(MINIMAL_BOX_WIDTH, MINIMAL_BOX_HEIGHT)); ComponentUtil.centerComponentInWindow(this, 50); // center position and 50% of screen size populateTemplatePage(); }
true, collector.getSaveConfig()); d.pack(); ComponentUtil.centerComponentInComponent(GuiPackage.getInstance() .getMainFrame(), d); d.setVisible(true);
ComponentUtil.centerComponentInWindow(this);
ComponentUtil.centerComponentInWindow(this);
MainFrame main = new MainFrame(treeModel, treeLis); splash.setProgress(100); ComponentUtil.centerComponentInWindow(main, 80); main.setLocationRelativeTo(splash); main.setVisible(true);