Java Code Examples for javax.swing.AbstractListModel

The following are top voted examples for showing how to use javax.swing.AbstractListModel. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jmt   File: ScrollBivariatePanel.java   Source Code and License 6 votes vote down vote up
public ScrollBivariatePanel(JWatBivariateStatsTable table) {
	tab = table;
	setViewportView(tab);
	ListModel lm = new AbstractListModel() {

		private static final long serialVersionUID = 1L;

		String headers[] = ((JWatBivariateStatsTableModel) tab.getModel()).getNames();

		public int getSize() {
			return headers.length;
		}

		public Object getElementAt(int index) {
			return headers[index];
		}

	};
	JList rowHeader = new JList(lm);
	rowHeader.setBackground(getBackground());
	rowHeader.setFixedCellWidth(100);
	rowHeader.setFixedCellHeight(tab.getRowHeight());
	rowHeader.setCellRenderer(new RowHeaderRenderer(tab));
	setRowHeaderView(rowHeader);
}
 
Example 2
Project: jmt   File: ScrollBivariatePanel.java   Source Code and License 6 votes vote down vote up
public void setNames() {
	ListModel lm = new AbstractListModel() {

		private static final long serialVersionUID = 1L;

		String headers[] = ((JWatBivariateStatsTableModel) tab.getModel()).getNames();

		public int getSize() {
			return headers.length;
		}

		public Object getElementAt(int index) {
			return headers[index];
		}

	};
	JList rowHeader = new JList(lm);
	rowHeader.setBackground(getBackground());
	rowHeader.setFixedCellWidth(100);
	rowHeader.setFixedCellHeight(tab.getRowHeight());
	rowHeader.setCellRenderer(new RowHeaderRenderer(tab));
	setRowHeaderView(rowHeader);
}
 
Example 3
Project: routerapp   File: OpenGraphDialog.java   Source Code and License 6 votes vote down vote up
private JList<String> makeList(final String[][] items, int visibleRows, Container parent) {
	JList<String> list = new JList<>(new AbstractListModel<String>()	{
		/**
		 * 
		 */
		private static final long serialVersionUID = 6510576197401709714L;

		public String getElementAt(int i) {
			return items[i][0];				
		}
		
		public int getSize() {
			return items.length;
		}
	});

	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.setVisibleRowCount(visibleRows);
	parent.add(new JScrollPane(list));
	return list;
}
 
Example 4
Project: QN-ACTR-Release   File: ScrollBivariatePanel.java   Source Code and License 6 votes vote down vote up
public void setNames() {
	ListModel lm = new AbstractListModel() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		String headers[] = ((JWatBivariateStatsTableModel) tab.getModel()).getNames();

		public int getSize() {
			return headers.length;
		}

		public Object getElementAt(int index) {
			return headers[index];
		}
	};
	JList rowHeader = new JList(lm);
	rowHeader.setBackground(getBackground());
	rowHeader.setFixedCellWidth(100);
	rowHeader.setFixedCellHeight(tab.getRowHeight());

	rowHeader.setCellRenderer(new RowHeaderRenderer(tab));

	setRowHeaderView(rowHeader);
}
 
Example 5
Project: ramus   File: SelectBaseFunctionDialog.java   Source Code and License 6 votes vote down vote up
public SelectBaseFunctionDialog(GUIFramework framework) {
    super(framework.getMainFrame(), true);
    setTitle(GlobalResourcesManager.getString("SelectModel"));
    result = null;
    final List<Qualifier> base = IDEF0Plugin.getBaseQualifiers(framework
            .getEngine());
    Collections.sort(base, new Comparator<Qualifier>() {

        private Collator collator = Collator.getInstance();

        @Override
        public int compare(Qualifier o1, Qualifier o2) {
            return collator.compare(o1.getName(), o2.getName());
        }
    });
    list.setModel(new AbstractListModel() {

        @Override
        public Object getElementAt(int index) {
            return base.get(index);
        }

        @Override
        public int getSize() {
            return base.size();
        }

    });

    JScrollPane pane = new JScrollPane();
    pane.setViewportView(list);
    setMainPane(pane);
    pack();
    setMinimumSize(getSize());
    setLocationRelativeTo(null);
    Options.loadOptions(this);
}
 
Example 6
Project: OpenHeosControl   File: QueueObserver.java   Source Code and License 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    final Song[] newQueue = (Song[]) evt.getNewValue();
    
    this.queueList.setModel(new AbstractListModel() {
        @Override
        public int getSize() {
            return  newQueue.length;
        }

        @Override
        public Object getElementAt(int index) {
            return newQueue[index].getTitle();
        }
    });
}
 
Example 7
Project: jeveassets   File: ExportDialog.java   Source Code and License 6 votes vote down vote up
public void setColumns(final List<EnumTableColumn<E>> enumColumns) {
	columns.clear();
	columnIndex.clear();
	columnIndex.addAll(enumColumns);
	for (EnumTableColumn<E> column : enumColumns) {
		columns.put(column.name(), column);
	}
	jColumnSelection.setModel(new AbstractListModel<EnumTableColumn<E>>() {
		@Override
		public int getSize() {
			return columnIndex.size();
		}

		@Override
		public EnumTableColumn<E> getElementAt(int index) {
			return columnIndex.get(index);
		}
	});
}
 
Example 8
Project: swingx   File: AncientSwingTeam.java   Source Code and License 6 votes vote down vote up
/**
 * 
 * Creates and returns a listModel with items of type NamedColor.
 * @return a ListModel containing items of type NamedColor.
 */
public static ListModel createNamedColorListModel() {
    final TableModel wrappee = new AncientSwingTeam();
    ListModel model = new AbstractListModel() {

        public Object getElementAt(int index) {
            return wrappee.getValueAt(index, 2);
        }

        public int getSize() {
            return wrappee.getRowCount();
        }
        
    };
    return model;
}
 
Example 9
Project: swingx   File: RolloverVisualCheck.java   Source Code and License 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    sortableTableModel = new AncientSwingTeam();
    listModel = new AbstractListModel() {

        public int getSize() {
            return sortableTableModel.getRowCount();
        }

        public Object getElementAt(int index) {
            return sortableTableModel.getValueAt(index, 0);
        }
        
    };
    treeTableModel = new FileSystemModel();
    foregroundHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null,
            Color.MAGENTA);
    backgroundHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW,
            null);
 }
 
Example 10
Project: swingx   File: FindIssues.java   Source Code and License 6 votes vote down vote up
/**
 * Issue #236-swingx: backwards match in first row shows not-found-message.
 * Trackdown from Nicfagn - findPanel.doSearch always returns the next startIndex
 * in backwards search that's -1 which is interpreted as "not-found"
 * 
 */
public void testFindPanelFirstRowBackwards() {
    JXList list = new JXList( new AbstractListModel() {
        private String[] data = { "a", "b", "c" };
        public Object getElementAt(int index) {
            return data[ index ];
        }
        public int getSize() {
            return data.length;
        }
    });
    JXFindPanel findPanel = new JXFindPanel(list.getSearchable());
    findPanel.init();
    PatternModel patternModel = findPanel.getPatternModel();
    patternModel.setBackwards(true);
    patternModel.setRawText("a");
    int matchIndex = list.getSearchable().search(patternModel.getPattern(),
            patternModel.getFoundIndex(), patternModel.isBackwards());
    assertEquals("found match", matchIndex, findPanel.doSearch());
}
 
Example 11
Project: stranded-mapviewer   File: ItemFilterPanel.java   Source Code and License 6 votes vote down vote up
public ItemFilterPanel() {
	setLayout(new BorderLayout(0, 0));

	JList<String> list = new JList<String>();
	list.setModel(new AbstractListModel<String>() {
		private static final long serialVersionUID = 1L;
		String[] values = new String[] { "Blah", "Blub", "Dingens" };

		public int getSize() {
			return values.length;
		}

		public String getElementAt(int index) {
			return values[index];
		}
	});
	add(list, BorderLayout.CENTER);
}
 
Example 12
Project: MediaMatrix   File: ColorSchemePanel.java   Source Code and License 6 votes vote down vote up
private void updateColorList(ColorImpressionKnowledge ci) {
    final HSVColor[] colors = ci.getColors();
    final DefaultListModel<Color> colorListModel = new DefaultListModel<Color>();
    for (int i = 0; i < colors.length; i++) {
        colorListModel.addElement(colors[i]);
    }
    colorList.setModel(colorListModel);

    final String[] words = ci.getWords();
    csList.setCellRenderer(new ImpressionWordListCellRenderer(ci, 14f));
    csList.setModel(new AbstractListModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public int getSize() {
            return words.length;
        }

        @Override
        public String getElementAt(int index) {
            return words[index];
        }
    });
}
 
Example 13
Project: ashantivirus   File: VirusDisplay.java   Source Code and License 6 votes vote down vote up
@Override
public void run() 
{
    while(Scanner.status)
    {
        list.setModel(new AbstractListModel() {

        @Override
        public int getSize() {
            return Loading.viruslist.size();
        }

        @Override
        public Object getElementAt(int index) {
            return Loading.viruslist.get(index);
        }
    });
    }
}
 
Example 14
Project: snap-desktop   File: ColorSelectionTest.java   Source Code and License 6 votes vote down vote up
@Override
protected JComponent createColorPicker() {
    List<ColorItem> colors = getColorItems();
    JList<ColorItem> view = new JList<>(new AbstractListModel<ColorItem>() {
        @Override
        public int getSize() {
            return colors.size();
        }

        @Override
        public ColorItem getElementAt(int index) {
            return colors.get(index);
        }
    });
    view.setCellRenderer(new ColorItemListCellRenderer());
    view.addListSelectionListener(e -> {
        setSelectedColor(view.getSelectedValue().color);
    });
    return new JScrollPane(view);
}
 
Example 15
Project: snap-desktop   File: NamesAssociationDialog.java   Source Code and License 6 votes vote down vote up
private JComponent createCenterList() {
    centerNames = new JList<>(new AbstractListModel<String>() {
        @Override
        public int getSize() {
            return nameProvider.getCenterNames().length;
        }

        @Override
        public String getElementAt(int index) {
            return nameProvider.getCenterNames()[index];
        }
    });
    centerNames.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    centerNames.addListSelectionListener(new CenterListSelectionListener(centerNames));
    centerNames.setEnabled(false);
    final JScrollPane scrollPane = new JScrollPane(centerNames);
    scrollPane.setPreferredSize(new Dimension(160, 200));
    return scrollPane;
}
 
Example 16
Project: snap-desktop   File: NamesAssociationDialog.java   Source Code and License 6 votes vote down vote up
private JComponent createRightList() {
    rightNames = new JList<>(new AbstractListModel<String>() {

        @Override
        public int getSize() {
            return nameProvider.getRightNames().length;
        }

        @Override
        public String getElementAt(int index) {
            return nameProvider.getRightNames()[index];
        }
    });
    rightNames.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    rightNames.addListSelectionListener(new RightListSelectionListener(rightNames));
    rightNames.setEnabled(false);
    final JScrollPane scrollPane = new JScrollPane(rightNames);
    scrollPane.setPreferredSize(new Dimension(160, 200));
    return scrollPane;
}
 
Example 17
Project: MediaMatrix   File: ColorSchemePanel.java   Source Code and License 6 votes vote down vote up
private void updateColorList(ColorImpressionKnowledge ci) {
    final HSVColor[] colors = ci.getColors();
    final DefaultListModel<Color> colorListModel = new DefaultListModel<Color>();
    for (int i = 0; i < colors.length; i++) {
        colorListModel.addElement(colors[i]);
    }
    colorList.setModel(colorListModel);

    final String[] words = ci.getWords();
    csList.setCellRenderer(new ImpressionWordListCellRenderer(ci, 14f));
    csList.setModel(new AbstractListModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public int getSize() {
            return words.length;
        }

        @Override
        public String getElementAt(int index) {
            return words[index];
        }
    });
}
 
Example 18
Project: LSystems   File: LSystemsUI.java   Source Code and License 6 votes vote down vote up
private void execute(AST ast)
{
    this.engine.setAST( ast );
    engine.run();

    final List<String> vars = new ArrayList<>();
    for ( Entry<Symbol, MyObject> entry : engine.getVariables().getAll().entrySet() ) {
    	vars.add( entry.getKey().getAbsoluteName().toString()+" => "+entry.getValue().toString() );
    }

    variablesList.setModel( new AbstractListModel<String>() {

        @Override
        public int getSize()
        {
            return vars.size();
        }

        @Override
        public String getElementAt(int index)
        {
            return vars.get(index);
        }
    });
}
 
Example 19
Project: sofd_swing   File: JGridList.java   Source Code and License 6 votes vote down vote up
public JGridList() {
    setLayout(new BorderLayout());
    cellsContainer = new JPanel();
    this.add(cellsContainer, BorderLayout.CENTER);
    setTransferHandler(new DefaultTransferHandler(this));
    setShowScrollbar(true);
    reInitEmptyUI();
    copyUiStateToSubComponents();
    enableEvents(AWTEvent.MOUSE_EVENT_MASK|AWTEvent.MOUSE_MOTION_EVENT_MASK);
    setupUiInteractions();
    setSelectionModel(createSelectionModel());
    setComponentFactory(new DefaultGridListComponentFactory());
    setModel(new AbstractListModel() {
                public int getSize() { return 2; }
                public Object getElementAt(int i) { return i==0?"no":"model"; }
            });
}
 
Example 20
Project: jalita   File: ListWidget.java   Source Code and License 6 votes vote down vote up
/** Sets the ListModel, which supplies the data for the list */
public void setListModel(ListModel model) {
	if (model == null) {
		this.model = new AbstractListModel() {

			public int getSize() {
				return 0;
			}


			public Object getElementAt(int i) {
				return "Keine Daten";
			}
		};

	}
	else {
		this.model = model;
	}

	selectedRow = (int)Math.ceil(getHeight() / 2f);
	selectedIndex = 0;
	setCursor(getPositionLine() + selectedRow - 1, getPositionColumn());
	setDirty(true);
}
 
Example 21
Project: YADBA   File: MainCalendar.java   Source Code and License 6 votes vote down vote up
private JList<String> createRowHeader() {
	ListModel<String> listModel = new AbstractListModel<String>() {
		/**  */
		private static final long serialVersionUID = 1L;

		public int getSize() {
			return rowHeaderValues.size() / 2;
		}

		public String getElementAt(int index) {
			return CalendarUtil.getHourMinuteString(rowHeaderValues
					.get(index * 2));
		}

	};
	JList<String> rowHeader = new JList<String>(listModel);
	rowHeader.setFixedCellWidth(fixedRowHeaderWidth);
	rowHeader.setFixedCellHeight((fixedRowHeight + fixedRowMargin) * 2);
	rowHeader.setCellRenderer(new RowHeaderRenderer(new JTable()));
	return rowHeader;
}
 
Example 22
Project: incubator-netbeans   File: IdentifierPickerPanel.java   Source Code and License 5 votes vote down vote up
private void initList() {
    listMime.setModel(new AbstractListModel() {
        @Override
        public int getSize() {
            return availableMimes.size();
        }

        @Override
        public Object getElementAt(int index) {
            return availableMimes.get(index).getDisplayName();
        }
    });
}
 
Example 23
Project: incubator-netbeans   File: SelectionList.java   Source Code and License 5 votes vote down vote up
public void setItems( List<? extends ListItem> items ) {
    final List<? extends ListItem> listItems = Collections.unmodifiableList( items );
    setItems( new AbstractListModel<ListItem>() {

        @Override
        public int getSize() {
            return listItems.size();
        }

        @Override
        public ListItem getElementAt( int index ) {
            return listItems.get( index );
        }
    });
}
 
Example 24
Project: QN-ACTR-Release   File: ScrollBivariatePanel.java   Source Code and License 5 votes vote down vote up
public ScrollBivariatePanel(JWatBivariateStatsTable table) {
	tab = table;
	setViewportView(tab);
	ListModel lm = new AbstractListModel() {
		/**
		* 
		*/
		private static final long serialVersionUID = 1L;
		String headers[] = ((JWatBivariateStatsTableModel) tab.getModel()).getNames();

		public int getSize() {
			return headers.length;
		}

		public Object getElementAt(int index) {
			return headers[index];
		}
	};
	JList rowHeader = new JList(lm);
	rowHeader.setBackground(getBackground());
	rowHeader.setFixedCellWidth(100);
	rowHeader.setFixedCellHeight(tab.getRowHeight());

	rowHeader.setCellRenderer(new RowHeaderRenderer(tab));

	setRowHeaderView(rowHeader);
}
 
Example 25
Project: SimBionic   File: SB_Autocomplete.java   Source Code and License 5 votes vote down vote up
/**
 * updates the glass panel label with the given text 
 * @param text - html formated text indicating the completions and the current selected
 *    completions.
 */
public void setText(String text){
 list.removeAll();
 
 if (text == null || text.length() == 0) {
    completionList.setVisible(false);
    completionList.validate();
 }
 else {
   final String[] textList = text.split("<BR>\n");
   if (textList.length > 0 ) {
      list.setModel(new AbstractListModel() {
         @Override
         public int getSize() {
            return textList.length;
         }

         @Override
         public Object getElementAt(int index) {
            return textList[index]; 
         }
      });

     adjustPaneSize();  
   }
 }
}
 
Example 26
Project: SimBionic   File: SB_GlassPane.java   Source Code and License 5 votes vote down vote up
/**
 * updates the glass panel label with the given text 
 * @param text - html formated text indicating the completions and the current selected
 *    completions.
 */
public void setText(String text){
	list.removeAll();

	if (text == null || text.length() == 0) {
		completionList.setVisible(false);
		completionList.validate();
	}
	else {
		final String[] textList = text.split("<BR>\n");
		if (textList.length > 0 ) {
			list.setModel(new AbstractListModel<String>() {
				@Override
				public int getSize() {
					return textList.length;
				}

				@Override
				public String getElementAt(int index) {
					return textList[index]; 
				}
			});

			adjustPaneSize();  
		}
	}
}
 
Example 27
Project: LewisOmniscientDebugger   File: Debugger.java   Source Code and License 5 votes vote down vote up
public JScrollPane createJL(AbstractListModel listData,
        ListSelectionListener sl, boolean doubleClick) {
    JList list;
    if (doubleClick)
        list = new DoubleClickJList(listData);
    else
        list = new JList(listData);

    list.setFont(new Font(FONT, Font.PLAIN, FONT_SIZE));
    list.addListSelectionListener(sl);
    list.setBorder(BorderFactory.createLineBorder(Color.black));
    JScrollPane sp = new JScrollPane(list);
    // sp.getViewport().add(list);
    return sp;
}
 
Example 28
Project: swingx   File: HighlighterClientVisualCheck.java   Source Code and License 5 votes vote down vote up
/**
 * @param tableModel2
 * @param i
 * @return
 */
private ListModel createListModel(final JXTable tableModel, final int i) {
    ListModel listModel = new AbstractListModel(){

        @Override
        public Object getElementAt(int index) {
            return tableModel.getValueAt(index, i);
        }

        @Override
        public int getSize() {
            return tableModel.getRowCount();
        }};
    return listModel ;
}
 
Example 29
Project: swingx   File: RendererVisualCheck.java   Source Code and License 5 votes vote down vote up
/**
 * Check disabled appearance.
 *
 */
public void interactiveListDisabledIconRenderer() {
    final TableModel model = createTableModelWithDefaultTypes();
    // 
    ListModel listModel = new AbstractListModel() {

        @Override
        public Object getElementAt(int index) {
            if (index == 0) {
                return "dummy";
            }
            return model.getValueAt(index - 1, 4);
        }

        @Override
        public int getSize() {
            return model.getRowCount() + 1;
        }
        
    };
    final JList standard = new JList(listModel);
    final JList enhanced = new JList(listModel);
    enhanced.setCellRenderer(new DefaultListRenderer());

    AbstractAction action = new AbstractAction("toggle disabled") {

        @Override
        public void actionPerformed(ActionEvent e) {
            standard.setEnabled(!standard.isEnabled());
            enhanced.setEnabled(!enhanced.isEnabled());
        }
        
    };
    JXFrame frame = wrapWithScrollingInFrame(standard, enhanced, "Disabled - compare renderers: default <--> enhanced");
    addAction(frame, action);
    frame.setVisible(true);
}
 
Example 30
Project: jeddict   File: WorkSpaceTrashDialog.java   Source Code and License 5 votes vote down vote up
private AbstractListModel<WorkSpace> getWorkSpaceModel() {
    return new AbstractListModel<WorkSpace>() {
        @Override
        public int getSize() {
            return workSpaces.size();
        }

        @Override
        public WorkSpace getElementAt(int i) {
            return workSpaces.get(i);
        }
    };
}
 
Example 31
Project: ashantivirus   File: SelectRemovable.java   Source Code and License 5 votes vote down vote up
void findRemovable(String tp)
{
    boolean exit=true;
    FileSystemView fsv = FileSystemView.getFileSystemView();
    File[] f = File.listRoots();
    for(File s:f)
    {
        if(fsv.getSystemTypeDescription(s).contains(tp))
        {
            //System.out.println(s+""+fsv.getSystemDisplayName(s));
            removableArray.add(fsv.getSystemDisplayName(s));
            removablePath.add(s.toString());
            exit = false;
        }
    }
    if(exit)
    {
        JOptionPane.showMessageDialog(this, "Not Removable Media Found!!!");
        System.exit(0);
    }
    list.setModel(new AbstractListModel() 
    {

        @Override
        public int getSize() {
            return removableArray.size();
        }

        @Override
        public Object getElementAt(int index) {
            return removableArray.get(index);
        }
    });
}
 
Example 32
Project: KinoSim   File: MovieListGui.java   Source Code and License 5 votes vote down vote up
public JComponent createUi() {
	final ListModel<Movie> model = new AbstractListModel<Movie>() {
		private static final long serialVersionUID = 1L;

		@Override
		public int getSize() {
			return movies.size();
		}

		@Override
		public Movie getElementAt(final int index) {
			return movies.get(index);
		}
	};
	final JList<Movie> list = new JList<>(model);
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.setDragEnabled(true);
	list.setTransferHandler(new MovieDragFromListTransferHandler());
	list.setCellRenderer(this);
	list.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(final MouseEvent e) {
			if (e.getClickCount() == 2) {
				final Movie selectedMovie = list.getSelectedValue();
				if (selectedMovie != null) {
					final RatingGui ratingUi = new RatingGui(selectedMovie.getRating());
					WindowUtil.show(ratingUi.createUi(), "Rating of " + selectedMovie.getTitle(), null);
				}
			}
		}
	});

	return new JScrollPane(list);
}
 
Example 33
Project: sofd_swing   File: JGridList.java   Source Code and License 5 votes vote down vote up
public JGridList(final Object[] listData)
{
    this (
        new AbstractListModel() {
            public int getSize() { return listData.length; }
            public Object getElementAt(int i) { return listData[i]; }
        }
    );
}
 
Example 34
Project: viskit   File: ImageListViewBaseImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Called if a the cells of this viewer need to be refreshed. Normally
 * called internally by subclasses if they determine the need to refresh the cells,
 * but may also be called explicitly from the outside.
 * <p>
 * Uses the same special casing hack as {@link #refreshCellForIndex(int) }.
 */
@Override
public void refreshCells() {
    if (getModel() instanceof AbstractListModel) {
        AbstractListModel alm = (AbstractListModel) getModel();
        Misc.callMethod(alm, "fireContentsChanged", alm, 0, alm.getSize() - 1);
    } else {
        System.err.println("JImageListView#refreshCells(): don't know how to refresh. Override me!");
    }
}
 
Example 35
Project: jalita   File: ListWidget.java   Source Code and License 5 votes vote down vote up
/** Creates a new ListWidget-Object */
public ListWidget(BasicForm owner, int posLine, int posColumn, int width, int rows, final Vector listData, boolean withPositionCursor) {
	this(owner, posLine, posColumn, width, rows, new AbstractListModel() {

		public int getSize() {
			return listData.size();
		}


		public Object getElementAt(int i) {
			return listData.elementAt(i);
		}
	}, withPositionCursor);
}
 
Example 36
Project: jalita   File: ListWidget.java   Source Code and License 5 votes vote down vote up
/** Sets the ListModel, which supplies the data for the list */
public void setListModel(final Vector listData) {
	setListModel(new AbstractListModel() {

		public int getSize() {
			return listData.size();
		}


		public Object getElementAt(int i) {
			return listData.elementAt(i);
		}
	});
}
 
Example 37
Project: jalita   File: MenuWidget.java   Source Code and License 5 votes vote down vote up
/** Creates a new ListWidget-Object */
public MenuWidget(BasicForm owner, int posLine, int posColumn, int width, int rows, final Vector listData, boolean withPositionCursor) {
	this(owner, posLine, posColumn, width, rows, new AbstractListModel() {

		public int getSize() {
			return listData.size();
		}


		public Object getElementAt(int i) {
			return listData.elementAt(i);
		}
	}, withPositionCursor);
}
 
Example 38
Project: incubator-netbeans   File: AddTableDlg.java   Source Code and License 4 votes vote down vote up
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {//GEN-BEGIN:initComponents

    java.awt.GridBagConstraints gridBagConstraints;

    _mainPanel = new JPanel();
    _tableScrollPane = new JScrollPane();
    _tableJList = new JList();

    setLayout(new java.awt.GridBagLayout());

    _mainPanel.setLayout(new java.awt.GridBagLayout());

    // Set the model to be the array that was passed to it
    _tableJList.setModel(new AbstractListModel() {
        public int getSize() { return _tableList.length; }
        public Object getElementAt(int i) { return _tableList[i]; }
    });
    _tableJList.getAccessibleContext().
        setAccessibleName(NbBundle.getMessage(AddTableDlg.class, "TABLE_LIST_a11yName"));
    _tableJList.getAccessibleContext().
        setAccessibleDescription(NbBundle.getMessage(AddTableDlg.class, "TABLE_LIST_a11yDescription"));
    tableListLabel = new JLabel();
    tableListLabel.setText(NbBundle.getMessage(AddTableDlg.class, "TABLE_LIST_label"));
    tableListLabel.setLabelFor(_tableJList);
    _tableScrollPane.setViewportView(_tableJList);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    _mainPanel.add(_tableScrollPane, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 10);
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;

    add(_mainPanel, gridBagConstraints);


}
 
Example 39
Project: Java_event_Bank   File: HistoryViewer.java   Source Code and License 4 votes vote down vote up
/**
 * Create the frame.
 */
public HistoryViewer(String[] transactions) {
    this.transactions = transactions;

    int screenPositionX = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - 210;
    int screenPositionY = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 - 290;
    setTitle("Bank Simulator");
    setResizable(false);
    setSize(419, 584);
    setLocation(screenPositionX, screenPositionY);
    setDefaultCloseOperation(HIDE_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setBackground(new Color(255, 255, 255));
    getContentPane().add(panel, BorderLayout.CENTER);
    panel.setLayout(null);

    JLabel lblBankSimulator = new JLabel("Bank Simulator");
    lblBankSimulator.setHorizontalAlignment(SwingConstants.CENTER);
    lblBankSimulator.setFont(new Font("Century Gothic", Font.BOLD, 36));
    lblBankSimulator.setForeground(new Color(0, 204, 153));
    lblBankSimulator.setBounds(79, 56, 265, 51);
    panel.add(lblBankSimulator);

    JLabel lblUsername = new JLabel("Reacent Transactions");
    lblUsername.setHorizontalAlignment(SwingConstants.CENTER);
    lblUsername.setForeground(new Color(0, 204, 153));
    lblUsername.setFont(new Font("Century Gothic", Font.BOLD, 21));
    lblUsername.setBounds(79, 133, 265, 45);
    panel.add(lblUsername);

    JList list = new JList();
    list.setFont(new Font("Tahoma", Font.BOLD, 13));
    list.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 204, 102)));
    list.setModel(new AbstractListModel() {

        public int getSize() {
            return transactions.length;
        }

        public Object getElementAt(int index) {
            return transactions[index];
        }
    });
    list.setForeground(new Color(0, 204, 102));
    list.setBounds(79, 214, 265, 279);
    panel.add(list);


}
 
Example 40
Project: LewisOmniscientDebugger   File: Debugger.java   Source Code and License 4 votes vote down vote up
public JScrollPane createJL(AbstractListModel listData,
        ListSelectionListener sl) {
    return (createJL(listData, sl, false));
}