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
相关文档:
认清JavaScript和JAVA全局变量和局部变量的作用域
2010年2月28日 george 发表评论 阅读评论
通过淘宝面试题来认清JavaScript和JAVA全局变量和局部变量的作用域
注意两者是有严重区别的!
var a = 100;
function testResult(){
var b = 2 * a;
var a = 200;
var c = a / 2 ......
废话不多说,直接上题目
接下来就是见证奇迹的时刻:请先不要运行代码,猜一下输出的结果:
1.
public class Test1{
public static void main(String[] args){
System.out.println(2.0 - 1.1);
}
}
2.
public class Test2{
&n ......
package sort;
import java.util.Random;
/**
* 排序测试类
*
* 排序算法的分类如下: 1.插入排序(直接插入排序、折半插入排序、希尔排序); 2.交换排序(冒泡泡排序、快速排 ......
package com.algrothim.sample.plo;
/**
* @author yuan
*这一个判断一个字符串是否为回文的例子。
*里面借助三个重要的数据结构的知识:
*栈,队列,以及引用。
*此程序的原理是:根据栈的后进先出,以及队列的先进先出的原理。
*两个ADT是同步的,如果从栈出来的字符与从队列出来的字符全部一样,
*说明为 ......
起到第一道安全保障作用的”双亲委派类加载模型”
双亲委派方式的类加载,指的是优先从顶层启动类加载器开始,自顶向下的方式加载类的模型(参见第一条类装载器体系结构)。
这种模型的好处是,底层的类装载器装载的类无法与顶层类装载器装载的类相互调用。
哪怕是同包下的类,只要他们不属于同一类装载器, ......