如何在按钮单击事件时为JTextPane设置背景图像?
问题描述:
我有一个按钮和一个JTextPane.我想在单击按钮(使用ActionListener)时切换JTextPane的背景图像的显示.
在此先感谢您的帮助.
I have a button, and a JTextPane. I want to toggle the displaying of a background image for the JTextPane on click of the button(using ActionListener).
Thanks in advance for the help.
答
-分配一个ActionListener
http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html [^ ]
-在操作上将图像分配给GUI控件
http://docs.oracle.com/javase/tutorial/2d/images/index.html [^ ]
-不要忘记:更新GUI以使图像可见.
-assign an ActionListener
http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html[^]
- on the Action assign an Image to the GUI Control
http://docs.oracle.com/javase/tutorial/2d/images/index.html[^]
- not to forget: update the GUI to get the image visible.