List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:de.tor.tribes.ui.views.DSWorkbenchDistanceFrame.java
private void buildMenu() { JXTaskPane editPane = new JXTaskPane(); editPane.setTitle("Bereichsfrbung"); slider = new com.visutools.nav.bislider.BiSlider(); slider.setBackground(getBackground()); slider.setSegmentSize(10);/*from ww w . j a va2 s.com*/ slider.setMinimumValue(0); slider.setMaximumColor(Constants.DS_BACK_LIGHT); slider.setMinimumColor(Constants.DS_BACK_LIGHT); slider.setMaximumValue(70); slider.setMinimumColoredValue(10); slider.setMaximumColoredValue(20); slider.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseReleased(java.awt.event.MouseEvent evt) { cellRenderer.setMarkerMin(slider.getMinimumColoredValue()); cellRenderer.setMarkerMax(slider.getMaximumColoredValue()); jDistanceTable.repaint(); } }); editPane.getContentPane().add(slider); JXTaskPane unitPane = new JXTaskPane(); unitPane.setTitle("Einheitsauswahl"); unitPane.getContentPane().add(unitBox); JXTaskPane transferTaskPane = new JXTaskPane(); transferTaskPane.setTitle("bertragen"); JXButton centerVillageInGame = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/center_ingame.png"))); centerVillageInGame.setToolTipText("Zentriert das gewhlte Dorf im Spiel"); centerVillageInGame.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { centerSelectionInGame(); } }); transferTaskPane.getContentPane().add(centerVillageInGame); JXButton openPlace = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/place.png"))); openPlace.setToolTipText("ffnet den Versammlungsplatz des gewhlten Dorfes im Spiel"); openPlace.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { openPlaceOfSelectionInGame(); } }); openPlace.setSize(centerVillageInGame.getSize()); openPlace.setMinimumSize(centerVillageInGame.getMinimumSize()); openPlace.setMaximumSize(centerVillageInGame.getMaximumSize()); openPlace.setPreferredSize(centerVillageInGame.getPreferredSize()); transferTaskPane.getContentPane().add(openPlace); JXButton centerVillage = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/center_24x24.png"))); centerVillage.setToolTipText("Zentriert das gewhlte Dorf auf der Hauptkarte"); centerVillage.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { centerSelectionOnMap(); } }); transferTaskPane.getContentPane().add(centerVillage); centerPanel.setupTaskPane(editPane, unitPane, transferTaskPane); }
From source file:com.googlecode.blaisemath.app.MenuConfig.java
private static JButton popupButton(String name, final JPopupMenu popup) { final JButton button = new JButton(name); button.addMouseListener(new MouseAdapter() { @Override/*from w w w . j a va2 s. co m*/ public void mousePressed(MouseEvent e) { popup.show(e.getComponent(), e.getX(), e.getY()); } }); return button; }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterListEdtDlg.java
/** * //from w w w . ja va2s . c om */ private void hookFormatListMouseListener() { MouseAdapter mAdp = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int index = formatList.locationToIndex(e.getPoint()); formatList.ensureIndexIsVisible(index); editFormatter((UIFieldFormatter) formatList.getSelectedValue(), false); } } }; formatList.addMouseListener(mAdp); }
From source file:com.haskins.cloudtrailviewer.sidebar.AbstractChart.java
private void addTable() { defaultTableModel.addColumn(""); defaultTableModel.addColumn("Property"); defaultTableModel.addColumn("Value"); final LegendColourRenderer cellRenderer = new LegendColourRenderer(); final JTable table = new JTable(defaultTableModel) { private static final long serialVersionUID = -6272711583089149891L; @Override//from w ww.j a va 2 s.com public TableCellRenderer getCellRenderer(int row, int column) { if (column == 0) { return cellRenderer; } return super.getCellRenderer(row, column); } @Override public boolean isCellEditable(int row, int column) { return false; } }; table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); String value = (String) defaultTableModel.getValueAt(table.getSelectedRow(), 1); if (me.getClickCount() == 2) { if (value.startsWith("i-")) { Event event = null; AllFilter filter = new AllFilter(); filter.setNeedle(value); for (Event searchEvent : eventDb.getEvents()) { if (filter.passesFilter(searchEvent)) { event = searchEvent; break; } } if (event != null) { AwsAccount account = AccountDao.getAccountByAcctNum(event.getRecipientAccountId()); ResourceDetailRequest request = new ResourceDetailRequest(account, event.getAwsRegion(), "EC2 Instance", value); ResourceDetailDialog.showDialog(CloudTrailViewer.frame, request); } } } else if (me.getClickCount() == 1) { try { eventTablePanel.setFilterString(value); } catch (Exception ex) { LOGGER.log(Level.WARNING, "Problem responding to mouse event on chart table", ex); } } } }); TableColumn column; for (int i = 0; i < 3; i++) { column = table.getColumnModel().getColumn(i); switch (i) { case 0: column.setMinWidth(15); column.setMaxWidth(15); column.setPreferredWidth(15); break; case 2: column.setMinWidth(70); column.setMaxWidth(70); column.setPreferredWidth(70); break; } } JScrollPane tablecrollPane = new JScrollPane(table); tablecrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.add(tablecrollPane, BorderLayout.CENTER); }
From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java
private void buildMenu() { JXTaskPane editPane = new JXTaskPane(); editPane.setTitle("Bearbeiten"); final JToggleButton createStats = new JToggleButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/medal.png"))); createStats.setToolTipText(/*w w w. j a v a 2 s .c o m*/ "Umschalten zwischen dem Erzeugen von Statistiken und der Anzeige von Verlaufsgrafiken"); createStats.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { boolean showChartView = !createStats.isSelected(); if (showChartView) { createStats .setIcon(new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/medal.png"))); } else { createStats .setIcon(new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/chart.png"))); } switchStatChartView(showChartView); } }); JXButton selectStart = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/beginning.png"))); selectStart.setToolTipText("Setzt eine Startmarkierung beim gewhlten Datenpunkt"); selectStart.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { setStartAnnotation(); } }); selectStart.setSize(createStats.getSize()); selectStart.setMinimumSize(createStats.getMinimumSize()); selectStart.setMaximumSize(createStats.getMaximumSize()); selectStart.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(selectStart); JXButton selectEnd = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/end.png"))); selectEnd.setToolTipText("Setzt eine Endmarkierung beim gewhlten Datenpunkt"); selectEnd.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { setEndAnnotation(); } }); selectEnd.setSize(createStats.getSize()); selectEnd.setMinimumSize(createStats.getMinimumSize()); selectEnd.setMaximumSize(createStats.getMaximumSize()); selectEnd.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(selectEnd); JXButton removeSelection = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/ui/delete_region.png"))); removeSelection.setToolTipText("Lscht alle Datenpunkte zwischen der Start- und Endmarkierung"); removeSelection.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { removeSelection(); } }); removeSelection.setSize(createStats.getSize()); removeSelection.setMinimumSize(createStats.getMinimumSize()); removeSelection.setMaximumSize(createStats.getMaximumSize()); removeSelection.setPreferredSize(createStats.getPreferredSize()); editPane.getContentPane().add(removeSelection); createStats.setSize(removeSelection.getSize()); createStats.setMinimumSize(removeSelection.getMinimumSize()); createStats.setMaximumSize(removeSelection.getMaximumSize()); createStats.setPreferredSize(removeSelection.getPreferredSize()); editPane.getContentPane().add(createStats); JXTaskPane viewPane = new JXTaskPane(); viewPane.setTitle("Anzeige"); viewPane.getContentPane().add(jViewSelectionBox); JXTaskPane settingsPane = new JXTaskPane(); settingsPane.setTitle("Einstellungen"); settingsPane.getContentPane().add(jShowItemValues); settingsPane.getContentPane().add(jShowLegend); settingsPane.getContentPane().add(jShowLines); settingsPane.getContentPane().add(jShowDataPoints); centerPanel.setupTaskPane(editPane, viewPane, settingsPane); }
From source file:io.github.jeremgamer.editor.panels.Others.java
public Others(final JFrame frame, final OtherPanel op, final PanelSave ps) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;//from w ww .ja va 2 s. c om try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(otherList), "Nommez le composant :", "Crer un composant", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new OtherSave(name); ActionPanel.updateLists(); PanelsPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (otherList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/others/" + otherList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(otherList), "tes-vous sr de vouloir supprimer ce composant?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } OtherSave os = new OtherSave(); try { os.load(file); } catch (IOException e1) { e1.printStackTrace(); } String type = null; switch (os.getInt("type")) { case 0: type = "Zone de saisie"; break; case 1: type = "Zone de saisie de mot de passe"; break; case 2: type = "Zone de saisie (Grande)"; break; case 3: type = "Case cocher"; break; case 4: type = "Menu droulant"; break; case 5: type = "Barre de progression"; break; case 6: type = "Slider"; break; case 7: type = "Spinner"; break; } for (String section : ps.getSectionsContaining( otherList.getSelectedValue() + " (" + type + ")")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (otherList.getSelectedValue().equals(op.getFileName())) { op.setFileName(""); } op.hide(); file.delete(); data.remove(otherList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); otherList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { op.show(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { op.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { op.hideThenShow(); previousSelection = list.getSelectedValue(); op.load(new File("projects/" + Editor.getProjectName() + "/others/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { op.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(otherList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); OtherPanel.updateLists(); }
From source file:edu.ku.brc.specify.tasks.subpane.ESResultsTablePanel.java
/** * Constructor of a results "table" which is really a panel * @param esrPane the parent/*from ww w . j a v a 2s .c om*/ * @param erTableInfo the info describing the results * @param installServices indicates whether services should be installed * @param isExpandedAtStartUp enough said * @param inclCloseBtn whether to include the close button on the bar */ public ESResultsTablePanel(final ExpressSearchResultsPaneIFace esrPane, final QueryForIdResultsIFace results, final boolean installServices, final boolean isExpandedAtStartUp, final boolean inclCloseBtn) { super(new BorderLayout()); this.esrPane = esrPane; this.results = results; this.bannerColor = results.getBannerColor(); this.isEditable = results.isEditingEnabled(); table = new JTable(); table.setShowVerticalLines(false); table.setRowSelectionAllowed(true); table.setSelectionMode(results.isMultipleSelection() ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION : ListSelectionModel.SINGLE_SELECTION); setBackground(table.getBackground()); if (isEditable) { addContextMenu(); } topTitleBar = new GradiantLabel(results.getTitle(), SwingConstants.LEFT); topTitleBar.setBGBaseColor(bannerColor); topTitleBar.setTextColor(Color.WHITE); topTitleBar.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { expandBtn.doClick(); } } }); String description = results.getDescription(); if (StringUtils.isNotEmpty(description)) { topTitleBar.setToolTipText(description); } expandBtn = new TriangleButton(); expandBtn.setToolTipText(getResourceString("CollapseTBL")); expandBtn.setForeground(bannerColor); expandBtn.setTextColor(Color.WHITE); showTopNumEntriesBtn = new GradiantButton( String.format(getResourceString("ShowTopEntries"), new Object[] { topNumEntries })); showTopNumEntriesBtn.setForeground(bannerColor); showTopNumEntriesBtn.setTextColor(Color.WHITE); showTopNumEntriesBtn.setVisible(false); showTopNumEntriesBtn.setCursor(handCursor); List<ServiceInfo> services = installServices ? getServices() : null; //System.out.println("["+tableInfo.getTableId()+"]["+services.size()+"]"); StringBuffer colDef = new StringBuffer("p,0px,p:g,0px,p,0px,"); int numCols = (installServices ? services.size() : 0) + (inclCloseBtn ? 1 : 0); colDef.append(UIHelper.createDuplicateJGoodiesDef("p", "0px", numCols)); // add additional col defs for services PanelBuilder builder = new PanelBuilder(new FormLayout(colDef.toString(), "f:p:g")); CellConstraints cc = new CellConstraints(); int col = 1; builder.add(expandBtn, cc.xy(col, 1)); col += 2; builder.add(topTitleBar, cc.xy(col, 1)); col += 2; builder.add(showTopNumEntriesBtn, cc.xy(col, 1)); col += 2; if (installServices && services.size() > 0) { serviceBtns = new Hashtable<ServiceInfo, JButton>(); //IconManager.IconSize size = IconManager. int iconSize = AppPreferences.getLocalPrefs().getInt("banner.icon.size", 20); // Install the buttons on the banner with available services for (ServiceInfo serviceInfo : services) { GradiantButton btn = new GradiantButton(serviceInfo.getIcon(iconSize)); // XXX PREF btn.setToolTipText(serviceInfo.getTooltip()); btn.setForeground(bannerColor); builder.add(btn, cc.xy(col, 1)); ESTableAction esta = new ESTableAction(serviceInfo.getCommandAction(), table, serviceInfo.getTooltip()); esta.setProperty("gridtitle", results.getTitle()); btn.addActionListener(esta); serviceBtns.put(serviceInfo, btn); col += 2; } } GradiantButton closeBtn = null; if (inclCloseBtn) { closeBtn = new GradiantButton(IconManager.getIcon("Close")); closeBtn.setToolTipText(getResourceString("ESCloseTable")); closeBtn.setForeground(bannerColor); closeBtn.setRolloverEnabled(true); closeBtn.setRolloverIcon(IconManager.getIcon("CloseHover")); closeBtn.setPressedIcon(IconManager.getIcon("CloseHover")); builder.add(closeBtn, cc.xy(col, 1)); col += 2; } add(builder.getPanel(), BorderLayout.NORTH); tablePane = new JPanel(new BorderLayout()); setupTablePane(); if (isEditable) { //delRSItems = UIHelper.createI18NButton("RESTBL_DEL_ITEMS"); delRSItems = UIHelper.createIconBtn("DelRec", "ESDelRowsTT", null); delRSItems.addActionListener(createRemoveItemAL()); delRSItems.setEnabled(false); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { delRSItems.setEnabled(table.getSelectedRowCount() > 0); } } }); } add(tablePane, BorderLayout.CENTER); moveToRSCmd = new DragSelectedRowsBtn(IconManager.getIcon("Record_Set", IconManager.IconSize.Std16)); if (installServices) { PanelBuilder bottomBar = new PanelBuilder( new FormLayout("4px,p,4px,p,4px,p," + (delRSItems != null ? "4px,p," : "") + "f:p:g", "p")); bottomBar.add(moveToRSCmd, cc.xy(2, 1)); bottomBar.add(selectAllBtn, cc.xy(4, 1)); bottomBar.add(deselectAllBtn, cc.xy(6, 1)); if (delRSItems != null) { bottomBar.add(delRSItems, cc.xy(8, 1)); } botBtnPanel = bottomBar.getPanel(); deselectAllBtn.setEnabled(false); selectAllBtn.setEnabled(true); moveToRSCmd.setEnabled(true); deselectAllBtn.setToolTipText(getResourceString("SELALLTOOLTIP")); selectAllBtn.setToolTipText(getResourceString("DESELALLTOOLTIP")); moveToRSCmd.setToolTipText(getResourceString("MOVEROWSTOOLTIP")); selectAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.selectAll(); } }); deselectAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.clearSelection(); } }); moveToRSCmd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { RecordSetIFace src = (RecordSetIFace) moveToRSCmd.getData(); CommandDispatcher .dispatch(new CommandAction(RecordSetTask.RECORD_SET, "AskForNewRS", src, null, null)); } }); add(botBtnPanel, BorderLayout.SOUTH); } else { botBtnPanel = null; } expandBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { expandTable(false); } }); if (!isExpandedAtStartUp) { expandTable(true); } showTopNumEntriesBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { morePanel.setVisible(true); showTopNumEntriesBtn.setVisible(false); showingAllRows = false; setDisplayRows(rowCount, topNumEntries); // If it is collapsed then expand it if (!expandBtn.isDown()) { tablePane.setVisible(true); expandBtn.setDown(true); } // Make sure the layout is updated invalidate(); doLayout(); esrPane.revalidateScroll(); } }); if (closeBtn != null) { closeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { removeMe(); } }); } }); } ResultSetTableModel rsm = createModel(); rsm.setPropertyListener(this); resultSetTableModel = rsm; table.setRowSorter(new TableRowSorter<ResultSetTableModel>(resultSetTableModel)); table.setRowSelectionAllowed(true); table.setModel(rsm); configColumns(); rowCount = rsm.getRowCount(); if (rowCount > topNumEntries + 2) { buildMorePanel(); setDisplayRows(rowCount, topNumEntries); } else { setDisplayRows(rowCount, Integer.MAX_VALUE); } invalidate(); doLayout(); UIRegistry.forceTopFrameRepaint(); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (botBtnPanel != null) { deselectAllBtn.setEnabled(table.getSelectedRowCount() > 0); selectAllBtn.setEnabled(table.getSelectedRowCount() != table.getRowCount()); moveToRSCmd.setEnabled(table.getSelectedRowCount() > 0); } } if (propChangeListener != null) { if (!e.getValueIsAdjusting()) { propChangeListener.propertyChange( new PropertyChangeEvent(this, "selection", table.getSelectedRowCount(), 0)); } else { propChangeListener.propertyChange( new PropertyChangeEvent(this, "selection", table.getSelectedRowCount(), 0)); } } } }); table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { //synchronized (((JTable)e.getSource()).getTreeLock()) //{ doDoubleClickOnRow(e); //} } }); // Horizontal Alignment is set later TableColumnModel tableColModel = table.getColumnModel(); for (int i = 0; i < tableColModel.getColumnCount(); i++) { tableColModel.getColumn(i).setCellRenderer(new BiColorTableCellRenderer()); } }
From source file:com.excilys.ebi.gatling.recorder.ui.component.RunningFrame.java
public RunningFrame() { /* Initialization of the frame */ setTitle("Gatling Recorder - Running..."); setMinimumSize(new Dimension(800, 640)); setLocationRelativeTo(null);//from w w w.ja va 2 s.c om setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); setIconImages(Commons.getIconList()); /* Declaration & initialization of components */ JButton btnClear = new JButton("Clear"); final JButton btnStop = new JButton("Stop !"); btnStop.setSize(120, 30); JScrollPane panelFilters = new JScrollPane(executedEvents); panelFilters.setPreferredSize(new Dimension(300, 100)); stringRequest.setPreferredSize(new Dimension(330, 100)); JSplitPane requestResponsePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(stringRequest), new JScrollPane(stringResponse)); final JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, requestResponsePane, stringRequestBody); JScrollPane panelHostsCertificate = new JScrollPane(requiredHostsCertificate); panelHostsCertificate.setPreferredSize(new Dimension(300, 100)); /* Layout */ GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(10, 5, 0, 0); gbc.gridx = 0; gbc.anchor = GridBagConstraints.LINE_START; gbc.gridy = 0; add(new JLabel("Tag :"), gbc); gbc.gridx = 1; add(txtTag, gbc); gbc.gridx = 2; gbc.weightx = 0.5; add(btnTag, gbc); gbc.gridx = 3; gbc.anchor = GridBagConstraints.CENTER; gbc.weightx = 0.25; add(btnClear, gbc); gbc.gridx = 4; gbc.anchor = GridBagConstraints.LINE_END; add(btnStop, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0; gbc.anchor = GridBagConstraints.LINE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; add(new JLabel("Executed Events:"), gbc); gbc.gridy = 2; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1; gbc.weighty = 0.20; gbc.fill = GridBagConstraints.BOTH; add(panelFilters, gbc); gbc.gridy = 4; gbc.weightx = 1; gbc.weighty = 0.75; gbc.fill = GridBagConstraints.BOTH; add(sp, gbc); gbc.gridy = 5; gbc.weighty = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = GridBagConstraints.CENTER; add(new JLabel("Secured hosts requiring accepting a certificate:"), gbc); gbc.gridy = 6; gbc.weighty = 0.05; gbc.gridwidth = GridBagConstraints.REMAINDER; add(panelHostsCertificate, gbc); /* Listeners */ btnTag.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!txtTag.getText().equals(EMPTY)) { TagEvent tag = new TagEvent(txtTag.getText()); events.addElement(tag.toString()); executedEvents.ensureIndexIsVisible(events.getSize() - 1); listEvents.add(tag); txtTag.setText(EMPTY); } } }); executedEvents.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (executedEvents.getSelectedIndex() >= 0) { Object obj = listEvents.get(executedEvents.getSelectedIndex()); if (obj instanceof ResponseReceivedEvent) { ResponseReceivedEvent event = (ResponseReceivedEvent) obj; stringRequest.txt.setText(event.getRequest().toString()); stringResponse.txt.setText(event.getResponse().toString()); stringRequestBody.txt.setText(new String(event.getRequest().getContent().array())); } else { stringRequest.txt.setText(EMPTY); stringResponse.txt.setText(EMPTY); stringRequestBody.txt.setText(EMPTY); } } } }); btnClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clearOldRunning(); } }); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { saveScenario(); proxy.shutdown(); proxy = null; if (!Configuration.getInstance().isConfigurationSkipped()) getEventBus().post(new ShowConfigurationFrameEvent()); else System.exit(0); } }); }
From source file:de.tor.tribes.ui.views.DSWorkbenchTagFrame.java
private void buildMenu() { JXTaskPane editPane = new JXTaskPane(); editPane.setTitle("Bearbeiten"); JXButton addButton = new JXButton(new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/add.png"))); addButton.setToolTipText("Erstellt einen neuen Gruppe"); addButton.addMouseListener(new MouseAdapter() { @Override/* w ww . j av a 2 s . c om*/ public void mouseReleased(MouseEvent e) { int unusedId = 1; while (unusedId < 1000) { if (TagManager.getSingleton().getTagByName("Neue Gruppe " + unusedId) == null) { TagManager.getSingleton().addTag("Neue Gruppe " + unusedId); break; } unusedId++; } if (unusedId == 1000) { JOptionPaneHelper.showErrorBox(DSWorkbenchTagFrame.this, "Du hast mehr als 1000 Gruppen. Bitte lsche zuerst ein paar bevor du Neue erstellst.", "Fehler"); } } }); editPane.getContentPane().add(addButton); JXButton linkButton = new JXButton( new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/branch.png"))); linkButton.setToolTipText("Verknpft mehrerer Gruppen zu einem neuen Gruppe"); linkButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { LinkedTag t = new LinkTagsDialog(DSWorkbenchTagFrame.this, true).setupAndShow(); if (t != null) { TagManager.getSingleton().addLinkedTag(t); } } }); editPane.getContentPane().add(linkButton); JXButton colorRemoveButton = new JXButton( new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/color_remove.png"))); colorRemoveButton.setToolTipText("Entfernt die Farbe der Kartenmarkierung fr die gewhlten Gruppen"); colorRemoveButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { for (Tag t : getSelectedTags()) { t.setTagColor(null); } TagManager.getSingleton().fireDataChangedEvents(); } }); editPane.getContentPane().add(colorRemoveButton); JXTaskPane transferTaskPane = new JXTaskPane(); transferTaskPane.setTitle("bertragen"); JXButton centerIngame = new JXButton( new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/center_ingame.png"))); centerIngame.setToolTipText("Zentriert das gewhlte Dorf im Spiel"); centerIngame.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { centerVillageInGame(); } }); transferTaskPane.getContentPane().add(centerIngame); JXButton transferJS = new JXButton( new ImageIcon(DSWorkbenchTagFrame.class.getResource("/res/ui/export_js.png"))); transferJS.setToolTipText( "<html>Alle Dörfer der gewählten Gruppe in die Zwischenablage kopieren.<BR/>Auf diesem Wege ist es z.B. möglich, verknüpfte Gruppen aus DS Workbench ins Spiel zu übertragen.<BR>Für weitere Informationen sieh bitte in der Hilfe nach.</html>"); transferJS.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { transferSelectedTagsToJS(); } }); transferTaskPane.getContentPane().add(transferJS); if (!GlobalOptions.isMinimal()) { JXButton centerButton = new JXButton( new ImageIcon(DSWorkbenchChurchFrame.class.getResource("/res/center_24x24.png"))); centerButton.setToolTipText("Zentriert das erste gewhlte Dorf auf der Hauptkarte"); centerButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { centerVillage(); } }); transferTaskPane.getContentPane().add(centerButton); } centerPanel.setupTaskPane(editPane, transferTaskPane); }
From source file:com.mirth.connect.client.ui.components.MirthTreeTable.java
public void setMirthColumnControlEnabled(boolean enable) { if (enable) { if (rightClickMouseAdapter == null) { rightClickMouseAdapter = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { getColumnMenu().show(e.getComponent(), e.getX(), e.getY()); }/*from w w w . j ava2 s. c o m*/ } }; getTableHeader().addMouseListener(rightClickMouseAdapter); } } else { if (rightClickMouseAdapter != null) { getTableHeader().removeMouseListener(rightClickMouseAdapter); rightClickMouseAdapter = null; } } setColumnControlVisible(enable); }