[英]How may I update a JTextField while my GUI is running?
所以這是帶有文本字段的類
public class SeatInformation extends JPanel{
public static byte section = 0;
public static int price = 0;
public static char row = 0;
public static byte number = 0;
public SeatInformation(String title){
setLayout(new GridLayout(5,5));
setLocation(500,20);
setSize(100, 50);
//Section Label and TextField
JLabel SectionLabel = new JLabel("Section:");
SectionLabel.setVisible(true);
add(SectionLabel);
JTextField Section = new JTextField(""+section);
Section.setVisible(true);
add(Section);
這是我的代碼,用於調用字段中的更改。
if(Stadium.getSeat(r,c).getSection() == 1){
final byte s = Stadium.getSeat(r,c).getSection();
final int p = Stadium.getSeat(r, c).getPrice();
final char ro = Stadium.getSeat(r, c).getRow();
final byte n = Stadium.getSeat(r, c).getNumber();
re.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e){
SeatInformation.section = s;
}
});
我不知道如何更新我的“SeatInformation”類中的所有值,所有建議都表示贊賞。
您必須將JTextField的實例保存在類的屬性中並調用setText()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.