jpopup

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?

Swing persistent popup

随声附和 提交于 2019-12-10 10:14:32
问题 I need to display a swing popup with my custom component. The popup should stay visible, until I hide it myself, but shouldn't get focus. I have a code written by some other developer that does it in the following way: popupMenu = new JPopupMenu(); popupMenu.add(myCustomComponent, BorderLayout.CENTER); popupMenu.setFocusable(false); popupMenu.setVisible(true); popupMenu.show(parentComponent, x, y); This seems to work, but has a bug - when the popup is visible, first mouse click outside the

How can I make combobox's list wider?

空扰寡人 提交于 2019-12-07 05:28:25
问题 import javax.swing.*; public class test { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(120,80); JComboBox cb = new JComboBox(); cb.addItem("A very long combo-box item that doesn't fit no. 1"); cb.addItem("A very long combo-box item that doesn't fit no. 2"); frame.add(cb); frame.validate(); frame.setVisible(true); } } How can I make combo-box items to appear in the way

Swing persistent popup

血红的双手。 提交于 2019-12-05 21:37:56
I need to display a swing popup with my custom component. The popup should stay visible, until I hide it myself, but shouldn't get focus. I have a code written by some other developer that does it in the following way: popupMenu = new JPopupMenu(); popupMenu.add(myCustomComponent, BorderLayout.CENTER); popupMenu.setFocusable(false); popupMenu.setVisible(true); popupMenu.show(parentComponent, x, y); This seems to work, but has a bug - when the popup is visible, first mouse click outside the component is consumed by the popup. So I need to click twice to set focus to another component. How can I

How can I make combobox's list wider?

风格不统一 提交于 2019-12-05 10:59:01
import javax.swing.*; public class test { public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(120,80); JComboBox cb = new JComboBox(); cb.addItem("A very long combo-box item that doesn't fit no. 1"); cb.addItem("A very long combo-box item that doesn't fit no. 2"); frame.add(cb); frame.validate(); frame.setVisible(true); } } How can I make combo-box items to appear in the way that all their text is visible? Now I have something like this: I don't want to change size of combo-box

Adding a vertical separator in PopupMenu, in the task bar

最后都变了- 提交于 2019-12-04 21:42:48
问题 How can I add a vertical separator in the pop up menu of the app in the task bar ? tray = SystemTray.getSystemTray(); openMenuItem = new MenuItem("Open P"); stopKLMenuItem = new MenuItem("Stop"); exitMenuItem = new MenuItem("exit"); menu.add(exitMenuItem); menu.add(stopKLMenuItem); menu.addSeparator(); // adds a horizontal separator menu.add(openMenuItem); trayIcon = new TrayIcon(image,"P",menu); The statement menu.addSeparator() adds a horizontal separator. I also wanted a vertical separator

Popup for JFrame close button

ⅰ亾dé卋堺 提交于 2019-12-04 13:29:58
问题 i am doing some basic Java Swing application (beginner level) . what i have to do is when i press close button on JFrame to colse the window i want a JOptionPane Confirm Dialog instead of straightforward close here is the code JFrame JFrame frame= new JFrame("frame"); frame.setSize(300,300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); frame.pack(); and JOptionPane code goes like this final JOptionPane optionPane = new JOptionPane("Are You sure?",JOptionPane

How can i make a JPopupMenu transparent?

∥☆過路亽.° 提交于 2019-12-01 18:54:17
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? The problem with a popup menu is that it may be realized as a top-level container (Window), and a

JPopupMenu is not displayed on right click

二次信任 提交于 2019-12-01 14:03:12
import java.awt.FlowLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; public class B extends MouseAdapter { JFrame frame = new JFrame(); JPopupMenu popup = new JPopupMenu(); JMenuItem item1 = new JMenuItem("ADD"); JMenuItem item2 = new JMenuItem("DELETE"); public static void main(String arg[]) { new B(); } B() { frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setLayout(new FlowLayout()); frame.addMouseListener(this); popup.add(item1); popup.add(item2); frame.add(popup);