您好,我正在尝试将图像作为元素符号点类型放置在 JOptionPane 中。 JOptionPane 中显示的内容我已放在对象数组中。但它只是不获取图像。它显示了我的文件名... 有什么想法吗?
public void popups(){
ImageIcon bullet = new ImageIcon("imgs/bullet.png");
Object[] instr = {+bullet+ "text "};
JOptionPane.showMessageDialog(null, instr, "Instrucciones", 1);
}
编辑:
StringBuilder html = new StringBuilder();
html.append("<html><ul> list-style-image: url ('imgs/bullet.png')</ul>"
+ "<ul>"
+ "<li>TEXT"
+ "<li>TEXT"
+ "</ul></html>");
JOptionPane.showMessageDialog(null, html, "Instrucciones", 1);
最佳答案
提供指定图像的样式。
ul {
list-style-image: url('/image/gJmeJ.png');
}
然后是这样的效果:
<ul>
<li>This is a list point.
<li>This is a 2nd list point.
</ul>
这是:
注意:该图像是使用基于 Swing 的 JLabel
生成的。 Swing 对 CSS 的支持相当有限/不完整,所以最好总是检查一下。
关于java - 如何在 Java 中将图像放入 Object[] 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49205664/