Java GUI JLabel 和 JPanel 图片 和组件重叠问题
package ui;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class MainUi extends JPanel implements ActionListener
{
protected JTextField id, psw;
protected JButton ok, register, exit;
protected JLabel idl, pswl, imgl;
protected static JLabel imgpanel;
protected ImageIcon image;
public MainUi()
{
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
image = new ImageIcon("D://java/PZ/image/bg.jpg");
imgpanel = new JLabel(image);
id = new JTextField(60);
id.setActionCommand("ID");
idl = new JLabel("ID :");
idl.setLabelFor(id);
psw = new JTextField(60);
psw.setActionCommand("password");
pswl = new JLabel("PassWord: ");
pswl.setLabelFor(psw);
ok = new JButton("OK");
register = new JButton("REGISTER");
exit = new JButton("EXIT");
JPanel login = new JPanel();
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
login.setLayout(gridbag);
// imgl.setBounds(0, 0, imgIcon.getIconWidth(), imgIcon.getIconHeight());
// login.setOpaque(false);
JLabel[] labels = { idl, pswl };
JTextField[] textFields = { id, psw };
addLabelTextRows(labels, textFields, gridbag, login);
c.gridw
相关文档:
在论坛里看到好多人问自己的 数据库 为什么连接不上的类似的问题
我答了好多 主要的错误原因是 : 导入 驱动程序的jar文件后 没编译 就运行
希望刚学Java数据库的同学注意了! ......
认清JavaScript和JAVA全局变量和局部变量的作用域
2010年2月28日 george 发表评论 阅读评论
通过淘宝面试题来认清JavaScript和JAVA全局变量和局部变量的作用域
注意两者是有严重区别的!
var a = 100;
function testResult(){
var b = 2 * a;
var a = 200;
var c = a / 2 ......
新手感悟……
就个人理解,java中分为基本数据类型还有对象。对于基本数据类型。在赋值操作中传递的是值,而不是引用。例如
int a = 10;
int b = a;
int b = 11;
这时,输出a,b可以发现。a = 10 ,b = 11;在b = a这个赋值操作中,是将a对应的值传递给了b。而不是将b的引用指向了a的 ......
网上的这篇文章,写得很实在,故贴了出来......
本人做软件开发大概有6年多了,从事java开发大概4年多,一直在上海.现在我在网上总是看到大家在讨论什么架构比什么架构好,什么技术比什么技术强. 对这个我想谈谈我的几点看法.
第一 ......