java窗口设计
Ⅰ java界面设计
我觉得,页面布局什么的,这个不用说了吧。。就是逻辑而已,点击“第一步”,判断有没有输入,如果有输入,判断是不是正整数,如果条件符合,那么第一格显示输入的值,然后第二格,处理下(其实就是for循环String,倒序)然后第三格=第一格+第二格的值;
第二步,同样获得第一步最后一个的和值,然后类似第一步。如下类似
Ⅱ 用java设计简单的windows窗口
我这有个java实现的记事本代码和java实现的计算机,但是这是两个项目 ,而且分别每个项目实现的功能比你的多,要不考给你,你把来个结合下,再把多出来功能的代码删掉?
Ⅲ java中如何设计窗体,让其美化
Java在这方面不算强项!你需要结合其他软件
Ⅳ 用JAVA设计一个窗口
//看看这个程序
//我猜不能判断窗口的最小化,只能判断它是否失去焦点
import java.awt.event.*;
import javax.swing.*;
//定义WindowTest类,继承自JFrame,实现了WindowListener接口
public class WindowTest extends JFrame implements WindowListener
{
//构造方法
public WindowTest()
{
//设置窗体的标题
this.setTitle("窗体事件响应");
//向窗体中添加一个标签作为提示
this.add(new JLabel("当您对窗体进行激活、转为非激活、关闭等动作时,控制台将打印相应的动作描述"));
//注册WindowListener监听器
this.addWindowListener(this);
//设置窗体的位置、大小、可见性及关闭
this.setBounds(200,200,480,150);
this.setVisible(true);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//与第25行功能相同
}
//实现WindowListener接口中的各个方法,不需要的方法也要给出空实现
public void windowActivated(WindowEvent e)
{
System.out.println("1.窗体被激活");
}
public void windowOpened(WindowEvent e){
System.out.println("2.窗口首次变为可见");
}
public void windowDeactivated(WindowEvent e)
{
System.out.println("3.窗体由激活状态变成非激活状态");
}
public void windowClosing(WindowEvent e)
{
System.out.println("4.窗体关闭,Game over");
System.exit(0);//与第19行功能相同
}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public static void main(String[] args)
{
//创建窗体对象
new WindowTest();
}
}
Ⅳ Java程序界面设计
界面方面主要是前端的框架,这样就可以更好的参与这个体系的课程学习哦!
Ⅵ 如何用JAVA设计程序窗口
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FrameTest {
private JFrame jf;
private JButton yellow,blue,green;
private JPanel panel1;
public FrameTest(){
jf = new JFrame("Frame");
yellow = new JButton("yellow");
blue = new JButton("blue");
green = new JButton("green");
panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
jf.add(panel1,BorderLayout.CENTER);
jf.setVisible(true);
jf.setSize(500,600);
jf.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
blue.setForeground(Color.blue);
panel1.add(blue);
blue.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
panel1.setBackground(Color.blue);
}
});
yellow.setForeground(Color.yellow);
panel1.add(yellow);
yellow.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
panel1.setBackground(Color.yellow);
}
});
green.setForeground(Color.green);
panel1.add(green);
green.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
panel1.setBackground(Color.green);
}
});
}
public static void main(String args[]){
FrameTest ft = new FrameTest();
}
}
Ⅶ 如何设计java窗体
这个效果是winXP仿Apple的桌面
两种方法:
1、下载这个主题包,装到winXP上,调用java里的
UIManager.getInstalledLookAndFeels();
获得这个效果。
2、自己重写一个这样的look and fell类。(这个太难!!!!!)
刚刚查了一下
这个应该是javax.swing.plaf中的观感设计方面的。
给你写了个代码作为参考。
改变观感里的参数就可以达到这种效果了。(因为自己不知道到底是那种)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PlafTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
PlafFrame frame = new PlafFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
//A Frae with a button panel for chaing look and fell
class PlafFrame extends JFrame {
public static final int DEFAULT_WIDTH = 300;
public static final int DEFAULT_HEITHT =200;
public PlafFrame(){
setTitle("PlaF Test");
setBounds(350,250,DEFAULT_WIDTH,DEFAULT_HEITHT);
PlafPanel panel = new PlafPanel();
add(panel);
}
}
//A panel with buttons to change the pluggable look and fell
class PlafPanel extends JPanel {
public PlafPanel(){
UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
for(UIManager.LookAndFeelInfo info : infos)
makeButton(info.getName(),info.getClassName());
}
void makeButton(String name,final String plafName){
//add button to panel
JButton button = new JButton(name);
add(button);
//set button action
button.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent event){
//button action :switch to the new look and feel
try{
UIManager.setLookAndFeel(plafName);
SwingUtilities.updateComponentTreeUI(PlafPanel.this);
}
catch(Exception e){e.printStackTrace();}
}
});
}
}
Ⅷ 用java设计一个简单的界面设计,越简单越好,谢谢
用java设计一个简单的界面可以参考如下实例:
importjavax.swing.JFrame;//框架
importjavax.swing.JPanel;//面板
importjavax.swing.JButton;//按钮
importjavax.swing.JLabel;//标签
importjavax.swing.JTextField;//文本框
importjava.awt.Font;//字体
importjava.awt.Color;//颜色
importjavax.swing.JPasswordField;//密码框
importjava.awt.event.ActionListener;//事件监听
importjava.awt.event.ActionEvent;//事件处理
importjavax.swing.JOptionPane;//消息窗口{
publicJPanelpnluser;
publicJLabellbluserLogIn;
publicJLabellbluserName;
publicJLabellbluserPWD;
publicJTextFieldtxtName;
publicJPasswordFieldpwdPwd;
publicJButtonbtnSub;
publicJButtonbtnReset;
publicUserLogIn(){
pnluser=newJPanel();
lbluserLogIn=newJLabel();
lbluserName=newJLabel();
lbluserPWD=newJLabel();
txtName=newJTextField();
pwdPwd=newJPasswordField();
btnSub=newJButton();
btnReset=newJButton();
userInit();
}
publicvoiserInit(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置关闭框架的同时结束程序
this.setSize(300,200);//设置框架大小为长300,宽200
this.setResizable(false);//设置框架不可以改变大小
this.setTitle("用户登录");//设置框架标题
this.pnluser.setLayout(null);//设置面板布局管理
this.pnluser.setBackground(Color.cyan);//设置面板背景颜色
this.lbluserLogIn.setText("用户登录");//设置标签标题
this.lbluserLogIn.setFont(newFont("宋体",Font.BOLD|Font.ITALIC,14));//设置标签字体
this.lbluserLogIn.setForeground(Color.RED);//设置标签字体颜色
this.lbluserName.setText("用户名:");
this.lbluserPWD.setText("密码:");
this.btnSub.setText("登录");
this.btnReset.setText("重置");
this.lbluserLogIn.setBounds(120,15,60,20);//设置标签x坐标120,y坐标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(newActionListener()//匿名类实现ActionListener接口
{
publicvoidactionPerformed(ActionEvente){
btnsub_ActionEvent(e);
}
}
);
this.btnReset.setBounds(155,120,60,20);
this.btnReset.addActionListener(newActionListener()//匿名类实现ActionListener接口
{
publicvoidactionPerformed(ActionEvente){
btnreset_ActionEvent(e);
}
}
);
this.pnluser.add(lbluserLogIn);//加载标签到面板
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);//设置框架可显
}
publicvoidbtnsub_ActionEvent(ActionEvente){
Stringname=txtName.getText();
Stringpwd=String.valueOf(pwdPwd.getPassword());
if(name.equals("")){
JOptionPane.showMessageDialog(null,"账号不能为空","错误",JOptionPane.ERROR_MESSAGE);
return;
}elseif(pwd.equals("")){
JOptionPane.showMessageDialog(null,"密码不能为空","错误",JOptionPane.ERROR_MESSAGE);
return;
}elseif(true){
this.dispose();
}else{
JOptionPane.showMessageDialog(null,"账号或密码错误","错误",JOptionPane.ERROR_MESSAGE);
return;
}
}
publicvoidbtnreset_ActionEvent(ActionEvente){
txtName.setText("");
pwdPwd.setText("");
}
publicstaticvoidmain(String[]args){
newUserLogIn();
}
}
Ⅸ 怎么用java设计一个窗口,要求功能如下:
java编程思想里现成的例子。
// Demonstration of File dialog boxes.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FileChooserTest extends JFrame {
private JTextField
fileName = new JTextField(),
dir = new JTextField();
private JButton
open = new JButton("Open"),
save = new JButton("Save");
public FileChooserTest() {
JPanel p = new JPanel();
open.addActionListener(new OpenL());
p.add(open);
save.addActionListener(new SaveL());
p.add(save);
add(p, BorderLayout.SOUTH);
dir.setEditable(false);
fileName.setEditable(false);
p = new JPanel();
p.setLayout(new GridLayout(2,1));
p.add(fileName);
p.add(dir);
add(p, BorderLayout.NORTH);
}
class OpenL implements ActionListener {
public void actionPerformed(ActionEvent e) {
JFileChooser c = new JFileChooser();
// Demonstrate "Open" dialog:
int rVal = c.showOpenDialog(FileChooserTest.this);
if(rVal == JFileChooser.APPROVE_OPTION) {
fileName.setText(c.getSelectedFile().getName());
dir.setText(c.getCurrentDirectory().toString());
}
if(rVal == JFileChooser.CANCEL_OPTION) {
fileName.setText("You pressed cancel");
dir.setText("");
}
}
}
class SaveL implements ActionListener {
public void actionPerformed(ActionEvent e) {
JFileChooser c = new JFileChooser();
// Demonstrate "Save" dialog:
int rVal = c.showSaveDialog(FileChooserTest.this);
if(rVal == JFileChooser.APPROVE_OPTION) {
fileName.setText(c.getSelectedFile().getName());
dir.setText(c.getCurrentDirectory().toString());
}
if(rVal == JFileChooser.CANCEL_OPTION) {
fileName.setText("You pressed cancel");
dir.setText("");
}
}
}
public static void main(String[] args) {
FileChooserTest f = new FileChooserTest();
f.setTitle(f.getClass().getSimpleName());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400, 200);
f.setVisible(true);
}
} ///:~
Ⅹ java窗体设计
SSH:struts+spring+hibernate框架结构