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框架結構