❶ java文本框如何自动跳转
一般不是按回车跳到下一个输入框的!你按Tab键就会自动跳到下一个输入框的!按回车一般都是提交表单!而且不需要怎么弄!在一个表单里就好!
❷ java中怎么由一个界面跳到另一个界面
package Action;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Demo1 {
JFrame frame=new JFrame();
JLabel label=new JLabel("文本几行");
JTextField text=new JTextField();
JButton but=new JButton("确定");
public Demo1()
{
.setLayout(null);
frame.setSize(300, 200);
label.setBounds(50, 10, 70, 20);
text.setBounds(110, 10, 80, 20);
but.setBounds(200, 10, 80, 20);
but.addActionListener(new Listener());
frame.add(label);
frame.add(text);
frame.add(but);
frame.setVisible(true);
}
class Listener implements ActionListener{
public void actionPerformed(ActionEvent e){
if(e.getSource()==but){
Demo2.k=Integer.parseInt(text.getText());
new Demo2();
}
}
}
public static void main(String[] args){
new Demo1();
}
}
package Action;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
class Demo2 {
static int k;
JFrame frame=new JFrame();
public Demo2(){
frame.setLayout(null);
frame.setLayout(new GridLayout(k,1,3,3));
for(int i=0;i<k;i++){
JButton but=new JButton("按钮");
frame.add(but);
}
frame.setSize(300, 200);
frame.setVisible(true);
}
}
❸ 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>
=======================================================
把两个文件保存到同级目录下就可以了.
❹ java代码怎么访问网页:例如在java中编写一段代码能够让他跳到到百度的首页
<jsp:forward page=""></jsp:forward>写上你要跳转的页面地址就可以了,这个jsp标准动作
❺ java中如何使文本框输入字符之后自动跳到下一文本框
给你写了一个 Demo,注意 addKeyListener 那段,添加键盘监听器以后用 grabFocus 可以强制转换焦点。
----------------------------------------------
import javax.swing.*;
import java.awt.event.*;
public class Demo extends JFrame {
private JTextField txtInput1, txtInput2;
public Demo () {
super("Demo Program");
setSize(100, 130);
setLocationRelativeTo(null);
setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
txtInput1 = new JTextField();
txtInput1.setBounds(10, 10, 80, 30);
txtInput1.addKeyListener(new KeyAdapter() {
public void keyTyped (KeyEvent ke) {
txtInput2.grabFocus();
}
});
txtInput2 = new JTextField();
txtInput2.setBounds(10, 50, 80, 30);
add(txtInput1);
add(txtInput2);
setVisible(true);
}
public static void main (String args[]) {
new Demo();
}
}