package csw;import java.awt.*;
import javax.swing.*;
/**
*
* @author Administrator
*/
public class x extends javax.swing.JFrame {
/** Creates new form x */
public x() {
Toolkit tk =Toolkit.getDefaultToolkit();
Dimension screenSize =tk.getScreenSize();
Image img =tk.getImage("1.gif"); /* 标注1*/
setIconImage(img);
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">
private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("xxxxxxxxxxx");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
/**
* @param arg
* s the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new x().setVisible(true);
}
});
}
// 变量声明 - 不进行修改
// 变量声明结束
}
-------------问题:我是用NEATBEAN作的
1.窗口标题栏的图标显示不了?是不少拉什么?
2.如果在标注1处是 路径 d:\c\cs.gif那么
Image img =tk.getImage("d:\c\cs.gif"); /* 标注1*/
调试会出错~,要如何改?
import javax.swing.*;
/**
*
* @author Administrator
*/
public class x extends javax.swing.JFrame {
/** Creates new form x */
public x() {
Toolkit tk =Toolkit.getDefaultToolkit();
Dimension screenSize =tk.getScreenSize();
Image img =tk.getImage("1.gif"); /* 标注1*/
setIconImage(img);
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">
private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("xxxxxxxxxxx");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
/**
* @param arg
* s the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new x().setVisible(true);
}
});
}
// 变量声明 - 不进行修改
// 变量声明结束
}
-------------问题:我是用NEATBEAN作的
1.窗口标题栏的图标显示不了?是不少拉什么?
2.如果在标注1处是 路径 d:\c\cs.gif那么
Image img =tk.getImage("d:\c\cs.gif"); /* 标注1*/
调试会出错~,要如何改?
setIconImage( Toolkit.getDefaultToolkit().getImage("jhobby.jpg"));
2,至少要这么改"d:\\c\\cs.gif"
Image img =tk.getImage(x.class.getResource("cs.gif"); //cs.gif和类文件x.class同目录