Search in sources :

Example 1 with BasicListUI

use of javax.swing.plaf.basic.BasicListUI in project gephi by gephi.

the class PartitionPanel method computeListSize.

public static void computeListSize(final JList list) {
    if (list.getUI() instanceof BasicListUI) {
        final BasicListUI ui = (BasicListUI) list.getUI();
        try {
            final Method method = BasicListUI.class.getDeclaredMethod("updateLayoutState");
            method.setAccessible(true);
            method.invoke(ui);
            list.revalidate();
            list.repaint();
        } catch (final SecurityException e) {
            e.printStackTrace();
        } catch (final NoSuchMethodException e) {
            e.printStackTrace();
        } catch (final IllegalArgumentException e) {
            e.printStackTrace();
        } catch (final IllegalAccessException e) {
            e.printStackTrace();
        } catch (final InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
Also used : BasicListUI(javax.swing.plaf.basic.BasicListUI) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with BasicListUI

use of javax.swing.plaf.basic.BasicListUI in project intellij-community by JetBrains.

the class PaletteItemsComponent method updateUI.

@Override
public void updateUI() {
    setUI(new BasicListUI() {

        MouseListener myListener;

        @Override
        protected void updateLayoutState() {
            super.updateLayoutState();
            Insets insets = list.getInsets();
            int listWidth = list.getWidth() - (insets.left + insets.right);
            if (listWidth >= cellWidth) {
                int columnCount = listWidth / cellWidth;
                cellWidth = (columnCount == 0) ? 1 : listWidth / columnCount;
            }
        }

        @Override
        protected void installListeners() {
            addMouseListener(myListener = new MouseAdapter() {

                @Override
                public void mousePressed(MouseEvent e) {
                    myBeforeClickSelectedRow = list.getSelectedIndex();
                }
            });
            super.installListeners();
        }

        @Override
        protected void uninstallListeners() {
            if (myListener != null) {
                removeMouseListener(myListener);
            }
            super.uninstallListeners();
        }
    });
    invalidate();
}
Also used : MouseListener(java.awt.event.MouseListener) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) BasicListUI(javax.swing.plaf.basic.BasicListUI)

Aggregations

BasicListUI (javax.swing.plaf.basic.BasicListUI)2 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1