導航:首頁 > 編程語言 > java添加文本框

java添加文本框

發布時間:2023-08-31 19:51:40

㈠ 用java寫出來的窗口上怎麼添加固定的文本框

public class mainFrame extends JFrame{
JLabel jl = new JLabel("用戶名稱:");
JTextField jtf = new JTextField();
JPanel jp_group = new JPanel();

public loginFrame() {
try {
jbInit();com.hrkj.hrkjkf.common.mysession.dataTrf.getValue("main");
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
jp_group.add(jl);
jp_group.add(jl);
this.add(jtf)
this.setTitle("窗體");
this.setSize(265, 185);
}
public static void main(String[] args) {
mainFrame mf = new mainFrame();
mf.setVsible(true);
}
}

㈡ JAVA一個窗體添加三個文本框具體怎麼操作

只要文本框添加監聽即可,用ActionListener即會在文本框中按下回車鍵時觸發事件。
下面是監聽的代碼:
public void actionPerformed(ActionEvent e)
{
Object o=e.getSource();

if(o==text1) //文本框旅孫一號拆李鏈
{
text2.requestFocus();//文本框2號,請求焦點

}
else if(o==text2)
{
text3.requestFocus();

}
}

程序如下:
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class MyFrame extends JFrame implements ActionListener
{
private JButton button;
private JTextField textField;
private JLabel label;
public MyFrame()
{
button = new JButton("Hello world");
textField = new JTextField(15);
label = new JLabel("輸入內容:"擾閉);
setTitle("Simple-Frame");
setBounds((Toolkit.getDefaultToolkit().getScreenSize().width - 500)/2,
(Toolkit.getDefaultToolkit().getScreenSize().height - 300)/2
, 500, 300);
setLayout(new FlowLayout());
add(label);
add(textField);
add(button);
setResizable(false);
setVisible(true);
this.button.addActionListener(this);
}
public static void main(String[] args)
{
new MyFrame();
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == this.button)
{
this.textField.setText("Hello World");
}
}
}

㈢ JAVA如何創建一個20行30列的文本框

1、首先打開Java表格進入界面。
2、其次點擊創建表格進入設置界面。
3、最後編劇調整為20行30列點擊確定即可。

閱讀全文

與java添加文本框相關的資料

熱點內容
資料庫查詢系統源碼 瀏覽:617
php5314 瀏覽:358
完美國際安裝到哪個文件夾 瀏覽:669
什麼app可以掃一掃做題 瀏覽:540
程序員編碼論壇 瀏覽:924
淘點是什麼app 瀏覽:660
中國高等植物pdf 瀏覽:454
51單片機時間 瀏覽:182
後台如何獲取伺服器ip 瀏覽:267
單片機流水燈程序c語言 瀏覽:235
程序員第二職業掙錢 瀏覽:240
運行里怎麼輸入伺服器路徑 瀏覽:843
pythonstepwise 瀏覽:510
劉一男詞彙速記指南pdf 瀏覽:66
php認證級別 瀏覽:370
方舟編譯啥時候推送 瀏覽:1012
php手機驗證碼生成 瀏覽:677
哲學思維pdf 瀏覽:17
凌達壓縮機有限公司招聘 瀏覽:535
weblogic命令部署 瀏覽:39