Example usage for com.jgoodies.binding.adapter BasicComponentFactory createList

List of usage examples for com.jgoodies.binding.adapter BasicComponentFactory createList

Introduction

In this page you can find the example usage for com.jgoodies.binding.adapter BasicComponentFactory createList.

Prototype

public static <E> JList createList(SelectionInList<E> selectionInList) 

Source Link

Document

Creates and returns a JList for the given SelectionInList.

If the selectionInList's selection holder is a ComponentValueModel it is synchronized with the visible and enabled state of the returned list.

Usage

From source file:ch.fork.AdHocRailway.ui.locomotives.configuration.LocomotiveConfigurationDialog.java

License:Open Source License

private void initComponents() {
    locomotiveGroups = new ArrayListModel<LocomotiveGroup>();

    locomotiveGroupModel = new SelectionInList<LocomotiveGroup>((ListModel<LocomotiveGroup>) locomotiveGroups);

    locomotiveGroupList = BasicComponentFactory.createList(locomotiveGroupModel);
    locomotiveGroupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    locomotiveGroupList.setCellRenderer(new LocomotiveGroupListCellRenderer());

    groupScrollPane = new JScrollPane(locomotiveGroupList);

    locomotiveGroupConfig = new LocomotiveGroupConfigPanel();

    addGroupButton = new JButton(new AddLocomotiveGroupAction());
    editGroupButton = new JButton(new EditLocomotiveGroupAction());
    removeGroupButton = new JButton(new RemoveLocomotiveGroupAction());
    DefaultTableCellRenderer r = new DefaultTableCellRenderer() {

        Border padding = BorderFactory.createEmptyBorder(10, 10, 10, 10);

        @Override// w  w w.  jav a 2 s .c  o m
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setBorder(padding);
            return this;
        }

    };

    locomotivesTable = new JTable();
    locomotivesTable.setDefaultRenderer(Object.class, r);

    locomotives = new ArrayListModel<Locomotive>();

    locomotiveModel = new SelectionInList<Locomotive>();
    locomotiveModel.setList(locomotives);

    locomotivesTable.setModel(new LocomotiveTableModel(locomotiveModel));
    locomotivesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    locomotivesTable.setRowHeight(50);

    final TableColumn imageColumn = locomotivesTable.getColumnModel().getColumn(1);
    imageColumn.setCellRenderer(new LocomotiveImageTableCellRenderer());

    locomotiveTableScrollPane = new JScrollPane(locomotivesTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    locomotivesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    tca = new TableColumnAdjuster(locomotivesTable, 10);

    addLocomotiveButton = new JButton(new AddLocomotiveAction());
    removeLocomotiveButton = new JButton(new RemoveLocomotiveAction());

    okButton = new JButton("OK", ImageTools.createImageIconFromIconSet("dialog-ok-apply.png"));
    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            okPressed = true;
            setVisible(false);
            locomotiveManager.removeLocomotiveManagerListenerInNextEvent(LocomotiveConfigurationDialog.this);
        }
    });
}

From source file:ch.fork.AdHocRailway.ui.routes.configuration.RoutesConfigurationDialog.java

License:Open Source License

@SuppressWarnings("unchecked")
private void initComponents() {
    routeGroups = new ArrayListModel<RouteGroup>();
    routeGroupModel = new SelectionInList<RouteGroup>((ListModel<?>) routeGroups);

    routeGroupList = BasicComponentFactory.createList(routeGroupModel);
    routeGroupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    routeGroupList.setCellRenderer(new RouteGroupListCellRenderer());

    routeGroupConfig = new RouteGroupConfigPanel();

    addRouteGroupButton = new JButton(new AddRouteGroupAction());
    editGroupButton = new JButton(new EditRouteGroupAction());
    removeRouteGroupButton = new JButton(new RemoveRouteGroupAction());

    routes = new ArrayListModel<Route>();
    routesModel = new SelectionInList<Route>();
    routesModel.setList(routes);/*from   ww  w .  j a v  a 2  s . c  om*/
    routesList = new JList<Object>();
    routesList.setModel(routesModel);
    routesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    routesList.setCellRenderer(new RouteListCellRenderer());

    addRouteButton = new JButton(new AddRouteAction());
    duplicateRouteButton = new JButton(new DuplicateRouteAction());
    removeRouteButton = new JButton(new RemoveRouteAction());

    okButton = new JButton("OK", ImageTools.createImageIconFromIconSet("dialog-ok-apply.png"));
    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            okPressed = true;
            setVisible(false);
            routeManager.removeRouteManagerListenerInNextEvent(RoutesConfigurationDialog.this);
        }

    });
}