jpopupmenu

JPopupMenu closes when child popup opens

旧时模样 提交于 2019-11-27 16:13:05
I have a JComboBox (among other components) inside a JPopupMenu. It turns out that whenever I open the combo box's popup (to select an item), the parent JPopupMenu closes. I've been trying to find a way to override this feature, to no avail. Does anyone have any suggestions to prevent closing the parent JPopupMenu? Thanks! that not possible directly, its very hard to override known bug , in other hands Swing doesn't allows two lightwieght popup components in same time import javax.swing.*; import java.awt.event.*; public class Test { public static void main(String[] args) { JFrame frame = new

Make JPopupMenu Display with a Certain Bottom Left Coordinate

不羁岁月 提交于 2019-11-27 07:56:46
问题 Say that I want to make a button in Java in such a way so that when you click on it, a JPopupMenu appears. The relevant code for it appearing is menu.show(button, button.getWidth()/2, button.getHeight()/2); , which makes the JPopupMenu be displayed with its top left corner at the center of the button, as shown below: However, I would like to have it so that instead the bottom left corner is at the center of the button, somewhat like what iTunes does (there is a button underneath the bottom

Open popup(Menu) on task tray icon with left click using java

女生的网名这么多〃 提交于 2019-11-27 07:45:37
问题 I am working on task tray Icon in java, I like to open a popup Menu using left click same popup Menu as I open on right click, and please help me with a quick response. Thanks in advance... here is the code working for right click need to show same popup on left click... don't forget to place any image @ "src/img" folder with name "titleImg.jpg" Just run this... it is a working example but i have to show same popup using left click i have checked the Mouse Listener, it listen the left click

JTable copy and paste using Clipboard and AbstractAction

半城伤御伤魂 提交于 2019-11-26 23:24:45
问题 When I try to paste into a JTable cell using table.setValueAt() , the cell I am pasting in remains blank, but setValueAt() seems to be working. Also, when I try to cut or copy from one cell, the Paste option on my JPopupMenu remains disabled when I want to paste into another cell. I'm not sure why. My code is below. class CopyAction extends AbstractAction { private JTable table; public CopyAction(JTable table) { this.table = table; } @Override public void actionPerformed(ActionEvent e) { int

JTable with JPopupMenu

流过昼夜 提交于 2019-11-26 14:42:31
how can I prevent triggering and showing JPopupMenu only if is Mouse Cursor over selected JTable'Row my question: if is there another way as getBounds from selected row and determine/compare that with Mouse position... my simple sscce demonstrated just un-wanted opposite status, any row could be selected and JPopupMenu is triggered from whole JTable import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class TableCheckBox extends JFrame { private static final long serialVersionUID = 1L; private JTable table; public TableCheckBox() { Object[] columnNames = {"Type",

How do I create a right click context menu in Java Swing?

独自空忆成欢 提交于 2019-11-26 10:15:22
问题 I\'m currently creating a right-click context menu by instantiating a new JMenu on right click and setting its location to that of the mouse\'s position... Is there a better way? 回答1: You are probably manually calling setVisible(true) on the menu. That can cause some nasty buggy behavior in the menu. The show(Component, int x, int x) method handles all of the things you need to happen, (Highlighting things on mouseover and closing the popup when necessary) where using setVisible(true) just

JTable with JPopupMenu

痞子三分冷 提交于 2019-11-26 05:56:40
问题 how can I prevent triggering and showing JPopupMenu only if is Mouse Cursor over selected JTable\'Row my question: if is there another way as getBounds from selected row and determine/compare that with Mouse position... my simple sscce demonstrated just un-wanted opposite status, any row could be selected and JPopupMenu is triggered from whole JTable import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class TableCheckBox extends JFrame { private static final long

JTable design to synchronize with back-end data-structure

只愿长相守 提交于 2019-11-25 23:59:40
问题 I have a JTable which is loaded from a data-structure using table model.The data-structure is of the format NavigableMap<Float,NavigableMap<Float,Boolean>> .An example data is: Table Format: Range f1,v1 f2,v2 f3,v3 f4,v4 12.1-30.2 30,true 32,false 45,true 50,false 30.2-45.6 30,true 32.4,true 45,true 50.1,true The above data format is represented in the DS as DS Format: Key Value 12.1 <<30,true>,<32,false>,<45,true>,<50,false>> 30.2 <<30,true>,<32.4,true>,<45,true>,<50.1,true>> 45.6 null I