当前位置:首页 » 编程语言 » java页面

java页面

发布时间: 2022-01-09 19:27:14

A. java界面设计

我觉得,页面布局什么的,这个不用说了吧。。就是逻辑而已,点击“第一步”,判断有没有输入,如果有输入,判断是不是正整数,如果条件符合,那么第一格显示输入的值,然后第二格,处理下(其实就是for循环String,倒序)然后第三格=第一格+第二格的值;
第二步,同样获得第一步最后一个的和值,然后类似第一步。如下类似

B. Java 界面设计

import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import java.awt.GridBagConstraints;

public class Test1 extends JPanel {

private static final long serialVersionUID = 1L;
private JSplitPane jSplitPane = null;

/**
* This is the default constructor
*/
public Test1() {
super();
initialize();
}

/**
* This method initializes this
*
* @return void
*/
private void initialize() {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.gridx = 0;
this.setSize(300, 200);
this.setLayout(new GridBagLayout());
this.add(getJSplitPane(), gridBagConstraints);
}

/**
* This method initializes jSplitPane
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane() {
if (jSplitPane == null) {
jSplitPane = new JSplitPane();
}
return jSplitPane;
}

}
楼主是不是要这种的效果???

C. java页面怎么取得jsp页面的值

jsp在页面上获取java参数总共有以下方法:
(1)直接在URL请求后添加
如:<a href="thexuan.jsp?action=transparams&detail=directe")直接传递参数, 特别的在使用response.sendRedirect做页面转向的时候,也可以用如下代码: response.sendRedirect("thexuan.jsp?action=transparams&detail=directe") ,可用request.getParameter(name)取得参数
(2)jsp:param
它可以实现主页面向包含页面传递参数,如下:



还可以实现在使用jsp:forward动作做页面跳转时传递参数,如下:


通过这种方式和一般的表单参数一样的,也可以通过request.getParameter(name)取得参数
(3)设置session和request
通过显示的把参数放置到session和request中,以达到传递参数的目的
session.setAttribute(name,value);
request.setAttribute(name,value)
取参数:value=(value className)session.getAttribute(name);
value=(value className)request.getAttribute(name);

D. 如何在HTML页面中写java代码

Java要运行html代码,需要运行在服务器端,也就是servlet容器中,经过容器编译解析,返回html静态内容,示例如下:

在servlet里面写就可以了
引入一系列包
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
public class Servlet1 extends HttpServlet {
public void doGet(ServletRequest req,ServletResponse res)throws ServletException, IOException{try{PrintWriter pw=res.getWriter();//在浏览器输出需要
pw.println("<script<script");}catch(exception e){="" e.printstacktrace();="" 为发现调试错误}}}=""

E. java实现简单登录界面

自己写的比较规范的代码,都有注释:

import javax.swing.JFrame;//框架
import javax.swing.JPanel;//面板
import javax.swing.JButton;//按钮
import javax.swing.JLabel;//标签
import javax.swing.JTextField;//文本框
import java.awt.Font;//字体
import java.awt.Color;//颜色
import javax.swing.JPasswordField;//密码框
import java.awt.event.ActionListener;//事件监听
import java.awt.event.ActionEvent;//事件处理
import javax.swing.JOptionPane;//消息窗口

public class UserLogIn extends JFrame{
public JPanel pnluser;
public JLabel lbluserLogIn;
public JLabel lbluserName;
public JLabel lbluserPWD;
public JTextField txtName;
public JPasswordField pwdPwd;
public JButton btnSub;
public JButton btnReset;

public UserLogIn(){
pnluser = new JPanel();
lbluserLogIn = new JLabel();
lbluserName = new JLabel();
lbluserPWD = new JLabel();
txtName = new JTextField();
pwdPwd = new JPasswordField();
btnSub = new JButton();
btnReset = new JButton();
userInit();
}

public void userInit(){
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(new Font("宋体",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(new ActionListener()//匿名类实现ActionListener接口
{
public void actionPerformed(ActionEvent e){
btnsub_ActionEvent(e);
}
}
);
this.btnReset.setBounds(155,120,60,20);
this.btnReset.addActionListener(new ActionListener()//匿名类实现ActionListener接口
{
public void actionPerformed(ActionEvent e){
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);//设置框架可显
}

public void btnsub_ActionEvent(ActionEvent e){
String name = txtName.getText();
String pwd = String.valueOf(pwdPwd.getPassword());
if(name.equals("")){
JOptionPane.showMessageDialog(null,"账号不能为空","错误",JOptionPane.ERROR_MESSAGE);
return;
}else if (pwd.equals("")){
JOptionPane.showMessageDialog(null,"密码不能为空","错误",JOptionPane.ERROR_MESSAGE);
return;
}else if(true){
this.dispose();
}else{
JOptionPane.showMessageDialog(null,"账号或密码错误","错误",JOptionPane.ERROR_MESSAGE);
return;
}
}

public void btnreset_ActionEvent(ActionEvent e){
txtName.setText("");
pwdPwd.setText("");
}

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

F. java如何添加界面

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
public class app//类名最好大写
{
static JFrame frm =new JFrame("清扫机器人模拟界面");
static ImageIcon bg = new ImageIcon("456.jpg");//背景图片名称,相对路径
static JLabel lab=new JLabel(bg);//图片放在标签里
public static void main(String[] args) {
lab.setBounds(0, 0, bg.getIconWidth(), bg.getIconHeight());//设置图片的大小
frm.getLayeredPane().add(lab,new Integer(Integer.MIN_VALUE));//把图片设置在第二层
JPanel jp = (JPanel) frm.getContentPane();//获取最上层JPanel
jp.setOpaque(false);//设置为透明
//JPanel jp2 = new JPanel();//如果要加按钮什么的就在这个jp2里面加,不需要的话就用了
//jp2.setOpaque(false);
//frm.add(jp2);
frm.setLayout(null);
frm.setSize(1300,700);
//frm.setBackground(Color.blue);
frm.setVisible(true);
frm.addWindowListener(new WindowAdapter() {//关闭窗口的方法没写
@Override
public void windowClosing(WindowEvent e) {
frm.setVisible(false);
System.exit(0);
}

});
}
}

G. 用java做个如下界面

对于窗口的左侧部分,存在几种可能, 1: 可能是工具栏里的按钮 2: 可能是选项卡 3: 一个按钮

三种可能性我写了三种参考代码.(建议对问题的描述更加清晰,这样可以得到更贴切的回答)

importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;

{
JPaneljp1;

publicSimpleDemo(){
initMenuBar();
JPaneljpWest=newJPanel();
JButtonjb=newJButton("拓扑");
jb.addActionListener(this);
jpWest.add(jb);

jp1=newJPanel();
jp1.setBackground(Color.RED);
jp1.setVisible(false);
add(jp1);
add(jpWest,BorderLayout.WEST);

setSize(300,200);//窗口大小
setLocationRelativeTo(null);//居中
setDefaultCloseOperation(EXIT_ON_CLOSE);//点击关闭按钮就退出
}

privatevoidinitMenuBar(){
JMenuBarjmb=newJMenuBar();
JMenujm1=newJMenu("系统");
JMenuItemitem1=newJMenuItem("退出");
item1.addActionListener(newActionListener(){
@Override
publicvoidactionPerformed(ActionEvente){
System.exit(0);//点击退出菜单项时,结束程序
}
});
jm1.add(item1);
JMenujm2=newJMenu("帮助");
jmb.add(jm1);
jmb.add(jm2);
setJMenuBar(jmb);//设置本窗口的菜单栏
}

publicstaticvoidmain(String[]args){
SwingUtilities.invokeLater(newRunnable(){
publicvoidrun(){
newSimpleDemo().setVisible(true);//创建窗口并设置可见
}
});
}

@Override
publicvoidactionPerformed(ActionEvente){
jp1.setVisible(!jp1.isVisible());
}
}

H. JAVA页面跳转

a页面代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> page A </TITLE>
<script language="javascript">
function newWin(){
var str = window.showModalDialog("pageB.html",null,"dialogWidth=400px;dialogHeight=300px");
if (typeof(str) == "undefined") {
alert("没有传回值来");

}else{
document.getElementById("mytext").value=str;
}
}
</script>
</HEAD>

<BODY>
<input type="text" id="mytext">
<input type="button" value="button" onclick="newWin();">
</BODY>
</HTML>

b页面代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Page B </TITLE>
<script language="javascript">
function colseWin(){
var returnValue = document.getElementById("mytext").value.trim;
window.returnValue=returnValue;
window.close();
}
</script>
</HEAD>

<BODY>
<input type="text" id="mytext">
<input type="button" value="保存并关闭" onclick="colseWin();">
</BODY>
</HTML>

=======================================================
把两个文件保存到同级目录下就可以了.

I. 用Java如何实现界面的功能

新建一个窗口,然后实现一个关闭按钮”窗口的功能
import java.awt.*;
import java.awt.event.*;

public class TestWindowEvent {
public static void main (String[] args) {
new Frame88 ("WindowAdapter");
}
}
class Frame88 extends Frame {
Frame88 (String s) {
super(s);
setBounds (300,300,200,70);
setLayout (null);
setVisible (true);
addWindowListener (new WindowAdapter() {
public void windowClosing(WindowEvent e) {
setVisible (false);
System.exit(0);
}
} );
}
}

热点内容
php查询结果数组 发布:2025-02-06 12:31:05 浏览:714
怎样把照片压缩打包 发布:2025-02-06 12:15:19 浏览:496
如何编译java文件 发布:2025-02-06 12:05:58 浏览:237
九九乘法编程 发布:2025-02-06 12:05:05 浏览:519
台式机忘记开机密码怎么办 发布:2025-02-06 11:58:01 浏览:871
android刷新按钮 发布:2025-02-06 11:57:17 浏览:586
存储过程有输入参数和输出参数 发布:2025-02-06 11:55:32 浏览:99
成绩评选算法 发布:2025-02-06 11:42:51 浏览:997
数据库测试数据 发布:2025-02-06 11:31:05 浏览:824
球头轴编程 发布:2025-02-06 11:29:36 浏览:283