JavaWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JavaWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 JLabel怎麼斷行顯示?
missu0524





發文: 5
積分: 0
於 2008-09-29 16:34 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
/************************************
利用JFrame來建構UI的基礎
*************************************/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class demo25a
{
public static void main(String args[]) //程式起點
{
  JFrame frm=new JFrame("JFrame是基礎!");//順便設定標題
  JLabel lab1=new JLabel("測試UI介面");
  Container c;
  frm.setSize(200,200); //設定視窗大小
  frm.setLocation(100,100);//設定視窗位置
  c=frm.getContentPane(); //取得JFrame的內容容器,元件都放這裡
  c.add(lab1); //加入UI元件
  frm.setVisible(true);//將frame 展示出來
  frm.addWindowListener(new WindowAdapter(){ //匿名內部類別
    public void windowClosing(WindowEvent e)
    {
      System.exit(0);
    }
  }); //處理視窗關閉要求
}
}
以上資源來自網路上

請問要如何讓JLabel lab1=new JLabel("測試UI介面");斷行
顯示出來變成

測試UI
介面

我改成"測試UI\n介面"
沒有用..

我在網路上看到
Panel p1 = new Panel(new GridLayout(4,1));

p1.add(new Label("使用牌照稅將於四月一日開徵,"));

p1.add(new Label("財政部表示,由於遇到假期,"));

p1.add(new Label("繳納截止日延至五月二日,"));

p1.add(new Label("呼籲民眾儘速繳納以免被罰。"));

加入之後刪掉原本的顯示
變成沒有字幕..


vote up 0 vote down
missu0524 edited on 2008-09-29 16:56
reply to postreply to post
作者 Re:JLabel怎麼斷行顯示? [Re:missu0524]
Forth



版主

發文: 673
積分: 8
於 2008-09-29 17:36 user profilesend a private message to usersend email to Forthreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1
JLabel lab1 = new JLabel("<html>測試UI<br>介面</html>");


vote up 0 vote down
reply to postreply to post
孟母擇鄰,良禽擇木,電腦擇友
作者 Re:JLabel怎麼斷行顯示? [Re:Forth]
missu0524





發文: 5
積分: 0
於 2008-09-30 00:02 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Forth wrote:
1
JLabel lab1 = new JLabel("<html>測試UI<br>介面</html>");



謝謝你..原來是這樣
我今天使用搜尋功能有看到這樣的解答..
但是我以為是用網頁的地方..
再次謝謝你..


vote up 0 vote down
reply to postreply to post

» JavaWorld@TW »  Java 新手區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JavaWorld@TW


Powered by Powerful JuteForum® Version Jute 1.5.8
Copyright© 2002-2003 Rainman Zhu,Zua,Netboy,Scott. All Rights Reserved.