public void paint() {
JFrame f ;
JPanel p = new JPanel();
JLabel label;
JLabel field;
try {
label = new JLabel();
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
Image img = ImageIO.read(new File("C:\\xxx.gif"));
ImageIcon icon = new ImageIcon(img);
label.setIcon(icon);
label.setVisible(true);
p.add(label,gridBagConstraints);
} catch (IOException ie) {
ie.printStackTrace();
} field = new JLabel();
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
field.setText("abc");
field.setVisible(true);
p.add(field,gridBagConstraints);
p.setVisible(true);
f = new JFrame();
f.setSize(new Dimension(556,347));
f.setResizable(false);
f.setVisible(true);
f.getContentPane().add(p);
}
JFrame f ;
JPanel p = new JPanel();
JLabel label;
JLabel field;
try {
label = new JLabel();
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
Image img = ImageIO.read(new File("C:\\xxx.gif"));
ImageIcon icon = new ImageIcon(img);
label.setIcon(icon);
label.setVisible(true);
p.add(label,gridBagConstraints);
} catch (IOException ie) {
ie.printStackTrace();
} field = new JLabel();
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
field.setText("abc");
field.setVisible(true);
p.add(field,gridBagConstraints);
p.setVisible(true);
f = new JFrame();
f.setSize(new Dimension(556,347));
f.setResizable(false);
f.setVisible(true);
f.getContentPane().add(p);
}
解决方案 »
- 模拟实现 DOS 一些命令 比如dir ab*则 显示ab开头的文件 怎么做
- 贴图时用哪种方法速度最快?
- 我找到windows installer可是启动不了,按启动后提示:本地计算机的的windows installer服务启动后又停止了.一些服务自动停止,如果它们没有什么可做的.例如:性能日志和敬报的服务.
- 高分求教(80分)有关SAX解析XML的问题。
- JPasswordField的问题
- 我的classpath路径前加有‘.'怎么还是不能在当前目录下编译?
- 关于线程调度
- 一个很难解决的问题,大家来看看
- 求救,关于一个简单的APPLET的问题!
- 谁能给我提供一些RMI的资料,或者网址(最好是国内的,国外的我这里上不去),多谢多谢
- JAVA中如何调用VC的OCX?
- 怎么将数据写入一个xml文档??
main函数在哪里?