導航:首頁 > 編程語言 > java窗體

java窗體

發布時間:2022-02-13 06:50:35

java如何顯示窗體

不太懂你的要求,猜了一下。可能是這樣:
import java.awt.Frame;
import java.awt.TextArea;

public class HelloWorld {
public static void main(String args[]){
Frame frame=new Frame("Windows窗體");
TextArea tArea=new TextArea();
tArea.append("HelloWorld");
frame.add(tArea);
frame.setVisible(true);//顯示窗體
}

}

② java這個窗體怎麼做出來

稍後你留個郵箱,一會我把布局代碼發給你。郵箱中間加些漢字 不然系統會和諧掉

③ java窗體滿分項目

給你個建議,不要學習java中的swing,java在這方面,自己都不玩了。
去學習:spring->spring boot->spring cloud吧
如果你針對窗體項目感興趣,去學習.NET的wpf

④ java窗口程序製作

麻煩能把答案也發一份給我么?[email protected]
我的郵箱,我也用sql~麻煩了~急呀~555

⑤ 求助:java窗體

/*
* StoreFrame.java
*
* Created on __DATE__, __TIME__
*/

/**
*
* @author __USER__
*/
public class StoreFrame extends javax.swing.JFrame {

/** Creates new form StoreFrame */
public StoreFrame() {
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu2 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jMenuBar1.setBackground(new java.awt.Color(0, 128, 255));

jMenu1.setText("\u7cfb\u7edf");
jMenuBar1.add(jMenu1);

jMenu2.setText("\u529f\u80fd");

jMenuItem1.setBackground(new java.awt.Color(0, 51, 255));
jMenuItem1.setText("\u5546\u54c1\u5165\u5e93");
jMenu2.add(jMenuItem1);

jMenuItem3.setText("\u5546\u54c1\u51fa\u5e93");
jMenu2.add(jMenuItem3);

jMenuItem2.setText("\u5546\u54c1\u67e5\u8be2");
jMenu2.add(jMenuItem2);

jMenuItem4.setText("\u5546\u54c1\u7edf\u8ba1");
jMenu2.add(jMenuItem4);

jMenuItem5.setText("\u5546\u54c1\u76d8\u70b9");
jMenu2.add(jMenuItem5);

jMenuItem6.setText("\u7cfb\u7edf\u7ba1\u7406");
jMenu2.add(jMenuItem6);

jMenuBar1.add(jMenu2);

jMenu3.setText("\u5e2e\u52a9");
jMenuBar1.add(jMenu3);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
Short.MAX_VALUE));
layout.setVerticalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 276,
Short.MAX_VALUE));

pack();
}// </editor-fold>
//GEN-END:initComponents

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new StoreFrame().setVisible(true);
}
});
}

//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
// End of variables declaration//GEN-END:variables

}

⑥ 用java創建窗口

我試一下硬碟文件存儲吧,首先在C盤根目錄下創建個login.swing的文件,在裡面寫上 tom##123&&lydia##123 ,這個為了方便測試,自己試下吧,我也是沒學多久,如果有太2的地方,請聯系我...謝謝...;

import java.awt.*;
import javax.swing.*;
import java.io.*;
public class LoginTest implements ActionListener{
private JFrame jf ;
private JLabel l1,l2 ;
private JTextField tf1 ;
private JPasswordField tf2;
private JPanel northPanel,centerPanel ;
private JButton b1,b2 ;
private File file = new File("c:/login.swing");

public LoginTest() {
jf = new JFrame("My First WindowTest") ;
northPanel = new JPanel(new GridLayout(2,2,10,10)) ;
l1 = new JLabel("用戶名:") ;
tf1 = new JTextField() ;
l2 = new JLabel("密 碼:") ;
tf2 = new JPasswordField() ;
northPanel.add(l1);
northPanel.add(tf1);
northPanel.add(l2);
northPanel.add(tf2);

centerPanel = new JPanel();
b1 = new JButton("login");
b2 = new JButton("exit");
centerPanel.add(b1);
centerPanel.add(b2);

b1.addActionListener(this);
b2.addActionListener(this);

jf.add(northPanel);
jf.add(centerPanel,"South");
jf.setSize(200,130);

Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
jf.setLocation(size.width / 2 - jf.getWidth() / 2, size.height / 2 - jf.getHeight() / 2);

jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
}

public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(b1)) {
String username = tf1.getText() ;
String password = String.valueOf(tf2.getPassword());
BufferedReader br = null ;
try {
FileReader fr = new FileReader(file);
br = new BufferedReader(fr);
String line = "",str = "" ;
while((line = br.readLine()) != null) {
str += line ;
}
String[] users = str.split("&&");
for(String user : users) {
String[] userInfo = user.split("##");
if(userInfo[0].equals(username) && userInfo[1].equals(password)) {
JOptionPane.showMessageDialog(null, "登錄成功!") ;
return ;
}
}
JOptionPane.showMessageDialog(null, "用戶名或密碼錯誤!") ;
return ;
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else {
System.exit(0);
}
}

public static void main(String args[]) {
new LoginTest();
}
}

⑦ java圖形界面子窗體怎麼弄

實在太長了!我都貼了好幾次都沒貼完,把核心方法給你貼出來: /**
* 保證只打開一個內部視窗的方法
* @param frame 要呼叫的內部視窗對象引用
*/
private void openOnlyOneInternalFrame(JInternalFrame frame) {
// 獲取桌面面板組件數組
JInternalFrame[] frames = pnlDsk.getAllFrames();
boolean isExist = false;
// 遍歷查找指定引用的內部視窗組件是否存在
for (JInternalFrame tmpFrame : frames) {
if (tmpFrame == frame) {
isExist = true;
}
}
// 如果不存在則添加到桌面面板
if (!isExist) {
pnlDsk.add(frame);
// 設置內部視窗位置居中
int x = (pnlDsk.getWidth() - frame.getWidth()) / 2;
int y = (pnlDsk.getHeight() - frame.getHeight()) / 2;
frame.setLocation(x, y);
}
// 將被呼叫內部視窗重新以默認方式布局(解決最小化後還原默認大小的問題)
frame.pack();
// 將被呼叫內部視窗顯示
frame.setVisible(true);
// 將被呼叫內部視窗置頂
// 方式一: 從類 java.awt.Window 繼承的方法
// frame.toFront();
// 方式二:從類 javax.swing.JInternalFrame 繼承的方法
frame.moveToFront();

// 將被呼叫內部視窗設置為選中狀態(標題欄高亮)
try {
frame.setSelected(true);
} catch (PropertyVetoException ex) {
ex.printStackTrace();
}
} ------------------------------------- 要源代碼就加我QQ,或發我QQ郵件,我回給你。

⑧ 如何用Java寫窗體

a.html 內容如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> A </TITLE>
<script language="javaScript">
function change(){
var value = window.showModalDialog("b.html",document);
if(value!=""){
alert(value);
}
}
</script>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<input type="text" id="username" readonly="1">
<input type="button" onClick="change()" value="查找">
</BODY>
</HTML>

----------------偶是分割線------------------

b.html內容如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<base target="_self">
<TITLE> B </TITLE>
<script language="javaScript">
window.returnValue="這個是從B.html返回的值";
function change(){
var doc = window.dialogArguments;
var username = document.getElementById("busername").value;
<!--這里是在用a.html的doc對象操作a頁面中的文本框-->
doc.getElementById("username").value = username;
window.close();
}
</script>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<!--這里還能用table等,獲取跟多的信息(比如雙擊單元格獲取單元格裡面的值)-->
<input type="text" id="busername"/>
<input type="button" onClick="change()" value="確定">
</BODY>
</HTML>

----------------偶是分割線------------------
參考資料

基本介紹:
showModalDialog() (IE 4+ 支持)
showModelessDialog() (IE 5+ 支持)
window.showModalDialog() 方法用來創建一個顯示HTML內容的模態對話框。
window.showModelessDialog() 方法用來創建一個顯示HTML內容的非模態對話框。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
參數說明:
sURL -- 必選參數,類型:字元串。用來指定對話框要顯示的文檔的URL。
vArguments -- 可選參數,類型:變體。用來向對話框傳遞參數。傳遞的參數類型不限,包括數組等。對話框通過window.dialogArguments來取得傳遞進來的參數。
sFeatures -- 可選參數,類型:字元串。用來描述對話框的外觀等信息,可以使用以下的一個或幾個,用分號「;」隔開。
----------------
1. dialogHeight: 對話框高度,不小於100px
2. dialogWidth: 對話框寬度。
3. dialogLeft: 離屏幕左的距離。
4. dialogTop: 離屏幕上的距離。
5. center: : 是否居中,默認yes,但仍可以指定高度和寬度。
6. help: : 是否顯示幫助按鈕,默認yes。
7. resizable: [IE5+]: 是否可被改變大小。默認no。
8. status: [IE5+]: 是否顯示狀態欄。默認為yes[ Modeless]或no[Modal]。
9. scroll: :是否顯示滾動條。默認為yes。

下面幾個屬性是用在HTA中的,在一般的網頁中一般不使用。
10. dialogHide::在列印或者列印預覽時對話框是否隱藏。默認為no。
11. edge::指明對話框的邊框樣式。默認為raised。
12. unadorned::默認為no。

參數傳遞:
1. 要想對話框傳遞參數,是通過vArguments來進行傳遞的。類型不限制,對於字元串類型,最大為4096個字元。也可以傳遞對象,例如:
-------------------------------
parent.htm
<script>
var obj = new Object();
obj.name="51js";
window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
var obj = window.dialogArguments
alert("您傳遞的參數為:" + obj.name)
</script>
-------------------------------
2. 可以通過window.returnValue向打開對話框的窗口返回信息,當然也可以是對象。例如:
------------------------------
parent.htm
<script>
str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>
modal.htm
<script>
window.returnValue="";
</script>

⑨ java能做窗體嗎

可以是可以,但是幾乎不會用java來做窗體應用的。

⑩ java窗體布局問題

第一個 創建兩個面板 p1 p2 flow布局 ,frame設置border布局 把p1,p2加到p3上, p1設置north 方位,p2設置center方位

第二個 創建三個面本 p1,p2,p3都是flow布局, frame設置border布局 ,p1north方位,p2center方位,p3 south方位

閱讀全文

與java窗體相關的資料

熱點內容
編譯怎麼學 瀏覽:329
數碼管顯示0到9plc編程 瀏覽:665
伺服器是為什麼服務的 瀏覽:765
java定義數據類型 瀏覽:874
安卓pdf手寫 瀏覽:427
什麼是app開發者 瀏覽:284
android鬧鍾重啟 瀏覽:101
程序員失職 瀏覽:518
在雲伺服器怎麼改密碼 瀏覽:586
伺服器pb什麼意思 瀏覽:940
51駕駛員的是什麼app 瀏覽:670
php靜態變數銷毀 瀏覽:886
編程買蘋果電腦 瀏覽:760
flac演算法 瀏覽:497
reactnative與android 瀏覽:663
程序員是干什麼的工作好嗎 瀏覽:258
kbuild編譯ko 瀏覽:469
條件編譯的宏 瀏覽:564
韓語編程語言 瀏覽:646
小程序開發如何租用伺服器 瀏覽:80