java简单的图形代码,java图形界面代码

求一个简单的java代码:(图形界面)

import java.awt.Color;

武侯网站建设公司创新互联,武侯网站设计制作,有大型网站制作公司丰富经验。已为武侯上千余家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的武侯做网站的公司定做!

import java.awt.Dimension;

import java.awt.Toolkit;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JDialog;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class vv extends JDialog {

private static final long serialVersionUID = 1L;

private JLabel l_Id = new JLabel("登陆账户", JLabel.CENTER);

private JLabel l_pw = new JLabel("登陆密码", JLabel.CENTER);

private JTextField t_Id = new JTextField(10);

private JPasswordField t_pw = new JPasswordField(10);

private JButton btnLogin;

private JButton btnClose;

public vv() {

super();

setResizable(false);

getContentPane().setBackground(new Color(225, 225, 225));

getContentPane().setLayout(null);

initialize();

}

protected void initialize() {

setTitle("系统登录");

l_Id.setBounds(48, 43, 53, 25);

t_Id.setBounds(110, 43, 150, 25);

l_pw.setBounds(48, 93, 53, 25);

t_pw.setBounds(110, 93, 150, 25);

getContentPane().add(l_Id);

getContentPane().add(l_pw);

getContentPane().add(t_Id);

getContentPane().add(t_pw);

btnLogin = new JButton();

btnLogin.setText("登 录");

btnLogin.setBounds(70, 142, 85, 28);

btnLogin.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

addBtnLoginActionListener();

}

});

getContentPane().add(btnLogin);

btnClose = new JButton();

btnClose.setText("关 闭");

btnClose.setBounds(175, 142, 85, 28);

btnClose.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

dispose();

System.exit(-1);

}

});

getContentPane().add(btnClose);

}

private void addBtnLoginActionListener() {

String user = t_Id.getText();

String password = new String(t_pw.getPassword());

if (user.equals("")) {

JOptionPane.showMessageDialog(this, "帐号不可为空", "Caution",

JOptionPane.WARNING_MESSAGE);

return;

}

if (password.equals("")) {

JOptionPane.showMessageDialog(this, "密码不可为空", "Caution",

JOptionPane.WARNING_MESSAGE);

return;

}

String sql = "select * FROM login WHERE id = '" + user + "' and pw = '"

+ password + "'";

boolean success = false;

// TODO:数据校验 success = executeQuery(sql);

if (success) {

// TODO: 如果数据校验成功 显示主界面 并关闭登录界面

JOptionPane.showMessageDialog(this, "成功登录", "提示",

JOptionPane.INFORMATION_MESSAGE);

this.dispose();

} else {

JOptionPane.showMessageDialog(this, "帐号或密码错误!", "警告",

JOptionPane.WARNING_MESSAGE);

t_pw.requestFocus(); // 密码框选中

}

}

public Dimension getPreferredSize() {

return new Dimension(320, 170);

}

public void show() {

Toolkit tk = Toolkit.getDefaultToolkit();

Dimension screen = tk.getScreenSize();

Dimension d = getSize();

this.setLocation((screen.width - d.width) / 2,

(screen.height - d.height) / 2);

// 输入密码后回车相当于点击了登录按钮

getRootPane().setDefaultButton(btnLogin);

t_pw.requestFocus();

setDefaultCloseOperation(DISPOSE_ON_CLOSE);

setSize(300, 220);

super.show();

}

public static void main(String[] args) {

vv loginFrame = new vv();

loginFrame.setVisible(true);

}

}

希望对你有帮助

java图形代码(新手)

麻烦把题目描述完整点啊!

intLetterCount这个数组是已经从大到小排好序的字母出现次数吧?

第一个for循环错的离谱,改成这样

if(intLetterCount.length0){

for(int i=0; iintLetterCount[0];i++){

for(int j=0; jintLetterCount.length; j++){

if (intLetterCount[j]=intLetterCount[0]-i) {

System.out.print(" "+"*");

}else {

continue;

}

}

System.out.println("");

}

}

求一个最简单的在JAVA上画图形的代码。

import java.awt.*;

class MyFrame extends Frame{

MyPanel p = new MyPanel();

public MyFrame(){

this.add(p);

this.setSize(300,300);

//省略了关闭窗口的代码

this.setVisible(true);

}

public static void main(String[] args){

new MyFrame();

}

class MyPanel extends Panel

{

public void paint(Graphics g){

g.drawLine(0,0,300,300);

}

}

}


当前标题:java简单的图形代码,java图形界面代码
浏览路径:http://hbruida.cn/article/hosops.html