求大神帮看下java打的页面怎么显示不出来,谢谢
packageyemian1;importjava.awt.Color;importjava.awt.Font;importjava.awt.event.ActionEv...
package yemian1;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Main extends JFrame implements ActionListener{
JFrame ff=new JFrame("白云书店");
JLabel ll=new JLabel("欢迎到白云书店");
JLabel l1 = new JLabel("用户名:");
JLabel l2 = new JLabel("密 码:");
JTextField txt = new JTextField(10);
JPasswordField pasw = new JPasswordField(10);
JButton btn1 = new JButton("管理员");
JButton btn2 = new JButton("游客登录");
public Main(JFrame jFrame) {
// TODO Auto-generated constructor stub
}
public void Ye(){
ff.setLayout(null);
ll.setForeground(Color.white);//字体颜色
ll.setBounds(110,5,400,50);
ll.setFont(new Font("华文行楷", Font.BOLD, 40));
ll.setHorizontalAlignment(JLabel.CENTER);
ff.getContentPane().add(ll);
l1.setForeground(Color.white);
l2.setForeground(Color.white);
l1.setBounds(150,50,200,100);
l2.setBounds(150,100,200,100);
ff.getContentPane().add(l1);
ff.getContentPane().add(l2);
pasw.setEchoChar('*');
txt.setBounds(200,90,200,30);
pasw.setBounds(200,140, 200,30);
ff.getContentPane().add(txt);
ff.getContentPane().add(pasw);
ff.getContentPane().add(btn1);
btn2.setBounds(320, 250,90, 30);
ff.getContentPane().add(btn2);
ImageIcon img = new ImageIcon("11.png");
//要设置的背景图片
JLabel imgLabel = new JLabel(img);
//将背景图放在标签里。
ff.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
//将背景标签添加到jfram的LayeredPane面板里。
imgLabel.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());
// 设置背景标签的位置
((JPanel)ff.getContentPane()).setOpaque(false);
this.setResizable(false);
this.setBounds(600,400,600,400);
this.setVisible(true);
}
public static void main(String[] args){
new Main((new JFrame()));
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getActionCommand()=="管理员")
{
this.login();
}else if(e.getActionCommand()=="游客")
{
//调用登录方法
}
}
private void login() {
// TODO Auto-generated method stub
}
} 展开
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Main extends JFrame implements ActionListener{
JFrame ff=new JFrame("白云书店");
JLabel ll=new JLabel("欢迎到白云书店");
JLabel l1 = new JLabel("用户名:");
JLabel l2 = new JLabel("密 码:");
JTextField txt = new JTextField(10);
JPasswordField pasw = new JPasswordField(10);
JButton btn1 = new JButton("管理员");
JButton btn2 = new JButton("游客登录");
public Main(JFrame jFrame) {
// TODO Auto-generated constructor stub
}
public void Ye(){
ff.setLayout(null);
ll.setForeground(Color.white);//字体颜色
ll.setBounds(110,5,400,50);
ll.setFont(new Font("华文行楷", Font.BOLD, 40));
ll.setHorizontalAlignment(JLabel.CENTER);
ff.getContentPane().add(ll);
l1.setForeground(Color.white);
l2.setForeground(Color.white);
l1.setBounds(150,50,200,100);
l2.setBounds(150,100,200,100);
ff.getContentPane().add(l1);
ff.getContentPane().add(l2);
pasw.setEchoChar('*');
txt.setBounds(200,90,200,30);
pasw.setBounds(200,140, 200,30);
ff.getContentPane().add(txt);
ff.getContentPane().add(pasw);
ff.getContentPane().add(btn1);
btn2.setBounds(320, 250,90, 30);
ff.getContentPane().add(btn2);
ImageIcon img = new ImageIcon("11.png");
//要设置的背景图片
JLabel imgLabel = new JLabel(img);
//将背景图放在标签里。
ff.getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));
//将背景标签添加到jfram的LayeredPane面板里。
imgLabel.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());
// 设置背景标签的位置
((JPanel)ff.getContentPane()).setOpaque(false);
this.setResizable(false);
this.setBounds(600,400,600,400);
this.setVisible(true);
}
public static void main(String[] args){
new Main((new JFrame()));
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getActionCommand()=="管理员")
{
this.login();
}else if(e.getActionCommand()=="游客")
{
//调用登录方法
}
}
private void login() {
// TODO Auto-generated method stub
}
} 展开
1个回答
2017-11-27
展开全部
package yemian1;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Main extends JFrame implements ActionListener {
JLabel ll = new JLabel("欢迎到白云书店");
JLabel l1 = new JLabel("用户名:");
JLabel l2 = new JLabel("密 码:");
JTextField txt = new JTextField(10);
JPasswordField pasw = new JPasswordField(10);
JButton btn1 = new JButton("管理员");
JButton btn2 = new JButton("游客登录");
public Main() {
setTitile("白云书店");
setLayout(null);
ll.setForeground(Color.white); //字体颜色
ll.setBounds(110, 5, 400, 50);
ll.setFont(new Font("华文行楷", Font.BOLD, 40));
ll.setHorizontalAlignment(JLabel.CENTER);
add(ll);
l1.setForeground(Color.white);
l2.setForeground(Color.white);
l1.setBounds(150, 50, 200, 100);
l2.setBounds(150, 100, 200, 100);
add(l1);
add(l2);
pasw.setEchoChar('*');
txt.setBounds(200, 90, 200, 30);
pasw.setBounds(200, 140, 200, 30);
add(txt);
add(pasw);
add(btn1);
btn2.setBounds(320, 250, 90, 30);
add(btn2);
ImageIcon img = new ImageIcon("11.png");
//要设置的背景图片
JLabel imgLabel = new JLabel(img);
//将背景图放在标签里。
add(imgLabel, new Integer(Integer.MIN_VALUE));
//将背景标签添加到jfram的LayeredPane面板里。
imgLabel.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());
// 设置背景标签的位置
((JPanel) getContentPane()).setOpaque(false);
setResizable(false);
setBounds(600, 400, 600, 400);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if ("管理员".equals(cmd)) {
this.login();
} else if ("游客".equals(cmd)) {
//调用登录方法
}
}
private void login() {}
public static void main(String[] args) {
new Main();
}
}
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Main extends JFrame implements ActionListener {
JLabel ll = new JLabel("欢迎到白云书店");
JLabel l1 = new JLabel("用户名:");
JLabel l2 = new JLabel("密 码:");
JTextField txt = new JTextField(10);
JPasswordField pasw = new JPasswordField(10);
JButton btn1 = new JButton("管理员");
JButton btn2 = new JButton("游客登录");
public Main() {
setTitile("白云书店");
setLayout(null);
ll.setForeground(Color.white); //字体颜色
ll.setBounds(110, 5, 400, 50);
ll.setFont(new Font("华文行楷", Font.BOLD, 40));
ll.setHorizontalAlignment(JLabel.CENTER);
add(ll);
l1.setForeground(Color.white);
l2.setForeground(Color.white);
l1.setBounds(150, 50, 200, 100);
l2.setBounds(150, 100, 200, 100);
add(l1);
add(l2);
pasw.setEchoChar('*');
txt.setBounds(200, 90, 200, 30);
pasw.setBounds(200, 140, 200, 30);
add(txt);
add(pasw);
add(btn1);
btn2.setBounds(320, 250, 90, 30);
add(btn2);
ImageIcon img = new ImageIcon("11.png");
//要设置的背景图片
JLabel imgLabel = new JLabel(img);
//将背景图放在标签里。
add(imgLabel, new Integer(Integer.MIN_VALUE));
//将背景标签添加到jfram的LayeredPane面板里。
imgLabel.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());
// 设置背景标签的位置
((JPanel) getContentPane()).setOpaque(false);
setResizable(false);
setBounds(600, 400, 600, 400);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
if ("管理员".equals(cmd)) {
this.login();
} else if ("游客".equals(cmd)) {
//调用登录方法
}
}
private void login() {}
public static void main(String[] args) {
new Main();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询