❶ 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();
}
}