- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想创建一个包含带有数据和 jCombobox 的项目的列表。我使用这个 listCellRenderer :
public class DeliveryListCellRenderer extends JPanel implements ListCellRenderer{
JLabel[] lbl = new JLabel[2];
JComboBox combo;
public DeliveryListCellRenderer()
{
setLayout(new GridLayout(0,2,15,0));
lbl[0] = new JLabel("",JLabel.RIGHT);
add(lbl[0]);
lbl[1] = new JLabel("",JLabel.LEFT);
add(lbl[1]);
String[] timeZones = {"timeZone 1", "timeZone 2", "timeZone 3", "timeZone 4"};
combo = new JComboBox(timeZones);
combo.setSelectedIndex(1);
add(combo);
}
public Component getListCellRendererComponent(JList list,Object value,
int index,boolean isSelected,boolean cellHasFocus)
{
Delivery delivery = (Delivery)value;
lbl[0].setText("X : "+delivery.getNode().getX());
lbl[1].setText("Y : "+delivery.getNode().getY());
if(isSelected) setBackground(Color.CYAN);
else setBackground(Color.WHITE);
return this;
}
}
当我运行应用程序时,一切都显示正常,但当我单击组合框时没有任何反应。
有人有想法吗?提前致谢。
最佳答案
When I run the application, everything appears ok, but nothing happens when I click on the combobox.
这不是 Renderer
的工作(当我运行应用程序时,一切都显示正常
),必须使用 XxxEditor
基本上这对于 JList
是不可能的,请查看 JTable
关于listCellRenderer 内的 java jcombobox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13357603/
这是我在这里的第一篇文章,如果它太可怕了,请提前道歉...... 我正在尝试使用自定义 ListCellRenderer 将自定义类列表中的项目添加到 JList 中。每个都有各种我想添加到一行的东西
以下 ListCellRenderer 不接收嵌套 ComboBox 上的单击事件。我需要启用某些功能吗? class FilterCellRenderer implements ListCellRe
这是自定义渲染器的代码: private class FacilityElement extends javax.swing.JLabel implements javax.swing.ListCel
我想编写一个自定义 ListCellRenderer。 唯一需要与默认不同的是,它不显示 value.toString() 的返回值,而是显示 value.myOwnCustomMethodThatR
我正在使用 ListCellRenderer 来编辑 JList 中条目的外观。选择它们后(通过单击它们,此代码位于单击事件内),我调用 ListCellRenderer 来更改文本的颜色。如果再次选
我试图仅获取 ArrayList 元素中的第一项以显示在组合框中。有人建议使用 ListCellRenderer 可以帮助我实现这一目标。我已经尝试了很多次,但无法访问必要的 getCourseNum
我正在使用 ListCellRenderer,我需要显示绘制的项目略有不同,这取决于它们是作为下拉列表的一部分还是作为组合框内联的一部分绘制的图片(即非下拉模式下的选定项目)。 使用渲染器的 getL
我正在尝试创建一个包含三个文本区域的 ListCellRenderer。在构造函数中,我创建了一个空容器,设置其布局,为文本区域设置样式并将文本区域添加到容器中。此容器 ID 进一步添加到渲染器组件。
我编写了自己的 ListCellRenderer(下面的代码),它使我的单元格透明。现在,如果我运行它,每次我单击一个列表项时,它都会变得比以前更白。会不会是 JList 总是添加我创建的这个新 JL
要为任意对象自定义 JComboBox 中显示的文本,我知道正确的方法是创建自定义 ListCellRenderer 。但是,我不确定如何以模仿与普通组合框相同的外观和感觉的方式执行此操作。 考虑下面
关于 JavaDoc for javax.swing.ListCellRenderer 中示例代码的快速问题: 我有点惊讶,在示例中,ListCellRenderer由扩展 JLabel 的类实现并且
我想创建一个包含带有数据和 jCombobox 的项目的列表。我使用这个 listCellRenderer : public class DeliveryListCellRenderer extend
今天早些时候我发布了一个问题,并在 MadProgrammer 的指导下使用 ListCellRenderer 来实现所需的结果。我几乎可以正常工作,但它在组合框中显示相同的条目两次,我不知道为什么。
我正在尝试制作一个自定义 JList,它显示任务列表,其中每个任务表示如下 - 类型:由 3 个不同的图标表示,状态由 2 个图标表示,名称为简单的字符串。 我的问题是,首先自定义 CellRende
我试图在 Generic ListCellRenderer 上设置开关组件,但它会抛出内部应用程序错误 - NullPointer 异常。 我尝试过的代码如下。 Form hi = new Form(
我目前正在尝试为 JList 编写自定义 ListCellRenderer。不幸的是,几乎所有示例都简单地将 DefaultListCellRenderer 用作 JLabel 并完成它;但是,我需要
我有这门课: @SuppressWarnings("serial") private class DataCellRenderer extends JLabel implements ListC
我有一个 class GridPanel extends JPanel , 带有静态内部类 ToolSelectComboBox extends JComboBox ,它又具有两个静态内部类 Tool
这是我的代码:- public class MyRender extends JPanel implements ListCellRenderer { ImageIcon on_img;
我有一个 JList ,为此我创建了自定义 ListCellRenderer .此列表包含在 JScrollPane 中. 为避免在运行时 调整框架大小,我希望滚动 Pane 始终具有适合显示的大小
我是一名优秀的程序员,十分优秀!