List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:net.java.sip.communicator.gui.AuthenticationSplash.java
/** * * We use dynamic layout managers, so that layout is dynamic and will * adapt properly to user-customized fonts and localized text. The * GridBagLayout makes it easy to line up components of varying * sizes along invisible vertical and horizontal grid lines. It * is important to sketch the layout of the interface and decide * on the grid before writing the layout code. * * Here we actually use//from ww w. j a va 2 s . c om * our own subclass of GridBagLayout called StringGridBagLayout, * which allows us to use strings to specify constraints, rather * than having to create GridBagConstraints objects manually. * * * We use the JLabel.setLabelFor() method to connect * labels to what they are labeling. This allows mnemonics to work * and assistive to technologies used by persons with disabilities * to provide much more useful information to the user. */ private void initComponents(final Frame parent) { Container contents = getContentPane(); contents.setLayout(new BorderLayout()); String title = Utils.getProperty("net.java.sip.communicator.gui.AUTH_WIN_TITLE"); if (title == null) title = "Login Manager"; setTitle(title); setResizable(false); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { dialogDone(CMD_CANCEL, parent); } }); // Accessibility -- all frames, dialogs, and applets should // have a description getAccessibleContext().setAccessibleDescription("Authentication Splash"); String authPromptLabelValue = Utils.getProperty("net.java.sip.communicator.gui.AUTHENTICATION_PROMPT"); if (authPromptLabelValue == null) authPromptLabelValue = "Please register to the service or enter your credentials to log in:"; JLabel splashLabel = new JLabel(authPromptLabelValue); splashLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); splashLabel.setHorizontalAlignment(SwingConstants.CENTER); splashLabel.setHorizontalTextPosition(SwingConstants.CENTER); contents.add(splashLabel, BorderLayout.NORTH); JPanel centerPane = new JPanel(); centerPane.setLayout(new GridBagLayout()); userNameTextField = new JTextField(); // needed below // user name label JLabel userNameLabel = new JLabel(); userNameLabel.setDisplayedMnemonic('U'); // setLabelFor() allows the mnemonic to work userNameLabel.setLabelFor(userNameTextField); String userNameLabelValue = Utils.getProperty("net.java.sip.communicator.gui.USER_NAME_LABEL"); if (userNameLabelValue == null) userNameLabelValue = "Username"; int gridy = 0; userNameLabel.setText(userNameLabelValue); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(12, 12, 0, 0); centerPane.add(userNameLabel, c); // user name text c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(12, 7, 0, 11); centerPane.add(userNameTextField, c); passwordTextField = new JPasswordField(); //needed below // password label JLabel passwordLabel = new JLabel(); passwordLabel.setDisplayedMnemonic('P'); passwordLabel.setLabelFor(passwordTextField); String pLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.PASSWORD_LABEL"); if (pLabelStr == null) pLabelStr = "Password"; passwordLabel.setText(pLabelStr); c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(11, 12, 0, 0); centerPane.add(passwordLabel, c); // password text passwordTextField.setEchoChar('\u2022'); c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(11, 7, 0, 11); centerPane.add(passwordTextField, c); //Set a relevant realm value //Bug report by Steven Lass (sltemp at comcast.net) //JLabel realmValueLabel = new JLabel("SipPhone.com"); // needed below // realm label JLabel realmLabel = new JLabel(); realmLabel.setDisplayedMnemonic('R'); realmLabel.setLabelFor(realmValueLabel); realmLabel.setText("Realm"); realmValueLabel = new JLabel(); // Buttons along bottom of window JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, 0)); loginButton = new JButton(); loginButton.setText("Login"); loginButton.setActionCommand(CMD_LOGIN); loginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dialogDone(event, parent); } }); buttonPanel.add(loginButton); // space buttonPanel.add(Box.createRigidArea(new Dimension(5, 0))); registerButton = new JButton(); registerButton.setMnemonic('G'); registerButton.setText("Register"); registerButton.setActionCommand(CMD_REGISTER); registerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dialogDone(event, parent); } }); buttonPanel.add(registerButton); buttonPanel.add(Box.createRigidArea(new Dimension(5, 0))); cancelButton = new JButton(); cancelButton.setText("Cancel"); cancelButton.setActionCommand(CMD_CANCEL); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dialogDone(event, parent); } }); buttonPanel.add(cancelButton); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3; c.gridwidth = 2; c.insets = new Insets(11, 12, 11, 11); centerPane.add(buttonPanel, c); contents.add(centerPane, BorderLayout.CENTER); getRootPane().setDefaultButton(loginButton); equalizeButtonSizes(); setFocusTraversalPolicy(new FocusTraversalPol()); }
From source file:com.alvermont.javascript.tools.shell.ShellJSConsole.java
public ShellJSConsole(String[] args) { super("Rhino JavaScript Console"); final JMenuBar menubar = new JMenuBar(); createFileChooser();// w w w. j a v a 2s . c o m final String[] fileItems = { "Load...", "Close" }; final String[] fileCmds = { "Load", "Close" }; final char[] fileShortCuts = { 'L', 'X' }; final String[] editItems = { "Cut", "Copy", "Paste" }; final char[] editShortCuts = { 'T', 'C', 'P' }; final JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); final JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic('E'); for (int i = 0; i < fileItems.length; ++i) { final JMenuItem item = new JMenuItem(fileItems[i], fileShortCuts[i]); item.setActionCommand(fileCmds[i]); item.addActionListener(this); fileMenu.add(item); } for (int i = 0; i < editItems.length; ++i) { final JMenuItem item = new JMenuItem(editItems[i], editShortCuts[i]); item.addActionListener(this); editMenu.add(item); } final ButtonGroup group = new ButtonGroup(); menubar.add(fileMenu); menubar.add(editMenu); setJMenuBar(menubar); this.consoleTextArea = new ShellConsoleTextArea(args); final JScrollPane scroller = new JScrollPane(this.consoleTextArea); setContentPane(scroller); this.consoleTextArea.setRows(24); this.consoleTextArea.setColumns(80); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { setVisible(false); } }); pack(); setVisible(true); // System.setIn(consoleTextArea.getIn()); // System.setOut(consoleTextArea.getOut()); // System.setErr(consoleTextArea.getErr()); ShellMain.setIn(this.consoleTextArea.getIn()); ShellMain.setOut(this.consoleTextArea.getOut()); ShellMain.setErr(this.consoleTextArea.getErr()); // we don't do this here as we want to separate construction from // the run thread this.args = args; //ShellMain.exec(args); }
From source file:com.lfv.lanzius.server.LanziusServer.java
public void init() { log.info(Config.VERSION + "\n"); docVersion = 0;//from w w w . j av a 2 s . com frame = new JFrame(Config.TITLE + " - Server Control Panel"); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { actionPerformed(new ActionEvent(itemExit, 0, null)); } }); // Create graphical terminal view panel = new WorkspacePanel(this); frame.getContentPane().add(panel); // Create a menu bar JMenuBar menuBar = new JMenuBar(); // FILE JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); // Load configuration itemLoadConfig = new JMenuItem("Load configuration..."); itemLoadConfig.addActionListener(this); fileMenu.add(itemLoadConfig); // Load terminal setup itemLoadExercise = new JMenuItem("Load exercise..."); itemLoadExercise.addActionListener(this); fileMenu.add(itemLoadExercise); fileMenu.addSeparator(); // Exit itemExit = new JMenuItem("Exit"); itemExit.addActionListener(this); fileMenu.add(itemExit); menuBar.add(fileMenu); // SERVER JMenu serverMenu = new JMenu("Server"); serverMenu.setMnemonic(KeyEvent.VK_S); // Start itemServerStart = new JMenuItem("Start"); itemServerStart.addActionListener(this); serverMenu.add(itemServerStart); // Stop itemServerStop = new JMenuItem("Stop"); itemServerStop.addActionListener(this); serverMenu.add(itemServerStop); // Restart itemServerRestart = new JMenuItem("Restart"); itemServerRestart.addActionListener(this); itemServerRestart.setEnabled(false); serverMenu.add(itemServerRestart); // Monitor network connection itemServerMonitor = new JCheckBoxMenuItem("Monitor network"); itemServerMonitor.addActionListener(this); itemServerMonitor.setState(false); serverMenu.add(itemServerMonitor); menuBar.add(serverMenu); // TERMINAL JMenu terminalMenu = new JMenu("Terminal"); terminalMenu.setMnemonic(KeyEvent.VK_T); itemTerminalLink = new JMenuItem("Link..."); itemTerminalLink.addActionListener(this); terminalMenu.add(itemTerminalLink); itemTerminalUnlink = new JMenuItem("Unlink..."); itemTerminalUnlink.addActionListener(this); terminalMenu.add(itemTerminalUnlink); itemTerminalUnlinkAll = new JMenuItem("Unlink All"); itemTerminalUnlinkAll.addActionListener(this); terminalMenu.add(itemTerminalUnlinkAll); itemTerminalSwap = new JMenuItem("Swap..."); itemTerminalSwap.addActionListener(this); terminalMenu.add(itemTerminalSwap); menuBar.add(terminalMenu); // GROUP JMenu groupMenu = new JMenu("Group"); groupMenu.setMnemonic(KeyEvent.VK_G); itemGroupStart = new JMenuItem("Start..."); itemGroupStart.addActionListener(this); groupMenu.add(itemGroupStart); itemGroupPause = new JMenuItem("Pause..."); itemGroupPause.addActionListener(this); groupMenu.add(itemGroupPause); itemGroupStop = new JMenuItem("Stop..."); itemGroupStop.addActionListener(this); groupMenu.add(itemGroupStop); menuBar.add(groupMenu); frame.setJMenuBar(menuBar); GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle maximumWindowBounds = graphicsEnvironment.getMaximumWindowBounds(); if (Config.SERVER_SIZE_FULLSCREEN) { maximumWindowBounds.setLocation(0, 0); maximumWindowBounds.setSize(Toolkit.getDefaultToolkit().getScreenSize()); frame.setResizable(false); frame.setUndecorated(true); } else if (Config.SERVER_SIZE_100P_WINDOW) { // Fixes a bug in linux using gnome. With the line below the upper and // lower bars are respected maximumWindowBounds.height -= 1; } else if (Config.SERVER_SIZE_75P_WINDOW) { maximumWindowBounds.width *= 0.75; maximumWindowBounds.height *= 0.75; } else if (Config.SERVER_SIZE_50P_WINDOW) { maximumWindowBounds.width /= 2; maximumWindowBounds.height /= 2; } frame.setBounds(maximumWindowBounds); frame.setVisible(true); log.info("Starting control panel"); // Autostart for debugging if (Config.SERVER_AUTOLOAD_CONFIGURATION != null) actionPerformed(new ActionEvent(itemLoadConfig, 0, null)); if (Config.SERVER_AUTOSTART_SERVER) actionPerformed(new ActionEvent(itemServerStart, 0, null)); if (Config.SERVER_AUTOLOAD_EXERCISE != null) actionPerformed(new ActionEvent(itemLoadExercise, 0, null)); if (Config.SERVER_AUTOSTART_GROUP > 0) actionPerformed(new ActionEvent(itemGroupStart, 0, null)); try { // Read the property files serverProperties = new Properties(); serverProperties.loadFromXML(new FileInputStream("data/properties/serverproperties.xml")); int rcPort = Integer.parseInt(serverProperties.getProperty("RemoteControlPort", "0")); if (rcPort > 0) { groupRemoteControlListener(rcPort); } isaPeriod = Integer.parseInt(serverProperties.getProperty("ISAPeriod", "60")); isaNumChoices = Integer.parseInt(serverProperties.getProperty("ISANumChoices", "6")); for (int i = 0; i < 9; i++) { String tag = "ISAKeyText" + Integer.toString(i); String def_val = Integer.toString(i + 1); isakeytext[i] = serverProperties.getProperty(tag, def_val); } isaExtendedMode = serverProperties.getProperty("ISAExtendedMode", "false").equalsIgnoreCase("true"); } catch (Exception e) { log.error("Unable to start remote control listener"); log.error(e.getMessage()); } isaClients = new HashSet<Integer>(); }
From source file:gtu._work.etc.EnglishAdd.java
void setDefaultSave() { this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { }/*from www. jav a2 s .c om*/ public void windowClosing(WindowEvent e) { if (JOptionPane.showConfirmDialog(null, "?") == JOptionPane.YES_OPTION) { String words = wordTextArea.getText(); if (StringUtils.isNotBlank(words) && currentFile != null) { FileUtil.saveToFile(currentFile, words, "BIG5"); } gtu.swing.util.JFrameUtil.setVisible(false, EnglishAdd.this); EnglishAdd.this.dispose(); } } }); }
From source file:com.limegroup.gnutella.gui.notify.AnimatedWindow.java
public static void main(String[] args) { JPanel content = new JPanel(new BorderLayout()); content.setBorder(BorderFactory.createLineBorder(Color.black, 2)); JLabel label = new JLabel("Hello World"); label.setIcon(UIManager.getIcon("FileView.computerIcon")); label.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); content.add(label, BorderLayout.CENTER); final AnimatedWindow window = new AnimatedWindow(null); window.setFinalLocation(new Point(200, 200)); window.setContentPane(content);//from w w w . java2s. co m JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10)); JButton button = new JButton("Bottom -> Top"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.BOTTOM_TO_TOP); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); button = new JButton("Top -> Bottom"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.TOP_TO_BOTTOM); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); button = new JButton("Fade"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.FADE); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); JFrame app = new JFrame("AnimatedWindow Demo"); app.setContentPane(buttonPanel); app.pack(); app.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); app.setVisible(true); }
From source file:net.sf.jabref.gui.search.SearchResultsDialog.java
private void init(String title) { diag = new JDialog(frame, title, false); int activePreview = Globals.prefs.getInt(JabRefPreferences.ACTIVE_PREVIEW); String layoutFile = activePreview == 0 ? Globals.prefs.get(JabRefPreferences.PREVIEW_0) : Globals.prefs.get(JabRefPreferences.PREVIEW_1); preview = new PreviewPanel(null, null, layoutFile); sortedEntries = new SortedList<>(entries, new EntryComparator(false, true, FieldName.AUTHOR)); model = (DefaultEventTableModel<BibEntry>) GlazedListsSwing .eventTableModelWithThreadProxyList(sortedEntries, new EntryTableFormat()); entryTable = new JTable(model); GeneralRenderer renderer = new GeneralRenderer(Color.white); entryTable.setDefaultRenderer(JLabel.class, renderer); entryTable.setDefaultRenderer(String.class, renderer); setWidths();//from w ww . j av a2 s . c om TableComparatorChooser<BibEntry> tableSorter = TableComparatorChooser.install(entryTable, sortedEntries, AbstractTableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); setupComparatorChooser(tableSorter); JScrollPane sp = new JScrollPane(entryTable); final DefaultEventSelectionModel<BibEntry> selectionModel = (DefaultEventSelectionModel<BibEntry>) GlazedListsSwing .eventSelectionModelWithThreadProxyList(sortedEntries); entryTable.setSelectionModel(selectionModel); selectionModel.getSelected().addListEventListener(new EntrySelectionListener()); entryTable.addMouseListener(new TableClickListener()); contentPane.setTopComponent(sp); contentPane.setBottomComponent(preview); // Key bindings: AbstractAction closeAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { diag.dispose(); } }; ActionMap am = contentPane.getActionMap(); InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", closeAction); entryTable.getActionMap().put("copy", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (!selectionModel.getSelected().isEmpty()) { List<BibEntry> bes = selectionModel.getSelected(); TransferableBibtexEntry trbe = new TransferableBibtexEntry(bes); // ! look at ClipBoardManager Toolkit.getDefaultToolkit().getSystemClipboard().setContents(trbe, frame.getCurrentBasePanel()); frame.output(Localization.lang("Copied") + ' ' + (bes.size() > 1 ? bes.size() + " " + Localization.lang("entries") : "1 " + Localization.lang("entry") + '.')); } } }); diag.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { contentPane.setDividerLocation(0.5f); } @Override public void windowClosing(WindowEvent event) { Globals.prefs.putInt(JabRefPreferences.SEARCH_DIALOG_WIDTH, diag.getSize().width); Globals.prefs.putInt(JabRefPreferences.SEARCH_DIALOG_HEIGHT, diag.getSize().height); } }); diag.getContentPane().add(contentPane, BorderLayout.CENTER); // Remember and default to last size: diag.setSize(new Dimension(Globals.prefs.getInt(JabRefPreferences.SEARCH_DIALOG_WIDTH), Globals.prefs.getInt(JabRefPreferences.SEARCH_DIALOG_HEIGHT))); diag.setLocationRelativeTo(frame); }
From source file:net.sf.jabref.gui.FileListEntryEditor.java
public FileListEntryEditor(JabRefFrame frame, FileListEntry entry, boolean showProgressBar, boolean showOpenButton, BibDatabaseContext databaseContext) { this.entry = entry; this.databaseContext = databaseContext; ActionListener okAction = e -> { // If OK button is disabled, ignore this event: if (!ok.isEnabled()) { return; }//w w w . ja v a2s.c o m // If necessary, ask the external confirm object whether we are ready to close. if (externalConfirm != null) { // Construct an updated FileListEntry: storeSettings(entry); if (!externalConfirm.confirmClose(entry)) { return; } } diag.dispose(); storeSettings(FileListEntryEditor.this.entry); okPressed = true; }; types = new JComboBox<>(); types.addItemListener(itemEvent -> { if (!okDisabledExternally) { ok.setEnabled(types.getSelectedItem() != null); } }); FormBuilder builder = FormBuilder.create().layout(new FormLayout( "left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p")); builder.add(Localization.lang("Link")).xy(1, 1); builder.add(link).xy(3, 1); final BrowseListener browse = new BrowseListener(frame, link); final JButton browseBut = new JButton(Localization.lang("Browse")); browseBut.addActionListener(browse); builder.add(browseBut).xy(5, 1); JButton open = new JButton(Localization.lang("Open")); if (showOpenButton) { builder.add(open).xy(7, 1); } builder.add(Localization.lang("Description")).xy(1, 3); builder.add(description).xyw(3, 3, 3); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); builder.add(Localization.lang("File type")).xy(1, 5); builder.add(types).xyw(3, 5, 3); if (showProgressBar) { builder.appendRows("2dlu, p"); builder.add(downloadLabel).xy(1, 7); builder.add(prog).xyw(3, 7, 3); } ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addRelatedGap(); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); ok.addActionListener(okAction); // Add OK action to the two text fields to simplify entering: link.addActionListener(okAction); description.addActionListener(okAction); open.addActionListener(e -> openFile()); AbstractAction cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { diag.dispose(); } }; cancel.addActionListener(cancelAction); // Key bindings: ActionMap am = builder.getPanel().getActionMap(); InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelAction); link.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { checkExtension(); } @Override public void removeUpdate(DocumentEvent documentEvent) { // Do nothing } @Override public void changedUpdate(DocumentEvent documentEvent) { checkExtension(); } }); diag = new JDialog(frame, Localization.lang("Save file"), true); diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); diag.pack(); diag.setLocationRelativeTo(frame); diag.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent event) { if (openBrowseWhenShown && !dontOpenBrowseUntilDisposed) { dontOpenBrowseUntilDisposed = true; SwingUtilities.invokeLater(() -> browse.actionPerformed(new ActionEvent(browseBut, 0, ""))); } } @Override public void windowClosed(WindowEvent event) { dontOpenBrowseUntilDisposed = false; } }); setValues(entry); }
From source file:org.zaproxy.zap.extension.ascan.ScanProgressDialog.java
/** * /*from w ww . j av a2s . c om*/ */ private void initialize() { this.setSize(new Dimension(580, 504)); if (site != null) { this.setTitle(MessageFormat.format(Constant.messages.getString("ascan.progress.title"), site)); } 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)); tab1.add(new JLabel(), LayoutHelper.getGBC(0, 1, 1, 1.0D, 0.0D)); // spacer tab1.add(getCloseButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D, 0.0D)); tab1.add(new JLabel(), LayoutHelper.getGBC(2, 1, 1, 1.0D, 0.0D)); // spacer 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()); this.seriesTotal = new TimeSeries("TotalResponses"); // Name not shown, so no need to i18n 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")); this.seriesTotal.setMaximumItemAge(mins * 60); this.series100.setMaximumItemAge(mins * 60); this.series200.setMaximumItemAge(mins * 60); this.series300.setMaximumItemAge(mins * 60); this.series400.setMaximumItemAge(mins * 60); this.series500.setMaximumItemAge(mins * 60); dataset.addSeries(series100); dataset.addSeries(series200); dataset.addSeries(series300); dataset.addSeries(series400); dataset.addSeries(series500); chart = createChart(dataset); // Set up some vaguesly sensible colours chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.BLACK); // Totals chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.GRAY); // 100: Info chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GREEN); // 200: OK chart.getXYPlot().getRenderer(0).setSeriesPaint(3, Color.BLUE); // 300: Info chart.getXYPlot().getRenderer(0).setSeriesPaint(4, Color.MAGENTA); // 400: Bad req chart.getXYPlot().getRenderer(0).setSeriesPaint(5, Color.RED); // 500: Internal error 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; } }); }
From source file:dk.dma.epd.common.prototype.gui.route.RoutePropertiesDialogCommon.java
/** * Constructor/*from ww w . j a v a 2s . com*/ * * @param parent the parent window * @param route the route * @param readOnlyRoute whether the route is read-only or not */ public RoutePropertiesDialogCommon(Window parent, ChartPanelCommon chartPanel, Route route, boolean readOnlyRoute) { super(parent, "Route Properties", Dialog.ModalityType.APPLICATION_MODAL); this.parent = parent; this.chartPanel = chartPanel; this.route = route; this.readOnlyRoute = readOnlyRoute; locked = new boolean[route.getWaypoints().size()]; addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { EPD.getInstance().getRouteManager().validateMetoc(RoutePropertiesDialogCommon.this.route); } }); initGui(); initValues(); setBounds(100, 100, 1000, 450); setLocationRelativeTo(parent); }