导航:首页 > 编程语言 > 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窗体相关的资料

热点内容
360pdf阅读器下载 浏览:751
百战程序员标签管理视频 浏览:380
朗读者app会员怎么下载 浏览:269
java读取单词 浏览:547
android查看网关 浏览:419
下载的主题在文件夹中找不到 浏览:16
在线攻击服务器什么意思 浏览:229
ce怎么改安卓系统 浏览:12
php分页显示代码 浏览:911
吃甜的东西缓解压力 浏览:171
有什么手势舞app 浏览:89
固定收益pdf 浏览:409
java排序comparator 浏览:500
如何只输入服务器上的ip 浏览:490
单片机称号 浏览:194
phpsocket并发多少 浏览:579
tomcat安装php 浏览:78
clay黏土服务器怎么加黏土 浏览:765
androidsetcolor 浏览:174
手机如何登陆主机服务器 浏览:531