Re: [問題] 輸入字串,印出在JFrame

看板java作者 (小美)時間17年前 (2008/12/03 10:27), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
※ 引述《redhon ( redhon)》之銘言: : 請問.. : 如果我的主程式為 : public class mm{ : public static void main (String[] args) throws IOException { : BufferedReader keyin; : keyin =new BufferedReader(new InputStreamReader(System.in)); : System.out.print("請輸入字串:"); : String st=keyin.readLine(); : CFrame frame = new CFrame(); : } : } : 該如何讓輸入的字串顯示於 Frame 上??? : 謝謝!! Here is an example ^^ import java.io.IOException; import javax.swing.JFrame; import javax.swing.JLabel; public class mm { public static void main(String[] args) throws IOException { BufferedReader keyin; keyin =new BufferedReader(new InputStreamReader(System.in)); System.out.print("請輸入字串:"); String st = "Hello world!"; JFrame frame = new JFrame(); frame.getContentPane().add(new JLabel(st)); frame.setSize(400, 300); frame.setVisible(true); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 24.17.240.114
文章代碼(AID): #19DUw6Aa (java)