(1) JFrame.setIconImage(Image),从这个JFrame弹出来的Dialog有同样的Icon
解决方案 »
- UDP DatagramPacket同时不间断向路由上一层2台主机发包,其中一台只收到一次数据。
- 请教高手两个题目
- 求基于FTP简单服务器端(Java编写)的程序源码
- 如何从sqlserver中取出存入得图片啊!!!
- 一个关于JAVA实现计数器方面的问题!
- 请教jdk1.5无法正常安装????
- 请教各位大哥,这个问题怎么解决?
- 请问一下:有没有专门可以编写applet的可视化编辑器啊
- 初学java,兄弟们,帮我看一段代码?
- finalize()方法与System.runFinalization()方法有什么区别
- 请问 学java的数据库编程,有什么书比较好?
- Buy IBMWebsphere and Weblogic??
You can't... at least not directly.
The dialog may not have a title bar in some windowing environments...atleast that has been the given rationale behind the lack of such a feature Starting JDK 1.1.7 a resizable dialog will inherit the icon of the owner frame. Owner frame is the one passed in the Dialog's CTOR. If you want to allow a different icon for your dialog from that of your main application frame then you could always create a dummy frame, set the icon on it using the frame.setIconImage(Image); and pass it in the Dialog's CTOR. The dummy frame is never shown. This has implications in term of - Modality of the Dialog
Automatic showing/hiding of Dialog when your main application frame is shown/hidden. You can always get around it by listeneing to ComponentEvents on the application frame and showing and hiding the dialog apropriately.
Answer You can use the DIRECTORIES_ONLY option for the setFileSelectionModel method of JFileChooser. For example:
import javax.swing.JFileChooser;public class ChooseDir {
public static void main(String[] args) {
JFileChooser jfc = new JFileChooser ();
jfc.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY);
System.out.println (jfc.showDialog (null, null));
System.out.println (jfc.getSelectedFile ());
}
}