List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:net.brtly.monkeyboard.plugin.ConsolePanel.java
public ConsolePanel(PluginDelegate service) { super(service); setLayout(new MigLayout("inset 5", "[grow][:100:100][24:n:24][24:n:24]", "[::24][grow]")); JComboBox comboBox = new JComboBox(); comboBox.setToolTipText("Log Level"); comboBox.setMaximumRowCount(6);/*from w w w. j av a 2 s. co m*/ comboBox.setModel( new DefaultComboBoxModel(new String[] { "Fatal", "Error", "Warn", "Info", "Debug", "Trace" })); comboBox.setSelectedIndex(5); add(comboBox, "cell 1 0,growx"); JButton btnC = new JButton(""); btnC.setToolTipText("Clear Buffer"); btnC.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/clear-document.png"))); btnC.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { logPangrams(); } }); add(btnC, "cell 2 0,wmax 24,hmax 26"); tglbtnV = new JToggleButton(""); tglbtnV.setToolTipText("Auto Scroll"); tglbtnV.setIcon(new ImageIcon(ConsolePanel.class.getResource("/img/auto-scroll.png"))); tglbtnV.setSelected(true); tglbtnV.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { _table.setAutoScroll(true); } else if (ev.getStateChange() == ItemEvent.DESELECTED) { _table.setAutoScroll(false); } } }); add(tglbtnV, "cell 3 0,wmax 24,hmax 26"); scrollPane = new JScrollPane(); scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { // TODO figure out what to do with this event? } }); add(scrollPane, "cell 0 1 4 1,grow"); _table = new JLogTable("Time", "Source", "Message"); _table.getColumnModel().getColumn(0).setMinWidth(50); _table.getColumnModel().getColumn(0).setPreferredWidth(50); _table.getColumnModel().getColumn(0).setMaxWidth(100); _table.getColumnModel().getColumn(1).setMinWidth(50); _table.getColumnModel().getColumn(1).setPreferredWidth(50); _table.getColumnModel().getColumn(1).setMaxWidth(100); _table.getColumnModel().getColumn(2).setMinWidth(50); _table.getColumnModel().getColumn(2).setWidth(255); _table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); scrollPane.setViewportView(_table); _appender = new JLogTableAppender(); _appender.setThreshold(Level.ALL); Logger.getRootLogger().addAppender(_appender); }
From source file:de.wusel.partyplayer.gui.LockingStatusbar.java
public LockingStatusbar(Application application, final JFrame mainFrame, final Settings settings) { this.application = application; this.settings = settings; this.application.getContext().getTaskMonitor().addPropertyChangeListener(listener); statusLabel = new JLabel("Ready"); fileReaderProgressBar = new JProgressBar(0, 100); pinCodeInputField = new JPasswordField(); PromptSupport.setPrompt("pin-code", pinCodeInputField); PromptSupport.setForeground(Color.GRAY, pinCodeInputField); pinCodeInputField.addMouseListener(new MouseAdapter() { @Override//from w w w . ja va2s . c o m public void mouseClicked(MouseEvent e) { if (!pinCodeInputField.isEnabled()) { ChangePasswordDialog dialog = new ChangePasswordDialog(mainFrame, settings); dialog.setVisible(true); if (dialog.getStatus() == DialogStatus.CONFIRMED) { settings.setNewPassword(dialog.getPassDigest()); settings.backup(PathUtil.getSettingsFile()); } } } }); pinCodeInputField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean unlocked = settings .isPasswordValid(DigestUtils.md5Hex(new String(pinCodeInputField.getPassword()))); if (unlocked) { pinCodeInputField.transferFocus(); unlock(); } pinCodeInputField.setText(null); } }); lockButton = new JToggleButton(); lockButton.setIcon(getIcon("lock")); lockButton.setSelectedIcon(getIcon("lock_open")); lockButton.setEnabled(false); lockButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { lock(); } }); this.settingsButton = new JButton(getIcon("cog_edit")); this.settingsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showSettings(); } }); add(statusLabel, new JXStatusBar.Constraint(JXStatusBar.Constraint.ResizeBehavior.FILL)); add(fileReaderProgressBar, new JXStatusBar.Constraint(200)); add(pinCodeInputField, new JXStatusBar.Constraint(100)); add(lockButton, new JXStatusBar.Constraint()); add(settingsButton, new JXStatusBar.Constraint()); this.mainFrame = mainFrame; }
From source file:gtu._work.etc.HotnoteMakerUI.java
private void initGUI() { try {/*from w ww . jav a2 s . c o m*/ ToolTipManager.sharedInstance().setInitialDelay(0); BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("hott notes - checklist", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(612, 348)); { checkListArea = new JTextArea(); jScrollPane1.setViewportView(checkListArea); checkListArea.addMouseListener(new MouseAdapter() { String randomColor() { StringBuilder sb = new StringBuilder().append("#"); for (int ii = 0; ii < 6; ii++) { sb.append(RandomUtil.randomChar('a', 'b', 'c', 'd', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')); } return sb.toString(); } void saveXml(Document document, File file) { OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("utf-16"); XMLWriter writer = null; try { writer = new XMLWriter(new FileWriter(file), format); writer.write(document); } catch (IOException e) { JCommonUtil.handleException(e); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { JCommonUtil.handleException(e); } } } } public void mouseClicked(MouseEvent evt) { if (!JMouseEventUtil.buttonLeftClick(2, evt)) { return; } if (StringUtils.isEmpty(checkListArea.getText())) { JCommonUtil ._jOptionPane_showMessageDialog_error("checklist area is empty!"); return; } File file = JCommonUtil._jFileChooser_selectFileOnly_saveFile(); if (file == null) { JCommonUtil._jOptionPane_showMessageDialog_error("file is not correct!"); return; } //XXX StringTokenizer tok = new StringTokenizer(checkListArea.getText(), "\t\n\r\f"); List<String> list = new ArrayList<String>(); String tmp = null; for (; tok.hasMoreElements();) { tmp = ((String) tok.nextElement()).trim(); System.out.println(tmp); list.add(tmp); } //XXX Document document = DocumentHelper.createDocument(); Element rootHot = document.addElement("hottnote"); rootHot.addAttribute("creationtime", new Timestamp(System.currentTimeMillis()).toString()); rootHot.addAttribute("lastmodified", new Timestamp(System.currentTimeMillis()).toString()); rootHot.addAttribute("type", "checklist"); //appearence Element appearenceE = rootHot.addElement("appearence"); appearenceE.addAttribute("alpha", "204"); Element fontE = appearenceE.addElement("font"); fontE.addAttribute("face", "Default"); fontE.addAttribute("size", "0"); Element styleE = appearenceE.addElement("style"); styleE.addElement("bg2color").addAttribute("color", randomColor()); styleE.addElement("bgcolor").addAttribute("color", randomColor()); styleE.addElement("textcolor").addAttribute("color", randomColor()); styleE.addElement("titlecolor").addAttribute("color", randomColor()); //behavior rootHot.addElement("behavior"); //content Element contentE = rootHot.addElement("content"); Element checklistE = contentE.addElement("checklist"); for (String val : list) { checklistE.addElement("item").addCDATA(val); } //desktop Element desktopE = rootHot.addElement("desktop"); desktopE.addElement("position").addAttribute("x", RandomUtil.numberStr(3)) .addAttribute("y", RandomUtil.numberStr(3)); desktopE.addElement("size").addAttribute("height", "200").addAttribute("width", "200"); //title Element titleE = rootHot.addElement("title"); titleE.addCDATA(StringUtils.defaultIfEmpty(checkListTitle.getText(), DateFormatUtils.format(System.currentTimeMillis(), "dd/MM/yyyy"))); if (!file.getName().toLowerCase().endsWith(".hottnote")) { file = new File(file.getParentFile(), file.getName() + ".hottnote"); } saveXml(document, file); JCommonUtil._jOptionPane_showMessageDialog_info("completed!\n" + file); } }); } } { checkListTitle = new JTextField(); checkListTitle.setToolTipText("title"); jPanel1.add(checkListTitle, BorderLayout.NORTH); } } } pack(); this.setSize(633, 415); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:ShapeTest.java
public ShapeComponent() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { Point p = event.getPoint(); for (int i = 0; i < points.length; i++) { double x = points[i].getX() - SIZE / 2; double y = points[i].getY() - SIZE / 2; Rectangle2D r = new Rectangle2D.Double(x, y, SIZE, SIZE); if (r.contains(p)) { current = i;/* w w w . jav a2 s . co m*/ return; } } } public void mouseReleased(MouseEvent event) { current = -1; } }); addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent event) { if (current == -1) return; points[current] = event.getPoint(); repaint(); } }); current = -1; }
From source file:de.tor.tribes.ui.components.TimePicker.java
private void initSpecialComponents() { for (int i = 0; i < hourLabels.length; i++) { CrossedLabel label = new CrossedLabel(); hourLabels[i] = label;/*from w w w . j a v a 2 s . c o m*/ if (i < 10) { label.setText("0" + Integer.toString(i)); } else { label.setText(Integer.toString(i)); } label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setBorder(javax.swing.BorderFactory.createLineBorder(Constants.DS_BACK)); label.setHorizontalAlignment(SwingConstants.CENTER); label.setOpaque(true); label.setBackground(Constants.DS_BACK_LIGHT); label.setFont(smallFont); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (selectedHour != null) { selectedHour.uncross(); } selectedHour = ((CrossedLabel) e.getSource()); selectedHour.cross(); for (int i = 0; i < hourLabels.length; i++) if (hourLabels[i] == selectedHour) { pHour = i; break; } } @Override public void mouseEntered(MouseEvent e) { ((CrossedLabel) e.getSource()).setBackground(highlight); } @Override public void mouseExited(MouseEvent e) { ((CrossedLabel) e.getSource()).setBackground(Constants.DS_BACK_LIGHT); } }); } addHourLabels(); for (int i = 0; i < minuteLabels.length; i++) { CrossedLabel label = new CrossedLabel(); minuteLabels[i] = label; if (i < 10) { label.setText(":0" + Integer.toString(i)); } else { label.setText(":" + Integer.toString(i)); } label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204))); label.setHorizontalAlignment(SwingConstants.CENTER); label.setOpaque(true); label.setBackground(Color.WHITE); label.setFont(smallFont); label.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (selectedMinute != null) { selectedMinute.uncross(); } selectedMinute = ((CrossedLabel) e.getSource()); selectedMinute.cross(); for (int i = 0; i < minuteLabels.length; i++) if (minuteLabels[i] == selectedMinute) { pMinute = i; break; } } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { ((CrossedLabel) e.getSource()).setBackground(highlight); } @Override public void mouseExited(MouseEvent e) { ((CrossedLabel) e.getSource()).setBackground(Color.WHITE); } }); } addMinuteLabels(false); }
From source file:burlov.ultracipher.swing.MainPanel.java
public MainPanel(Translator translator) { editDataPanel = new EditDataPanel(translator); translator.addToComponent(searchField); listPopup.add(getNewEntryAction());// ww w. ja v a2s .c om listPopup.add(getDeleteEntryAction()); setLayout(new BorderLayout()); add(splitPane); /* * Suchpanel initialisieren */ JPanel panel = new JPanel(new BorderLayout()); JPanel searchPanel = new JPanel(new BorderLayout()); searchPanel.add(new JLabel(new ImageIcon(getClass().getResource("find.png"))), BorderLayout.WEST); searchPanel.add(searchField, BorderLayout.CENTER); searchField.setToolTipText("Search"); panel.add(searchPanel, BorderLayout.NORTH); panel.add(new JScrollPane(searchResults), BorderLayout.CENTER); splitPane.setLeftComponent(panel); /* * Anzeigepanel initialisieren */ panel = new JPanel(new BorderLayout()); panel.add(editDataPanel, BorderLayout.CENTER); panel.add(new PassGeneratorPanel(), BorderLayout.SOUTH); splitPane.setRightComponent(panel); searchResults.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { showDeletePopup(e); } @Override public void mouseReleased(MouseEvent e) { showDeletePopup(e); } private void showDeletePopup(MouseEvent e) { if (!e.isPopupTrigger()) { return; } int index = searchResults.locationToIndex(e.getPoint()); if (index > -1) { searchResults.setSelectedIndex(index); } listPopup.show(e.getComponent(), e.getX(), e.getY()); } }); searchResults.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { editDataPanel.editData((DataEntry) searchResults.getSelectedValue(), false); } }); searchField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { initResultList(); } @Override public void insertUpdate(DocumentEvent e) { initResultList(); } @Override public void changedUpdate(DocumentEvent e) { initResultList(); } }); editDataPanel.addNameChangeListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } @Override public void insertUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } @Override public void changedUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } }); searchField.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showTextPopup(e); } else { // searchField.selectAll(); } } @Override public void mouseReleased(MouseEvent e) { showTextPopup(e); } }); // searchField.addFocusListener(new FocusListener() { // @Override // public void focusLost(FocusEvent e) { // System.out.println("MainPanel.MainPanel().new FocusListener() {...}.focusLost()"); // } // // @Override // public void focusGained(FocusEvent e) { // System.out.println("MainPanel.MainPanel().new FocusListener() {...}.focusGained()"); // //searchField.selectAll(); // } // }); }
From source file:com.unicauca.braim.braimclient.BraimGui.java
private void add_mouse_listener_to_list() { MouseListener mouseListener = new MouseAdapter() { @Override//from w ww . j a v a2s .c om public void mouseClicked(MouseEvent mouseEvent) { JList theList = (JList) mouseEvent.getSource(); if (mouseEvent.getClickCount() == 2) { int index = theList.locationToIndex(mouseEvent.getPoint()); if (index >= 0) { actualSong = actualSongList[index]; lbl_song_name.setText(actualSong.getName()); play_song(actualSong); } } } }; list_songs.addMouseListener(mouseListener); }
From source file:gtu._work.etc.GoogleContactUI.java
private void initGUI() { try {/*from ww w . j av a 2 s . c o m*/ BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("jPanel1", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { DefaultTableModel model = JTableUtil.createModel(false, googleColumns); model.addRow(new Object[googleColumns.length]); googleTable = new JTable(); jScrollPane1.setViewportView(googleTable); googleTable.setModel(model); googleTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JTableUtil.newInstance(googleTable).defaultToolTipText(evt); googleTableMouseClicked(evt); } }); JTableUtil.defaultSetting(googleTable); JTableUtil.newInstance(googleTable).showColumnByHeaderValue(defaultShow_googleColumns); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("jPanel2", null, jPanel2, null); } } pack(); this.setSize(642, 405); } catch (Exception e) { e.printStackTrace(); } }
From source file:javazoom.jlgui.player.amp.playlist.ui.PlaylistUI.java
public PlaylistUI() { super();//from w w w .jav a 2s.co m setDoubleBuffered(true); setLayout(new AbsoluteLayout()); config = Config.getInstance(); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { handleMouseClick(e); } }); // DnD support. DropTargetAdapter dnd = new DropTargetAdapter() { public void processDrop(Object data) { processDnD(data); } }; DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, true); }
From source file:com.choicemaker.cm.modelmaker.gui.panels.HoldVsAccuracyPlotPanel.java
private void buildPanel() { XYSeriesCollection dataset = new XYSeriesCollection(); String title = ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.title"); data = new XYSeries(title); dataset.addSeries(data);//from w w w.j a v a 2 s. c om final PlotOrientation orientation = PlotOrientation.VERTICAL; chart = ChartFactory.createXYLineChart(title, ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.cm.accuracy"), ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.holdpercentage"), dataset, orientation, true, true, true); MouseListener tableMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent e) { Point origin = e.getPoint(); JTable src = (JTable) e.getSource(); int row = src.rowAtPoint(origin); int col = src.columnAtPoint(origin); ModelMaker mm = parent.getModelMaker(); if (src == accuracyTable) { if (col < 2) { if (!Float.isNaN(accuracyData[row][2]) && !Float.isNaN(accuracyData[row][3])) mm.setThresholds(new Thresholds(accuracyData[row][2], accuracyData[row][3])); } else if (col == 2) { if (!Float.isNaN(accuracyData[row][2])) mm.setDifferThreshold(accuracyData[row][2]); } else { if (!Float.isNaN(accuracyData[row][3])) mm.setMatchThreshold(accuracyData[row][3]); } } else { if (col < 2) { if (!Float.isNaN(hrData[row][2]) && !Float.isNaN(hrData[row][3])) mm.setThresholds(new Thresholds(hrData[row][2], hrData[row][3])); } else if (col == 2) { if (!Float.isNaN(hrData[row][2])) mm.setDifferThreshold(hrData[row][2]); } else { if (!Float.isNaN(hrData[row][3])) mm.setMatchThreshold(hrData[row][3]); } } } }; chart.setBackgroundPaint(getBackground()); accuracyTable = new AccuracyTable(true, accuracies); accuracyTable.addMouseListener(tableMouseListener); accuracyPanel = getPanel(accuracyTable, ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.table.hrvsacc")); hrTable = new AccuracyTable(false, hrs); hrTable.addMouseListener(tableMouseListener); hrPanel = getPanel(hrTable, ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.table.accvshr")); accuracyTable.setEnabled(false); hrTable.setEnabled(false); }