Skip to content

Commit

Permalink
Fix a windows problem #17
Browse files Browse the repository at this point in the history
- Set preferred size for the scrollpane because the height is very low in Windows
- Remove the listener correctly because the event does not occur
  • Loading branch information
junichi11 committed Sep 5, 2017
1 parent 54b96b5 commit e22fb79
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
*
Expand Down Expand Up @@ -113,6 +114,11 @@ public void mouseClicked(MouseEvent e) {
final JList<String> 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;
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit e22fb79

Please sign in to comment.