Java 类javax.swing.JList 实例源码
项目:Cognizant-Intelligent-Test-Scripter
文件:JSList.java
public ListPanel(FilterModel fltrmodel, Function<T, String> mapper) {
setLayout(new java.awt.BorderLayout());
JScrollPane sp = new javax.swing.JScrollPane();
list = new JList();
list.setModel(fltrmodel);
list.setCellRenderer(new CheckBoxListRenderer(mapper));
sp.setViewportView(list);
add(sp, BorderLayout.CENTER);
list.setSelectionModel(new MultiSelectionModel(this::onSelect));
list.addKeyListener(onDelete());
list.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ctrl A"), "SelectAll");
list.getActionMap().put("SelectAll", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ae) {
list.setSelectionInterval(0, list.getModel().getSize() - 1);
}
});
}
项目:DocIT
文件:DeptView.java
public DeptView(Controller controller) {
this.controller = controller;
frame = new JFrame();
namePanel = new JPanel(new GridLayout(1, 2, 0, 0));
managerPanel = new JPanel(new GridLayout(1, 2, 66, 0));
employeePanel = new JPanel(new GridLayout(1, 2, 30, 0));
subDeptPanel = new JPanel(new GridLayout(1, 2, 20, 0));
salaryPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 0));
buttonPanel = new JPanel(new GridLayout(1, 3, 20, 0));
subDeptLabel = new JLabel();
salaryLabel = new JLabel();
cutButton = new JButton();
saveButton = new JButton();
okButton = new JButton();
cancelButton = new JButton();
nameField = new JTextField();
managerButton = new JButton();
employeeListModel = new DefaultListModel();
subDeptListModel = new DefaultListModel();
employeeList = new JList(employeeListModel);
subDeptList = new JList(subDeptListModel);
init();
}
项目:java-swing-template
文件:IconListCellRenderer.java
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value != null) {
setText(value.toString());
ImageIcon imageIcon = new javax.swing.ImageIcon(getClass().getResource("/app/resources/" + icon_resource));
setIcon(imageIcon);
}
setForeground(list.getForeground());
setBackground(list.getBackground());
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
}
return this;
}
项目:incubator-netbeans
文件:ActionMappings.java
@Override
public Component getListCellRendererComponent(JList list, Object value,
int arg2, boolean arg3,
boolean arg4) {
Component supers = super.getListCellRendererComponent(list, value, arg2, arg3, arg4);
if (supers instanceof JLabel && value instanceof MappingWrapper) {
MappingWrapper wr = (MappingWrapper)value;
JLabel lbl = (JLabel)supers;
if (wr.isUserDefined()) {
lbl.setFont(lbl.getFont().deriveFont(Font.BOLD));
} else {
lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
}
}
return supers;
}
项目:ripme
文件:QueueMenuMouseListener.java
@Override
public void mouseClicked(MouseEvent e) {
if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
if (!(e.getSource() instanceof JList)) {
return;
}
queueList = (JList) e.getSource();
queueListModel = (DefaultListModel) queueList.getModel();
queueList.requestFocus();
int nx = e.getX();
if (nx > 500) {
nx = nx - popup.getSize().width;
}
popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
}
}
项目:VISNode
文件:ProcessBrowser.java
/**
* Creates the process list
*
* @return JComponent
*/
private JComponent buildList() {
list = new JList<>();
list.setCellRenderer(new CellRenderer(list.getCellRenderer()));
list.setTransferHandler(new ProcessTransferHandler());
list.setDragEnabled(true);
list.setDropMode(DropMode.ON_OR_INSERT);
list.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.getClickCount() % 2 == 0) {
ProcessInformationPane.showDialog(list.getSelectedValue());
}
}
});
return ScrollFactory.pane(list).create();
}
项目:marathonv5
文件:ListTransferHandler.java
protected void cleanup(JComponent c, boolean remove) {
if (remove && indices != null) {
JList source = (JList) c;
DefaultListModel model = (DefaultListModel) source.getModel();
// If we are moving items around in the same list, we
// need to adjust the indices accordingly, since those
// after the insertion point have moved.
if (addCount > 0) {
for (int i = 0; i < indices.length; i++) {
if (indices[i] > addIndex) {
indices[i] += addCount;
}
}
}
for (int i = indices.length - 1; i >= 0; i--) {
model.remove(indices[i]);
}
}
indices = null;
addCount = 0;
addIndex = -1;
}
项目:incubator-netbeans
文件:TaskPanel.java
private void enableComponents (Component comp, boolean enable) {
if (comp instanceof Container) {
for (Component subComp : ((Container) comp).getComponents()) {
enableComponents(subComp, enable);
}
}
if ((comp instanceof JComboBox)
|| ((comp instanceof JTextComponent) && ((JTextComponent) comp).isEditable())
|| (comp instanceof AbstractButton) || (comp instanceof JList)) {
if (enable) {
Boolean b = enableMap.get(comp);
if (b != null) {
comp.setEnabled(b);
}
} else {
enableMap.put(comp, comp.isEnabled());
comp.setEnabled(false);
}
}
}
项目:FreeCol
文件:EndTurnDialog.java
/**
* {@inheritDoc}
*/
@Override
public Component getListCellRendererComponent(JList<? extends UnitWrapper> list,
UnitWrapper value,
int index,
boolean isSelected,
boolean cellHasFocus) {
imageLabel.setIcon(new ImageIcon(
getImageLibrary().getSmallerUnitImage(value.unit)));
nameLabel.setText(value.name);
locationLabel.setText(value.location);
JPanel panel = (isSelected) ? selectedPanel : itemPanel;
panel.removeAll();
panel.add(imageLabel, "center, width 40!, height 40!");
panel.add(nameLabel, "split 2, flowy");
panel.add(locationLabel);
return panel;
}
项目:rapidminer
文件:PlotterPanel.java
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
String s = value.toString();
setText(s);
Icon icon = plotter.getIcon(index);
if (icon != null) {
setIcon(icon);
}
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setEnabled(list.isEnabled());
setFont(list.getFont());
setOpaque(true);
return this;
}
项目:SER316-Ingolstadt
文件:StickerDialog.java
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
/*
* if (isSelected) { setBackground(list.getSelectionBackground());
* setForeground(list.getSelectionForeground());
*/
if(index==7){
this.setForeground(Color.WHITE);
}
else setForeground(list.getForeground());
if ((index > -1) && (index < colors.length))
setBackground(colors[index]);
else
setBackground(list.getBackground());
//}
setText(value.toString());
return this;
}
项目:incubator-netbeans
文件:MultiDiffPanelController.java
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
String tooltip = null;
if (value instanceof Revision) {
Revision rev = (Revision) value;
value = rev.toString(true);
tooltip = rev.getFullMessage();
if (tooltip != null) {
tooltip = tooltip.replace("\r\n", "\n").replace("\n", "<br>"); //NOI18N
StringBuilder sb = new StringBuilder("<html><p>"); //NOI18N
sb.append(tooltip).append("</p></html>"); //NOI18N
tooltip = sb.toString();
}
} else if (value instanceof String) {
value = "<html><i>" + value + "</i></html>"; //NOI18N
tooltip = Bundle.MSG_Revision_Select_Tooltip();
}
Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (comp instanceof JComponent) {
((JComponent) comp).setToolTipText(tooltip);
}
return comp;
}
项目:incubator-netbeans
文件:DashboardTransferHandler.java
@Override
protected Transferable createTransferable(JComponent c) {
if (c instanceof JList) {
JList list = (JList) c;
Object[] values = list.getSelectedValues();
if (values == null || values.length == 0) {
return null;
}
List<TaskNode> nodes = new ArrayList<TaskNode>(values.length);
for (int i = 0; i < values.length; i++) {
Object val = values[i];
if (val instanceof TaskNode) {
nodes.add((TaskNode) val);
} else {
return null;
}
}
return new DashboardTransferable(nodes.toArray(new TaskNode[nodes.size()]));
}
return null;
}
项目:SER316-Munich
文件:StickerDialog.java
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
/*
* if (isSelected) { setBackground(list.getSelectionBackground());
* setForeground(list.getSelectionForeground());
*/
if(index==7){
this.setForeground(Color.WHITE);
}
else setForeground(list.getForeground());
if ((index > -1) && (index < colors.length))
setBackground(colors[index]);
else
setBackground(list.getBackground());
//}
setText(value.toString());
return this;
}
项目:Equella
文件:BaseEntityWithAddDialogTool.java
public PluginDialog()
{
listModel = new DefaultListModel<>();
list = new JList<>();
list.setModel(listModel);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
for( String name : plugins.keySet() )
{
listModel.addElement(name);
}
setLayout(new BorderLayout());
add(new JScrollPane(list));
}
项目:incubator-netbeans
文件:PlatformComponentFactory.java
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
// #93658: GTK needs name to render cell renderer "natively"
setName("ComboBox.listRenderer"); // NOI18N
NbPlatform plaf = ((NbPlatform) value);
// NetBeans.org modules doesn't have platform at all --> null
String text = plaf == null ? "" : plaf.getLabel(); // NOI18N
setText(text);
if ( isSelected ) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
}
else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
if (plaf != null && !plaf.isValid()) {
setForeground(INVALID_PLAF_COLOR);
}
return this;
}
项目:incubator-netbeans
文件:FoldOptionsPanel.java
/**
* Creates new form FoldOptionsPanel
*/
public FoldOptionsPanel(FoldOptionsController ctrl) {
this.ctrl = ctrl;
initComponents();
langSelect.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof String[]) {
value = ((String[])value)[1];
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
}
});
langSelect.addActionListener(this);
contentPreview.addActionListener(this);
foldedSummary.addActionListener(this);
// preferences should be set as a reaction to index selection
}
项目:rapidminer
文件:ConfirmLicensesDialog.java
public void valueChanged(ListSelectionEvent e) {
if(!e.getValueIsAdjusting()) {
JList source = (JList)e.getSource();
if(!source.isSelectionEmpty()) {
if(!this.otherList.isSelectionEmpty()) {
this.otherList.clearSelection();
}
PackageDescriptor desc = null;
Object selectedValue = source.getSelectedValue();
desc = (PackageDescriptor)selectedValue;
try {
ConfirmLicensesDialog.this.setLicensePaneContent(desc);
} catch (Exception var6) {
SwingTools.showSimpleErrorMessage("error_installing_update", var6, new Object[]{var6.getMessage()});
}
}
}
}
项目:incubator-netbeans
文件:ProfilingPointsDisplayer.java
private void initComponents() {
setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
listModel = new DefaultListModel();
list = new JList(listModel);
list.getAccessibleContext().setAccessibleName(Bundle.ProfilingPointsDisplayer_ListAccessName());
list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setVisibleRowCount(6);
list.setCellRenderer(org.netbeans.modules.profiler.ppoints.Utils.getPresenterListRenderer());
JScrollPane listScroll = new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
listScroll.setPreferredSize(new Dimension(405, listScroll.getPreferredSize().height));
add(listScroll, BorderLayout.CENTER);
}
项目:incubator-netbeans
文件:Utils.java
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
renderer.setBorder(BorderFactory.createEmptyBorder(1, 7, 1, 5));
if (value instanceof ProfilingPoint) {
boolean enabled = ((ProfilingPoint) value).isEnabled();
renderer.setText(((ProfilingPoint) value).getName());
renderer.setIcon(enabled ? ((ProfilingPoint) value).getFactory().getIcon() :
((ProfilingPoint) value).getFactory().getDisabledIcon());
renderer.setEnabled(enabled);
} else if (value instanceof ProfilingPointFactory) {
renderer.setText(((ProfilingPointFactory) value).getType());
renderer.setIcon(((ProfilingPointFactory) value).getIcon());
renderer.setEnabled(true);
} else {
renderer.setIcon(null);
renderer.setEnabled(true);
}
return renderer;
}
项目:scorekeeperfrontend
文件:TimeEntry.java
@Override
public Component getListCellRendererComponent(JList<?> l, Object o, int i, boolean is, boolean f)
{
super.getListCellRendererComponent(l, o, i, is, f);
if (o instanceof Run)
{
Run r = (Run)o;
setText(NF.format(r.getRaw()));
}
else if (o instanceof Double)
{
setText(NF.format((Double)o));
}
setFont(font);
return this;
}
项目:incubator-netbeans
文件:OnSaveTabPanel.java
public OnSaveTabPanel() {
initComponents();
// Languages combobox renderer
cboLanguage.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if ((value instanceof String) && selector != null) {
value = selector.getLanguageName((String) value);
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
commonPanel = new OnSaveCommonPanel();
commonPanelContainer.setLayout(new BorderLayout());
commonPanelContainer.add(commonPanel, BorderLayout.WEST);
customPanelContainer.setLayout(new BorderLayout());
}
项目:incubator-netbeans
文件:JShellOptions2.java
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel l = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
MemberDescription md = (MemberDescription)value;
if (md == null) {
return l;
}
l.setIcon(ElementIcons.getElementIcon(md.kind, md.modifiers));
String n = md.name;
if (md.kind == ElementKind.METHOD) {
n += "()"; // NOI18N
}
l.setText(md.name);
return l;
}
项目:JavaGraph
文件:FindReplaceDialog.java
/** Returns the combo box for the label in the given type graph. */
private JComboBox<TypeLabel> getLabelComboBox(TypeGraph typeGraph) {
final JComboBox<TypeLabel> result = new JComboBox<>();
result.setFocusable(false);
result.setRenderer(new DefaultListCellRenderer() {
@SuppressWarnings("rawtypes")
@Override
public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
if (value instanceof TypeLabel) {
value = HTMLConverter.HTML_TAG.on(((TypeLabel) value).toLine().toHTMLString());
}
return super.getListCellRendererComponent(list,
value,
index,
isSelected,
cellHasFocus);
}
});
for (TypeLabel label : sortLabels(typeGraph.getLabels())) {
if (!label.isDataType() && label != TypeLabel.NODE) {
result.addItem(label);
}
}
return result;
}
项目:MaxSim
文件:CheckRenderer.java
public CheckRenderer(final JList<Object> list) {
this.list = list;
list.addMouseListener(
new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int index = list.locationToIndex(e.getPoint());
Point p2 = list.indexToLocation(index);
Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
if (r.contains(e.getPoint())) {
CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
node.setSelected(!node.isSelected());
list.repaint();
e.consume();
}
}
});
this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
startBackground = this.getBackground();
}
项目:FreeCol
文件:NegotiationDialog.java
/**
* {@inheritDoc}
*/
@Override
public Component getListCellRendererComponent(JList<? extends Unit> list,
Unit value, int index, boolean isSelected,
boolean cellHasFocus) {
setText((value == null) ? "" : value.getDescription());
return this;
}
项目:jmt
文件:AllStationsParametersPanel.java
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = new JLabel(stationData.getStationName(value), JMTImageLoader.loadImage(stationData.getStationType(value) + "Combo"),
SwingConstants.LEFT);
label.setOpaque(true);
label.setBorder(new LineBorder(cellHasFocus ? Color.BLUE : Color.WHITE));
label.setBackground(isSelected ? list.getSelectionBackground() : Color.WHITE);
label.setForeground(isSelected ? list.getSelectionForeground() : Color.BLACK);
label.setFont(isSelected ? label.getFont().deriveFont(Font.BOLD) : label.getFont().deriveFont(Font.ROMAN_BASELINE));
return label;
}
项目:incubator-netbeans
文件:J2EEUtils.java
public static ListCellRenderer getRenderer() {
return new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof DBColumnInfo) {
DBColumnInfo column = (DBColumnInfo)value;
String label = column.getName() + (column.isValid() ? "" : " (" + column.getMessage() + ")"); // NOI18N
setText(label);
setEnabled(column.isValid());
}
return this;
}
};
}
项目:incubator-netbeans
文件:AddPropertyPanel.java
@Override
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
// #89393: GTK needs name to render cell renderer "natively"
setName("ComboBox.listRenderer"); // NOI18N
if (value != null) {
String text = (String) value;
text = text.substring(text.lastIndexOf('.') + 1);
setText(text);
setIcon(getClassIcon());
} else {
setText(null);
setIcon(getEmptyIcon());
}
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
return this;
}
项目:freecol
文件:FreeColComboBoxRenderer.java
/**
* Returns a {@code ListCellRenderer} for the given
* {@code JList}.
*
* @param list The {@code JList}.
* @param value The list cell.
* @param index The index in the list.
* @param isSelected {@code true} if the given list cell is selected.
* @param hasFocus {@code false} if the given list cell has the focus.
* @return The {@code ListCellRenderer}
*/
@Override
public Component getListCellRendererComponent(JList<? extends T> list,
T value, int index,
boolean isSelected,
boolean hasFocus) {
JLabel c = isSelected ? SELECTED_COMPONENT : NORMAL_COMPONENT;
c.setForeground(list.getForeground());
c.setFont(list.getFont());
setLabelValues(c, value);
return c;
}
项目:MailCopier
文件:ReceiveForm.java
private JScrollPane get_MessagesList() {
if(messagesList == null) {
messagesList = new JList<String>();
messagesList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
messagesList.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent evt) {
int keyCode = evt.getKeyCode();
if(keyCode == KeyEvent.VK_DELETE) {
if(receive_butt.getText().equals(pManager.get_String("pause"))) {
String title = pManager.get_String("warning");
String message = pManager.get_String("receiver_delete_message");
boolean sound = pManager.get_sounds_status();
Notification.show(title, message, sound, Notification.WARNING_MESSAGE);
} else {
int[] indices = messagesList.getSelectedIndices();
mailCopier.deleteMessages(indices);
}
}
}
});
mailCopier.addCopierListener(new CopierAdapter() {
public void messagesListChanged(LinkedList<String> messages) {
messagesList.setListData(messages.toArray(new String[messages.size()]));
}
});
}
JScrollPane scroll = new JScrollPane(messagesList);
scroll.setPreferredSize(new Dimension(100, 150));
return scroll;
}
项目:openjdk-jdk10
文件:JListOperator.java
/**
* Maps {@code JList.getSelectedValue()} through queue
*/
public Object getSelectedValue() {
return (runMapping(new MapAction<Object>("getSelectedValue") {
@Override
public Object map() {
return ((JList) getSource()).getSelectedValue();
}
}));
}
项目:incubator-netbeans
文件:ColorEditor.java
/** This is the only method defined by ListCellRenderer. We just
* reconfigure the Jlabel each time we're called.
*/
public Component getListCellRendererComponent (
JList list,
Object value, // value to display
int index, // cell index
boolean isSelected, // is the cell selected
boolean cellHasFocus // the list and the cell have the focus
) {
this.index = index;
selected = isSelected;
hasFocus = cellHasFocus;
getAccessibleContext().setAccessibleName(names[index]);
return this;
}
项目:freecol
文件:UnitType.java
@Override
public int getMinimumIndex(Colony colony, JList<BuildableType> buildQueueList, int UNABLE_TO_BUILD) {
ListModel<BuildableType> buildQueue = buildQueueList.getModel();
if (colony.canBuild(this)) return 0;
for (int index = 0; index < buildQueue.getSize(); index++) {
if (buildQueue.getElementAt(index).hasAbility(Ability.BUILD, this)) return index + 1;
}
return UNABLE_TO_BUILD;
}
项目:VISNode
文件:ProcessBrowser.java
@Override
public Component getListCellRendererComponent(JList<? extends Class<Process>> list, Class<Process> value, int index, boolean isSelected, boolean cellHasFocus) {
ProcessMetadata metadata = processMetadata.get(value);
// Title label
JLabel label = (JLabel) defaultRenderer.getListCellRendererComponent(list, "", index, isSelected, cellHasFocus);
label.setText(metadata.getName());
label.setFont(new Font("Segoe UI", Font.BOLD, 12));
// Description label
JLabel description = new JLabel(metadata.getDescription());
description.setForeground(description.getForeground());
description.setBorder(BorderFactory.createEmptyBorder(1, 10, 3, 3));
description.setFont(new Font("Segoe UI", Font.PLAIN, 10));
if (metadata.getDescription() == null || metadata.getDescription().isEmpty()) {
description.setText("<No description specified>");
description.setForeground(description.getForeground().darker());
}
// Builds the component
JPanel component = new JPanel();
component.setLayout(new BorderLayout());
component.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
if (isSelected) {
component.setBackground(new Color(0xEDEDED));
} else {
if (index % 2 == 0) {
component.setBackground(new Color(0x555555));
}
}
component.add(label);
component.add(description, BorderLayout.SOUTH);
component.setOpaque(true);
component.setForeground(description.getForeground());
return component;
}
项目:incubator-netbeans
文件:SummaryCellRenderer.java
@Override
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
AbstractSummaryView.ShowLessEventsItem item = (AbstractSummaryView.ShowLessEventsItem) value;
id = item.getItemId();
if (linkerSupport.getLinker(ShowLessFilesLink.class, id) == null) {
linkerSupport.add(new ShowLessFilesLink(item.getParent()), id);
}
StringBuilder sb = new StringBuilder("<html><a href=\"expand\">"); //NOI18N
String label = NbBundle.getMessage(SummaryCellRenderer.class, "MSG_ShowLessFiles"); //NOI18N
if (isSelected) {
Component c = dlcr.getListCellRendererComponent(list, "<html><a href=\"expand\">ACTION_NAME</a>", index, isSelected, cellHasFocus); //NOI18N
sb.append("<font color=\"").append(getColorString(c.getForeground())).append("\">") //NOI18N
.append(label).append("</font>"); //NOI18N
} else if (LINK_COLOR != null) {
sb.append("<font color=\"").append(getColorString(LINK_COLOR)).append("\">") //NOI18N
.append(label).append("</font>"); //NOI18N
} else {
sb.append(label);
}
sb.append("</a></html>"); //NOI18N
comp = dlcr.getListCellRendererComponent(list, sb.toString(), index, isSelected, cellHasFocus);
removeAll();
add(comp);
comp.setMaximumSize(comp.getPreferredSize());
setBackground(comp.getBackground());
return this;
}
项目:incubator-netbeans
文件:RepositorySelectorBuilder.java
@Override
public Component getListCellRendererComponent(JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus)
{
String text;
Image icon = null;
if (value == null) {
text = null;
} else if (value instanceof RepositoryImpl) {
RepositoryImpl repo = (RepositoryImpl) value;
text = repo.getDisplayName();
icon = repo.getIcon();
} else if (value instanceof NewRepositoryInfo) {
String connectorName = ((NewRepositoryInfo) value).connector
.getDisplayName();
text = newConnectionFormat.format(new Object[] {connectorName});
icon = ((NewRepositoryInfo) value).connector.getIcon();
} else {
assert false;
text = "???"; //NOI18N
}
Component r = defaultRenderer.getListCellRendererComponent(list,
text,
index,
isSelected,
cellHasFocus);
if (r instanceof JLabel) {
JLabel label = (JLabel) r;
label.setIcon(new ImageIcon(icon));
}
return r;
}
项目:incubator-netbeans
文件:GenerateCodePanel.java
public Renderer(JList list) {
setFont(list.getFont());
fgColor = list.getForeground();
bgColor = list.getBackground();
bgColorDarker = new Color(Math.abs(bgColor.getRed() - DARKER_COLOR_COMPONENT),
Math.abs(bgColor.getGreen() - DARKER_COLOR_COMPONENT),
Math.abs(bgColor.getBlue() - DARKER_COLOR_COMPONENT));
bgSelectionColor = list.getSelectionBackground();
fgSelectionColor = list.getSelectionForeground();
}
项目:jdk8u-jdk
文件:MultiListUI.java
/**
* Invokes the <code>getCellBounds</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Rectangle getCellBounds(JList a, int b, int c) {
Rectangle returnValue =
((ListUI) (uis.elementAt(0))).getCellBounds(a,b,c);
for (int i = 1; i < uis.size(); i++) {
((ListUI) (uis.elementAt(i))).getCellBounds(a,b,c);
}
return returnValue;
}
项目:OpenJSharp
文件:MultiListUI.java
/**
* Invokes the <code>indexToLocation</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Point indexToLocation(JList a, int b) {
Point returnValue =
((ListUI) (uis.elementAt(0))).indexToLocation(a,b);
for (int i = 1; i < uis.size(); i++) {
((ListUI) (uis.elementAt(i))).indexToLocation(a,b);
}
return returnValue;
}