From e22fb7982228ae52bafb95f6094b2891cf7d5b07 Mon Sep 17 00:00:00 2001 From: junichi11 Date: Tue, 5 Sep 2017 21:28:41 +0900 Subject: [PATCH] Fix a windows problem #17 - Set preferred size for the scrollpane because the height is very low in Windows - Remove the listener correctly because the event does not occur --- .../encoding/ui/EncodingStatusLineElementProvider.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/com/junichi11/netbeans/modules/encoding/ui/EncodingStatusLineElementProvider.java b/src/com/junichi11/netbeans/modules/encoding/ui/EncodingStatusLineElementProvider.java index a502f61..d455bb5 100644 --- a/src/com/junichi11/netbeans/modules/encoding/ui/EncodingStatusLineElementProvider.java +++ b/src/com/junichi11/netbeans/modules/encoding/ui/EncodingStatusLineElementProvider.java @@ -83,6 +83,7 @@ import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; import org.openide.util.lookup.ServiceProvider; +import org.openide.windows.WindowManager; /** * @@ -113,6 +114,11 @@ public void mouseClicked(MouseEvent e) { final JList encodingList = new JList<>(encodingListModel); final JScrollPane encodingScrollPane = new JScrollPane(encodingList); + // #17 set preferred size + int preferredWidth = encodingScrollPane.getPreferredSize().width; + int preferredHeight = WindowManager.getDefault().getMainWindow().getSize().height / 3; + encodingScrollPane.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); + FileObject fileObject = getfocusedFileObject(); if (fileObject == null) { return; @@ -140,7 +146,9 @@ public void eventDispatched(AWTEvent event) { if (source != encodingScrollPane.getVerticalScrollBar()) { popup.hide(); Toolkit.getDefaultToolkit().removeAWTEventListener(this); - encodingList.removeListSelectionListener(encodingListSelectionListener); + if (source != encodingList) { + encodingList.removeListSelectionListener(encodingListSelectionListener); + } } } }