jpopupmenu

Adding JPopupMenu to the TrayIcon

吃可爱长大的小学妹 提交于 2020-01-21 02:54:05
问题 I want to add JPopupMenu to the task bar as a TrayIcon ( i.e systemTray.add(trayIcon) ) but I haven't found a way to do so.From the docs the constructor of TrayIcon looks like : public TrayIcon(Image image, String tooltip, PopupMenu popup) Is there any way I can do this ? 回答1: This is a known problem. There is a bug report, which contains the outline of a workaround. I've adapted that below: // Build your popup menu final JPopupMenu trayPopup = new JPopupMenu(); // I'm using actions, there

How do I make a JPopupMenu appear when any one of 3 JButtons is clicked, right-clicked, or dragged upon?

微笑、不失礼 提交于 2020-01-15 11:59:05
问题 I am trying to make a set of navigation buttons for a file browser. I want it so that if the user clicks the dedicated history button, a JPopupMenu appears. However, I also want that exact same menu to appear when the user right-clicks or drags the cursor down the back or forward button. How can I make that exact same JPopupMenu (not a copy, but the same exact one) appear for multiple GUI components for different gestures? So far I've tried the following: histButton.addMouseListener(new

Open JPopupMenu from opened JComboBox

◇◆丶佛笑我妖孽 提交于 2020-01-11 10:34:25
问题 I'd like to change OOTB behaviour of combobox, to freeze it after right mouse button click (detecting which button was clicked is easy, so that's not the point) and open JPopupMenu istead of choosing that entry. So - how to disable choosing entry on given condition and use custom behaviour then? I tried to start by adding mouse listeners to all combobox components, but without success - nothing changed import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseAdapter

How can i make a JPopupMenu transparent?

微笑、不失礼 提交于 2020-01-11 08:58:09
问题 I'd like to customize the look of JPopupMenu so i made a custom class extending the JPopupMenu class on i overrode the paintComponent method as i would do for any component i need to customize. public class CustomPopupMenu extends JPopupMenu { @Override public paintComponent(Graphics g) { //custom draw } } The only problem i have right know is that i'm not able to make the JPopupMenu transparent. I though setOpaque(false) would be enough, i was wrong. How can i make a JPopupMenu transparent?

JPopupMenu not showing on the screen?

不想你离开。 提交于 2020-01-06 14:03:00
问题 So for my school project I am creating a Class Diagram maker. I am 95% done with it and all I need is to make the Jpopup menu appear. In the core I have 3 files. The ApplicationModel which extends the JFrame, ClassDiagram which extends the JPanel and ClassModel which makes the Rectangles (in the picture) appear. The core of the rendering is on Rectangle objects and the text inside the middle and bottom rectangles are surrounded by another invisible rectangle, which is right-clickable. This is

JPopupMenu Behavior

五迷三道 提交于 2020-01-02 10:00:10
问题 I prepared a small test case below. My problem is when i right click on the window. JPopupMenu show up but if i click anywhere outside the JWindow menu does not disappear. I have to click somewhere on the window to get rid of it which is not the expected behavior. EDIT: after reading akf's answer i switched to JFrame, when frame is in focus and pop up menu is showing it disappears when you click on another window. but if the window does not have focus and you click somewhere menu does not

MouseListener is giving problems with show() method

∥☆過路亽.° 提交于 2019-12-24 07:18:15
问题 I want to display a small context menu when a user right clicks a table row in my application. My plan was to use a custom made MouseListener for this that calls the show() method. Here is my code: import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JTable; import javax.swing.SwingUtilities; class

Update JPopupMenu height while visible

风流意气都作罢 提交于 2019-12-24 05:35:28
问题 I have a popup menu in my application that I want to replace with a customized one so that it matches the look & feel of the rest of the application. Essentially, instead of having the normal menu items in the popup, I want reuse a component that already exist elsewhere in the application that lets you navigate through a hierarchy of items in a "paging" way instead of with sub-menus. So if you click on an item in the list that contains children then the next page will be displayed replacing

JPopupMenu display under Canvas

家住魔仙堡 提交于 2019-12-23 10:55:47
问题 I have a Canvas, some text fields and a context menu. When I start the application and right click on the canvas a popup menu shows. But when I write something inside the text field than I right click on the canvas, the popup will shows behind the canvas. Any idea how to fix that ? 回答1: JPopupMenu.setDefaultLightWeightPopupEnabled( false ); solved the issue. 回答2: 1) Canvas is AWT Component , and is Heavyweight type of Components 2) JPopupMenu is Swing JComponent and is Lightweight type of

Get XY position from caret position in JTextArea

为君一笑 提交于 2019-12-22 10:44:17
问题 I'm trying to make an editor which have ability show pop up (JPopupMenu) each time users type any letter. Maybe, to imagine how my editor works its like any compiler, such as NetBeans when we type dot, the function appear. I have learned JPopupMenu from here. JPopupMenu needs XY position. My idea is to get XY position from JTextArea's caret position. My question is: Is there possible to get XY position from caret position (text cursor) in JTextArea or other JTextComponent? Or maybe is there