java窗口里加标签_Java登陆界面设计添加一个字符提示标签

这篇博客主要展示了如何在Java Swing GUI中创建一个登录界面,并在其中添加一个显示提示信息的JLabel。博主遇到问题,尽管代码没有错误,但提示标签无法正常显示。博客内容包括界面组件的实例化、布局设置、位置调整以及窗体属性配置。
摘要由CSDN通过智能技术生成

如题privateStringnote="提示信息:";buttomLabel=newJLabel(note);//提示信息标签在底部setLayout(null);//设置为空布局buttomLabel.setBounds(34,350,80,20);只是截取了部分代码没有...

如题

private String note="提示信息:";

buttomLabel =new JLabel(note);//提示信息标签在底部

setLayout(null);//设置为空布局

buttomLabel.setBounds(34,350,80,20);

只是截取了部分代码 没有提示错误 其它组件均可以正常显示 但这个无论走在哪个位置都显示不出来

有大神可以提一下意见吗 下面是全部代码

package com.loginwindow;

import javax.swing.*;

import java.awt.event.*;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JTextField;

public class loginwindow extends JFrame {

private JLabel numLabel,nameLabel,topLabel,buttomLabel;//标签,提示信息

private JTextField numText,nameText;//文本框

private JButton loginButton,exitButton;//登录,登出按钮

private String note="提示信息:";

public loginwindow(){

super("系统登录"); //super 调用系统构造

ImageIcon imgtop=new ImageIcon("res/无标题.png");//res为项目目录中与src并列

topLabel =new JLabel(imgtop);//带图标的JLabel对象放在顶端

buttomLabel =new JLabel(note);//提示信息标签在底部

//登录窗体的中间部分放置以下对象

numLabel =new JLabel("考生学号:");

nameLabel =new JLabel("考生姓名:");

numText =new JTextField(20);

nameText =new JTextField(20);

loginButton =new JButton("登录");

exitButton =new JButton("登出");

setLayout(null);//设置为空布局

add(numLabel);//添加组件

add(nameLabel);

add(numText);

add(nameText);

add(loginButton);

add(exitButton);

add(topLabel);

add(buttomLabel);

//设置组件的长宽高

numLabel.setBounds(130,90,80,20);

nameLabel.setBounds(130,130,80,20);

numText.setBounds(200,90,160,20);

nameText.setBounds(200,130,160,20);

loginButton.setBounds(120,200,100,30);

exitButton.setBounds(260,200,100,30);

topLabel.setBounds(0, 0, 500, 370);

buttomLabel.setBounds(34,350,80,20);

//设置主窗体在屏幕上的位置 长宽高

setBounds(260,200,500,370);

setResizable(false);//主窗体大小不可变

setVisible(true);//可见

setDefaultCloseOperation(this.EXIT_ON_CLOSE);

validate();//刷新主窗体

}

}

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值