java好看界面代碼 javagui界面設(shè)計代碼

如何運(yùn)java制作一個美麗的界面

可以用下面的代碼放在界面所在的構(gòu)造函數(shù)內(nèi),便出現(xiàn)美麗的Nimbus界面風(fēng)格.

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),石家莊企業(yè)網(wǎng)站建設(shè),石家莊品牌網(wǎng)站建設(shè),網(wǎng)站定制,石家莊網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,石家莊網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

至于具體的界面呢.就看你的天分了...

try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");//Nimbus風(fēng)格,新出來的外觀,JDK 6 Update10 版本開始出現(xiàn)

} catch (Exception e) {

}

用java設(shè)計一個簡單的界面設(shè)計,越簡單越好,謝謝

用java設(shè)計一個簡單的界面可以參考如下實(shí)例:

import?javax.swing.JFrame;//框架

import?javax.swing.JPanel;//面板

import?javax.swing.JButton;//按鈕

import?javax.swing.JLabel;//標(biāo)簽

import?javax.swing.JTextField;//文本框

import?java.awt.Font;//字體

import?java.awt.Color;//顏色

import?javax.swing.JPasswordField;//密碼框

import?java.awt.event.ActionListener;//事件監(jiān)聽

import?java.awt.event.ActionEvent;//事件處理

import?javax.swing.JOptionPane;//消息窗口public?class?UserLogIn?extends?JFrame{

public?JPanel?pnluser;

public?JLabel?lbluserLogIn;

public?JLabel?lbluserName;

public?JLabel?lbluserPWD;

public?JTextField?txtName;

public?JPasswordField?pwdPwd;

public?JButton?btnSub;

public?JButton?btnReset;

public?UserLogIn(){

pnluser?=?new?JPanel();

lbluserLogIn?=?new?JLabel();

lbluserName?=?new?JLabel();

lbluserPWD?=?new?JLabel();

txtName?=?new?JTextField();

pwdPwd?=?new?JPasswordField();

btnSub?=?new?JButton();

btnReset?=?new?JButton();

userInit();

}

public?void?userInit(){

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設(shè)置關(guān)閉框架的同時結(jié)束程序

this.setSize(300,200);//設(shè)置框架大小為長300,寬200

this.setResizable(false);//設(shè)置框架不可以改變大小

this.setTitle("用戶登錄");//設(shè)置框架標(biāo)題

this.pnluser.setLayout(null);//設(shè)置面板布局管理

this.pnluser.setBackground(Color.cyan);//設(shè)置面板背景顏色

this.lbluserLogIn.setText("用戶登錄");//設(shè)置標(biāo)簽標(biāo)題

this.lbluserLogIn.setFont(new?Font("宋體",Font.BOLD?|?Font.ITALIC,14));//設(shè)置標(biāo)簽字體

this.lbluserLogIn.setForeground(Color.RED);//設(shè)置標(biāo)簽字體顏色

this.lbluserName.setText("用戶名:");

this.lbluserPWD.setText("密????碼:");

this.btnSub.setText("登錄");

this.btnReset.setText("重置");

this.lbluserLogIn.setBounds(120,15,60,20);//設(shè)置標(biāo)簽x坐標(biāo)120,y坐標(biāo)15,長60,寬20

this.lbluserName.setBounds(50,55,60,20);

this.lbluserPWD.setBounds(50,85,60,25);

this.txtName.setBounds(110,55,120,20);

this.pwdPwd.setBounds(110,85,120,20);

this.btnSub.setBounds(85,120,60,20);

this.btnSub.addActionListener(new?ActionListener()//匿名類實(shí)現(xiàn)ActionListener接口

{

public?void?actionPerformed(ActionEvent?e){

btnsub_ActionEvent(e);

}????

}

);?

this.btnReset.setBounds(155,120,60,20);

this.btnReset.addActionListener(new?ActionListener()//匿名類實(shí)現(xiàn)ActionListener接口

{

public?void?actionPerformed(ActionEvent?e){

btnreset_ActionEvent(e);

}????

}

);???

this.pnluser.add(lbluserLogIn);//加載標(biāo)簽到面板

this.pnluser.add(lbluserName);

this.pnluser.add(lbluserPWD);

this.pnluser.add(txtName);

this.pnluser.add(pwdPwd);

this.pnluser.add(btnSub);

this.pnluser.add(btnReset);

this.add(pnluser);//加載面板到框架

this.setVisible(true);//設(shè)置框架可顯??

}

public?void?btnsub_ActionEvent(ActionEvent?e){

String?name?=?txtName.getText();

String?pwd?=?String.valueOf(pwdPwd.getPassword());

if(name.equals("")){

JOptionPane.showMessageDialog(null,"賬號不能為空","錯誤",JOptionPane.ERROR_MESSAGE);

return;

}else?if?(pwd.equals("")){

JOptionPane.showMessageDialog(null,"密碼不能為空","錯誤",JOptionPane.ERROR_MESSAGE);

return;

}else?if(true){

this.dispose();

}else{

JOptionPane.showMessageDialog(null,"賬號或密碼錯誤","錯誤",JOptionPane.ERROR_MESSAGE);

return;

}

}

public?void?btnreset_ActionEvent(ActionEvent?e){

txtName.setText("");

pwdPwd.setText("");

}

public?static?void?main(String[]?args){

new?UserLogIn();

}

}

java swing怎樣開發(fā)出漂亮的界面

你的java和圖片放在一個目錄,

我都是放在C盤根目錄了,

給你稍微改了一下代碼:

import?java.awt.*;

import?javax.swing.*;

public?class?TestGra?extends?JFrame?{

Container?c?=?getContentPane();

JLabel?lb;

Image?image;

public?TestGra()?{

//?就改這里了

ImageIcon?img?=?new?ImageIcon(System.getProperty("user.dir")?+?"\\1.jpeg");

lb?=?new?JLabel(img);

add(lb,?BorderLayout.CENTER);

setSize(800,?600);

setVisible(true);

setDefaultCloseOperation(EXIT_ON_CLOSE);

}

public?static?void?main(String?as[])?{

new?TestGra();

}

}

分享標(biāo)題:java好看界面代碼 javagui界面設(shè)計代碼
當(dāng)前鏈接:http://muchs.cn/article48/ddipeep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站ChatGPT、微信公眾號、營銷型網(wǎng)站建設(shè)外貿(mào)建站、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司