所以,我面临的问题是我想采用JButton的图像模型,而是将其用作图像.我之前没有使用过实施图标,所以我决定做一些搜索.但是,我找不到任何可以理解这里发生的事情.
我试过以下代码:
JButton button = new JButton("Text");
JLabel buttonIcon = new JLabel(button.getIcon());
Run Code Online (Sandbox Code Playgroud)
但是,当我去展示JLabel时,什么都没有出现.这种互动是错的吗?
我也很满意将JButton的模型保存为图像格式,并将其导入.
任何帮助将不胜感激!