Multiline JLabel in Japanese?

Hi.
On Windows NT 4.0, I am trying to get a JLabel to display multiple lines in Japanese.
With English or other Latin-based languages, this can be done easily enough using HTML tags. However, when I try to mix HTML tags with Japanese, the Japanese will not be rendered. Rather, it will display the infamous square box.
Below is sample code which renders the two cases (uncomment the appropriate case).
Any ideas?
import javax.swing.*;
import java.awt.*;
public class test {
public static void main(String[] args) {
JFrame frame = new JFrame("HelloWorldSwing");
final JLabel label = new JLabel();
Font f = new Font("MS Mincho", Font.PLAIN, 24);
label.setFont(f);
     // This doesn't render the Japanese, but it renders Cyrillic
label.setText("<html><body>\u0414<br>\u3059</body></html>");
     // This renders both Japanese and Cyrillic properly
     //label.setText("\u0414\u3059");
frame.getContentPane().add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}

One thing I forgot to mention...
I tried setting the following as well:
label.setText("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF8\"></head><body>\u0414<br>\u3059</body></html>");
For "charset", I tried various different settings (shift_jis, utf8, utf-8, utf-16). However, I may have gotten this wrong so I am mentioning this, in case it helps anyone to find the correct answer more easily.

Similar Messages

  • Not sure why line break is not working

    Hi all,
    Here is part of my simple Swing application:
    String text1 = "hello";
    String text2 = "world";
    String text3 = text1+"\n"+text2;
    // have also tried (String text3 = text1+"\n\r"+text2;)
    displayField.setText(text3);I supposed that the text3 in the label field (displayField) would display like this:
    hello
    world
    But not, the text3 just displayed in the same line like this instead: helloworld.
    I am not sure why the line break is not working.

    Use HTML for a multiline JLabel.// String text3 = text1+"\n"+text2;
    String text3 = "<html>" + text1 + "<br/>" + text2 + "</html>";db

  • Choice of Text Component

    Hi!
    I need the text component for image and text or only the text output. I also need scrolling, if it is needed, and auto line wrapping.
    In general, I need multiline JLabel with scrolling, line and word wrapping.

    HowdyTom.Sanders:
    where in the formatting help does it tell you how to embed links in the text rather than having to use the ugly URL?To see how it's done, click reply to camickr's post, then click quote original -- basically the format is:
    [ url link] whatever [ /url] (tag with no space).
    ;o)
    V.V.

  • Displaying multiline txt in JLabel

    How to display multilines in JLabel.

    sigh
    Use the fine forum search, please. This has been answered many times before.

  • Bringing Chinese/Japanese characters as JLabel Text

    Hi,
    In our application we are planning to implement multiple languages as labels.
    We succeded to implement French,German etc because the characters are present on keyboard and the editors support the text.
    Now we are planning to implement Chinese/Japanese. At this moment we dont know whether we can type Chinese/Japanese text through key board and whether our editor support those characters.
    Can anybody please tell me the procedure to bring Chinese/Japanese Characters as JLabel Text in Swing Application?
    Thanks in advance,
    Vattikuti

    What you wanted to do depends to a large extent on the OS... On Windows XP, install the appropriate language packs (there are several for Chinese and at least two for Japanese languages) and check it out.
    ;o)
    V.V.

  • How to display Long text in a JLabel with multiline??

    Hi,
    Suppose I have a label that displays a long text....
    ""This is an example label that displays long text, how to break the line????.........""
    how to display it like below with one label?
    ""This is an example label
    that displays long text, how
    to break the line????.........""
    Thanks

    so basically do this
    JLabel myLabel = new JLabel();
    String theText = "<html>This is an example label<br>
                                  that displays long text, how<br>
                                  to break the line????.........</html>";
    myLabel.setText(theText);Obivously, u dont have to use a separate string, u could just call setText or pass it into the JLabel constructor, i just separated it to make it easier to see what your supposed to do.
    GOod Luck

  • How to write multiline String in a JLabel

    How can i write a string that is shown in many lines in a JLabel. Or is there any orher way to write them?
    Also, similarly how to write tooltip text that spans across many lines. Not just one line

    import java.awt.*;
    import javax.swing.*;
    public class UseThisTheNextTimeYouFeelLikePostingEelops {
        public static void main(String[] args) {
            String str = "This is \nmy example \nof a multi-line \nJLabel";
            JLabel strLabel = new JLabel (str);
            display(strLabel, "Hmmm...");
        public static void display(JComponent comp, String title) {
            JFrame f = new JFrame(title);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(comp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • JLabel Multiline

    Hi,
    I am trying to create a JOptionPane.showMessageDialog which is multiline. So I decided to use HTML to create the lines. The only issue is that the html shows up correctly in IE but crooked when it displays inside the showMessageDialog (the spacing is messed up).
    Any help would be greatly appreciated.
    domMike
    (html below, you can just copy it into a blank txt file and thne open it in IE to see what i mean)
    <html><body>          x<br>         xxx<br>        xxxxx<br>       xxxxxxx<br>      xxxxxxxxx<br>     xxxxxxxxxxx<br>    xxxxxxxxxxxxx<br>   xxxxxxxxxxxxxxx<br>  xxxxxxxxxxxxxxxxx<br> xxxxxxxxxxxxxxxxxxx<br>xxxxxxxxxxxxxxxxxxxxx<br> xxxxxxxxxxxxxxxxxxx<br>  xxxxxxxxxxxxxxxxx<br>   xxxxxxxxxxxxxxx<br>    xxxxxxxxxxxxx<br>     xxxxxxxxxxx<br>      xxxxxxxxx<br>       xxxxxxx<br>        xxxxx<br>         xxx<br>          x<br></body></html>

    String str = "<html> This<br> is<br> a<br>
    html<br> multi<br> line<br> demo. </html>";
    JOptionPane.showMessageDialog(null, str);the first six characters of the string should be
    <html>I am stil facing space problems I even atempted to use the equivalent of a spcae in html by use &anbsp; �
    Also what do you mean by the bard "the first 6 characters of the string should be html?
    Thanks,
    Mike
    Thanks,
    Mike

  • Multiline tooltip for JComboBox items.

    Hi, As the title suggests I'd like to create a multiline tooltip for items in a combobox list.
    I have implemented a multiline tooltip renderer which works perfectly on any component except JComboBox items.
    I have also implemented a ListCellRenderer for a combobox that enables tooltips for the combobox items. Also works perfectly, except that they are single line tooltips.
    The tooltip text is read from an xml file, therefore I have no control on how long the line of text is. Most of the time the text also contains newlines.
    This is the method (overridden from JComponent) added to a subclass of a component so that that component uses the MultiLineToolTip:
        public JToolTip createToolTip() {
            MultiLineToolTip tip = new MultiLineToolTip(this);
            tip.setComponent(this);
            return tip;
        }And this is the ListCellRenderer used on the combobox, so that items have (single-line) tooltips enabled:
        private class ToolTipEnabledComboBoxRenderer extends JLabel implements ListCellRenderer{
             public ToolTipEnabledComboBoxRenderer(){
                  setOpaque(true);
             public Component getListCellRendererComponent(JList list,Object value,
                                                              int index,boolean isSelected,
                                                              boolean cellHasFocus) {
                  String entry = (String)value;
                  if (isSelected || cellHasFocus) {
                       this.setBackground(list.getSelectionBackground());
                       setForeground(list.getSelectionForeground());
                  } else {
                       this.setBackground(list.getBackground());
                       setForeground(list.getForeground());
                  this.setText(entry);
                  if(isSelected || cellHasFocus){
                       if(constraint!=null &&combobox!=null &&
                                   constraint.getType() == Constrained.CONTROLLED_VOCABULARY){
                            String tooltip = ((ControlledVocabulary)constraint).getEntryDescription(entry);
                            if(tooltip==null || tooltip.equals("")){
                                 tooltip="";
                            list.setToolTipText(tooltip);
                  return this;
        }It seems to me that what I have to do is subclass the list used by the combobox and override the createToolTip() method. But how can I set the list used by the combobox? As far as I know the only time I can access the list is in the getListCellRendererComponent() method of the ListCellRenderer, in which the list is a parameter.
    Any ideas?
    Don

    Hello,
    <p>Have you seen this one?</p>
    Francois

  • Japanese character is not displaying properly in JDialog

    Hi All,
    Japanese character are shown in parent window but not displaying properly JDialog window.
    Even JDialog Title bar is showing in Japanese properly but JLabel's and JButton text are not showing properly in Japanese.
    Anybody knows why Japanese characters are not showing properly in JLabel and JButton of JDialog window.
    Thanks,
    -Mani

    Specified font on that objects, that's why Japanese character doesn't shown.

  • Multiline text in a jtree node

    i'm not able to add the multiline text in a jtree node. i've checked the data in both the cases before adding into the tree and after adding into the tree. itz getting the data in the proper format. but while displaying inside the tree itz taking into the single line.
    kindly help me to get the data in a multi line format in the jtree.
    thanks in advance.
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.text.*;
    public class DynamicTreeDemo extends JPanel {
    public static String transactionName=null;
    String p1Name=null;
       public static String duration=null;
        public static final String NEWLINE = System.getProperty("line.separator");
    static String[] arrCorrelatorId={"110","122","129","132","130","136","111","109","131","124","127",null};
    static String[] arrParcorrelatorId={"108","110","122","129","122","130","108","108","109","121","121"};
    static String[] arrtransactionName={"FINT3","FINT17","FINT20","FINT52","FINT21","FINT18","FINT4","FINT3"," FINT31","FINT19","FINT51"};
    public static MutableTreeNode node;
    public static DefaultTreeModel model;
    public static TreePath path;
    public static JTree tree;
    static String[] nodeName={"FINT3_108","FINT17_110","FINT20_122","FINT52_129","FINT21_122","FINT18_110","FINT4_108","FINT3_108"," FINT31_109","FINT19_121","FINT51_121",null};
    public DynamicTreeDemo(JFrame frame) {
    final DynamicTree treePanel = new DynamicTree(transactionName);
    populateTree(treePanel);
    JTextField name = new JTextField(20);
    setLayout(new BorderLayout());
    treePanel.setPreferredSize(new Dimension(300, 150));
    add(treePanel, BorderLayout.CENTER);
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(10,50));
    add(panel, BorderLayout.EAST);
    public DefaultMutableTreeNode newObj(String parent){
    DefaultMutableTreeNode pname= new DefaultMutableTreeNode(parent);
    return pname;
    public void populateTree(DynamicTree treePanel)
         String p3;
         DefaultMutableTreeNode p2,nNode, p1;
         int ind=0, i=0,k=0, len=0, m=0;
         boolean flag= false;
         String desc;
         while(nodeName[m]!=null)
         p3 = nodeName[m];
         ind = p3.indexOf("_");
         p3 = p3.substring(0, ind);
           desc=NEWLINE +"hi"+NEWLINE+"how r u";
         if(arrParcorrelatorId[m].equals(arrParcorrelatorId[0]))
                   treePanel.addObject(null, p3,desc);
         else{
              int loopcount=0;
              for(int j=0;nodeName[j]!=null;j++)
                        if(arrParcorrelatorId[m].equals(arrParcorrelatorId[j]))
                             for(int p=0;nodeName[p]!=null;p++)
                                       if(arrCorrelatorId[p].equals(arrParcorrelatorId[j]))
                                            p1=newObj(arrtransactionName[p]);
                                            System.out.println("parent:"+p1);
                                            System.out.println("child:"+p3);
                                            treePanel.addObject(p1, p3,desc);
                                            break;
                        break;
              m++;
    public static void showNodes(String corrId)
         transactionName="FINT3";
    public void DynamicDisplayNode(String corrId){
    JFrame frame = new JFrame("DynamicTreeDemo");
    showNodes(corrId);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1,1));
    contentPane.add(new DynamicTreeDemo(frame));
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args)
    JFrame frame1=null;
    DynamicTreeDemo demo= new DynamicTreeDemo(frame1);
    demo.DynamicDisplayNode("108");
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.util.Enumeration;
    import java.util.StringTokenizer;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    import javax.swing.border.Border;
    import javax.swing.border.LineBorder;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.*;
    public class DynamicTree extends JPanel  {
        protected DefaultMutableTreeNode rootNode;
        protected DefaultTreeModel treeModel;
        protected JTree tree;
        protected DefaultTreeCellRenderer linksRenderer;
        public static final String NEWLINE = System.getProperty("line.separator");
        public DynamicTree(String appName) {
             rootNode = new DefaultMutableTreeNode(appName);
            treeModel = new DefaultTreeModel(rootNode);
            tree = new JTree(treeModel);
            tree.setEditable(false);
            tree.setShowsRootHandles(true);
            tree.setBackground(Color.white);
            tree.setCellRenderer(new DefaultTreeCellRenderer()
                 public Component getTreeCellRendererComponent(JTree pTree,
                     Object pValue, boolean pIsSelected, boolean pIsExpanded,
                     boolean pIsLeaf, int pRow, boolean pHasFocus)
                       DefaultMutableTreeNode node = (DefaultMutableTreeNode)pValue;
                       JLabel lbl = (JLabel)super.getTreeCellRendererComponent(pTree, pValue, pIsSelected,pIsExpanded, pIsLeaf, pRow, pHasFocus);
                      lbl.setBorder(new LineBorder(Color.RED,1));
                 /* Component c =  super.getTreeCellRendererComponent(pTree, pValue, pIsSelected,
                         pIsExpanded, pIsLeaf, pRow, pHasFocus);
                           if (node.isRoot())
                                          c.setForeground(Color.red);
                          else if (node.getChildCount() > 0)
                                    c.setForeground(Color.blue);
                           else if (pIsLeaf)
                                    c.setForeground(Color.black);//new Color(0x736AFF));*/
                           setBackgroundNonSelectionColor(Color.white);
                           JPanel p = new JPanel();
                           p.setBackground(tree.getBackground());
                           Dimension d = lbl.getPreferredSize();
                           p.setPreferredSize(new Dimension(d.width, d.height));
                           p.add(lbl);
                           tree.setRowHeight(30);
                  return (p);
            JScrollPane scrollPane = new JScrollPane(tree);
            setLayout(new GridLayout(1,0));
            add(scrollPane);
        public void addObject(DefaultMutableTreeNode parent,Object child,String desc)
            child=child+desc;
            //System.out.println("child"+child);
                DefaultMutableTreeNode     parent1;
            DefaultMutableTreeNode childNode =
                    new DefaultMutableTreeNode(child);
              if (parent == null)
                          parent = rootNode;
              else
                   String parentName = (String)parent.getUserObject();
                   String tok;
                   Enumeration e=null;
                   e=(Enumeration) rootNode.breadthFirstEnumeration();
                   int breakloop=0;
                   parent = rootNode.getLastLeaf();
                    while (e.hasMoreElements() ) {
                        if(parent!= null)
                             //System.out.println("parent.toString():"+parent.toString());
                             tok=parent.toString();
                             StringTokenizer st = new StringTokenizer(tok);
                             parent1=newObj(st.nextToken());
                             if(parent1.getUserObject().equals(parentName))
                                       breakloop=1;
                                       break;
                             parent= parent.getPreviousNode();
                   if(breakloop==0)
                        parent = rootNode.getLastLeaf();
              System.out.println("parent.toString():"+parent.toString());
              System.out.println("childNode"+childNode.toString());
              parent.add(childNode);
    public DefaultMutableTreeNode newObj(String parent){
          DefaultMutableTreeNode pname= new DefaultMutableTreeNode(parent);
              return pname;
    class MyTreeModelListener implements TreeModelListener {
            public void treeNodesChanged(TreeModelEvent e) {
                DefaultMutableTreeNode node;
                node = (DefaultMutableTreeNode)
                         (e.getTreePath().getLastPathComponent());
                try {
                    int index = e.getChildIndices()[0];
                    node = (DefaultMutableTreeNode)
                           (node.getChildAt(index));
                } catch (NullPointerException exc) {}
            public void treeNodesInserted(TreeModelEvent e) {
            public void treeNodesRemoved(TreeModelEvent e) {
            public void treeStructureChanged(TreeModelEvent e) {
    }

    Here is a simple example.
    import java.awt.BorderLayout;
    import javax.swing.*;
    import javax.swing.tree.DefaultMutableTreeNode;
    public class MultiLineTreeDemo extends JFrame {
         private JTree tree;
         public static void main( String[] args ) throws Exception {
              SwingUtilities.invokeLater( new Runnable() {
                   public void run() { new MultiLineTreeDemo(); }
         public MultiLineTreeDemo() {
              super( "MultiLineTreeDemo" );
              setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              DefaultMutableTreeNode root = new DefaultMutableTreeNode( "<html>This is<p>the root node.</html>" );
              DefaultMutableTreeNode node = new DefaultMutableTreeNode( "<html>This is<p>a child node.<html>" );
              root.add( node );
              tree = new JTree( root );
              setLayout( new BorderLayout() );
              JScrollPane scrollPane = new JScrollPane( tree );
              add( scrollPane, BorderLayout.CENTER );
              setSize( 200, 200 );
              setVisible( true );
    }

  • Groupable + multiline table header paint problem

    hi, i try to make a groupable + multiline table header
    based on Nobuo Tamesama's code...
    there are some problems which i considered tolerable except one...
    the header didn't paint correctly when i set the autoResizeMode into autoresizemode_off
    and resize the columns pass the scrollpane width...
    thx in advance
    here's the complete code :
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.util.*;
    import javax.swing.border.*;
    import javax.swing.plaf.basic.*;
    public class GroupableHeaderExample extends JFrame {
        GroupableHeaderExample() {
            super("Groupable Header Example");
            JScrollPane sp = new JScrollPane();
            Object[][] data = {{"b1k1", "b1k2", "b1k3", "b1k4", "b1k5"}, {"b2k1", "b2k2", "b2k3", "b2k4", "b2k5"}};
            JTable table = new JTable(new DefaultTableModel(data, new Object[]{"Kol1", "Kol2\nmmm", "Kol3", "kol4\nmmm\nnnn", " \n \nKol5\nmmm"})) {
                protected JTableHeader createDefaultTableHeader() {
                    return new GroupableTableHeader(columnModel);
            table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            ColumnGroup cg = new ColumnGroup("CG", 0, 3);
            ColumnGroup cg2 = new ColumnGroup("CG2\nmmm", 1, 3);
            ColumnGroup cg3 = new ColumnGroup("CG3", 1, 2);
            GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader();
            header.addColumnGroup(cg3);
            header.addColumnGroup(cg);
            header.addColumnGroup(cg2);
            header.fitHeight();
            sp.setViewportView(table);
            getContentPane().add(sp);
            setSize(400, 300);  
        public static void main(String[] args) {
            GroupableHeaderExample frame = new GroupableHeaderExample();
            frame.addWindowListener( new WindowAdapter() {
                public void windowClosing( WindowEvent e ) {
                    System.exit(0);
            frame.setVisible(true);
    class GroupableTableHeader extends JTableHeader {
        private Vector<ColumnGroup> columnGroups = new Vector<ColumnGroup>(1, 1);
        public GroupableTableHeader(TableColumnModel model) {
            super(model);
            setUI(new GroupableTableHeaderUI());
            setReorderingAllowed(false);
        public void addColumnGroup(ColumnGroup cg) {
            if(columnGroups.size() == 0) {
                columnGroups.addElement(cg);
                return;
            int size = columnGroups.size();
            for(int i = 0; i < size; i++) {
                if(cg.getLength() > ((ColumnGroup)columnGroups.elementAt(i)).getLength())
                    columnGroups.insertElementAt(cg, i);
                else {
                    if(i == size - 1)
                        columnGroups.addElement(cg);           
        public void fitHeight() {
            int[] counter = new int[getTable().getColumnCount()];
            for(int i = 0; i < getTable().getColumnCount(); i++) {
                int level = 0;
                for(int j = 0; j < columnGroups.size(); j++) {
                    if(i >= ((ColumnGroup)columnGroups.elementAt(j)).getStartIndex() && i <= ((ColumnGroup)columnGroups.elementAt(j)).getEndIndex())
                        level = level + getNewLineCount(((ColumnGroup)columnGroups.elementAt(j)).getText());
                counter[i] = level + getNewLineCount(table.getColumnModel().getColumn(i).getHeaderValue().toString());
            int maxCounter = counter[0];
            for(int i = 0; i < counter.length; i++) {
                if(counter[i] > maxCounter)
                    maxCounter = counter;
    setPreferredSize(new Dimension(100, (maxCounter) * 20));
    public Vector getColumnGroups() {
    return columnGroups;
    public int getNewLineCount(String str) {
    BufferedReader br = new BufferedReader(new StringReader(str));
    String line;
    Vector<String> v = new Vector<String>(1, 1);
    try {           
    while((line = br.readLine()) != null) {
    v.addElement(line);
    catch(IOException ex) {
    JOptionPane.showMessageDialog(null, ex.getMessage(), "Informasi", JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
    int i = 0;
    boolean b = false;
    for(i = 0; i < v.size(); i++) {
    for(int j = 0; j < v.elementAt(i).length(); j++) {
    if(v.elementAt(i).charAt(j) != ' ') {
    b = true;
    break;
    if(b)
    break;
    if(i == v.size())
    i = 0;
    return v.size() - i;
    public void updateUI(){
    setUI(new GroupableTableHeaderUI());
    class GroupableTableHeaderUI extends BasicTableHeaderUI {     
    public void paint(Graphics g, JComponent c) {
    TableCellRenderer renderer = new MultiLineHeaderRendererEx();
    Component[] cmp = new Component[header.getColumnModel().getColumnCount()];
    Vector cg = ((GroupableTableHeader)header).getColumnGroups();
    Component[] cmpGroup = new Component[cg.size()];
    TableColumnModel tcm = header.getTable().getColumnModel();
    for(int i = 0; i < cmpGroup.length; i++) {
    cmpGroup[i] = renderer.getTableCellRendererComponent(header.getTable(), ((ColumnGroup)cg.elementAt(i)).getText(), false, false, -1, i);
    rendererPane.add(cmpGroup[i]);
    int x = 0;
    int y = 0;
    int height = 20 * ((GroupableTableHeader)header).getNewLineCount(((ColumnGroup)cg.elementAt(i)).getText());
    for(int j = 0; j < ((ColumnGroup)cg.elementAt(i)).getStartIndex(); j++)
    x += tcm.getColumn(j).getWidth();
    for(int j = 0; j < cmpGroup.length; j++) {
    if(i == j)
    continue;
    if(((ColumnGroup)cg.elementAt(i)).getStartIndex() >= ((ColumnGroup)cg.elementAt(j)).getStartIndex() && ((ColumnGroup)cg.elementAt(i)).getEndIndex() <= ((ColumnGroup)cg.elementAt(j)).getEndIndex())
    y = ((ColumnGroup)cg.elementAt(j)).getY() + ((ColumnGroup)cg.elementAt(j)).getHeight();
    ((ColumnGroup)cg.elementAt(i)).setY(y);
    ((ColumnGroup)cg.elementAt(i)).setHeight(height);
    int width = 0;
    for(int j = ((ColumnGroup)cg.elementAt(i)).getStartIndex(); j <= ((ColumnGroup)cg.elementAt(i)).getEndIndex(); j++)
    width += tcm.getColumn(j).getWidth();
    rendererPane.add(cmpGroup[i]);
    rendererPane.paintComponent(g, cmpGroup[i], header, x, y, width, height, true);
    for(int i = 0; i < cmp.length; i++) {
    cmp[i] = renderer.getTableCellRendererComponent(header.getTable(), header.getColumnModel().getColumn(i).getHeaderValue(), false, false, -1, i);
    rendererPane.add(cmp[i]);
    int x = 0;
    int y = 0;
    for(int j = 0; j < i; j++)
    x += tcm.getColumn(j).getWidth();
    for(int j = 0; j < cmpGroup.length; j++) {
    if(i >= ((ColumnGroup)cg.elementAt(j)).getStartIndex() && i <= ((ColumnGroup)cg.elementAt(j)).getEndIndex())
    y = ((ColumnGroup)cg.elementAt(j)).getY() + ((ColumnGroup)cg.elementAt(j)).getHeight();
    rendererPane.add(cmp[i]);
    rendererPane.paintComponent(g, cmp[i], header, x, y, tcm.getColumn(i).getWidth(), (header.getPreferredSize().height - y), true);
    class MultiLineHeaderRendererEx extends JList implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    if(((GroupableTableHeader)table.getTableHeader()).getNewLineCount(value.toString()) == 1) {
    JLabel header = new JLabel();
    header.setForeground(table.getTableHeader().getForeground());
    header.setBackground(table.getTableHeader().getBackground());
    header.setFont(table.getTableHeader().getFont());
    header.setHorizontalAlignment(JLabel.CENTER);
    header.setText(value.toString());
    header.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    return header;
    else {
    setOpaque(true);
    setForeground(UIManager.getColor("TableHeader.foreground"));
    setBackground(UIManager.getColor("TableHeader.background"));
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    setFont(UIManager.getFont("TableHeader.font"));
    ListCellRenderer renderer = getCellRenderer();
    ((JLabel)renderer).setHorizontalAlignment(SwingConstants.CENTER);
    setCellRenderer(renderer);
    String str = value.toString();
    BufferedReader br = new BufferedReader(new StringReader(str));
    String line;
    Vector<String> v = new Vector<String>(1, 1);
    try {           
    while((line = br.readLine()) != null) {
    v.addElement(line);
    catch(IOException ex) {
    JOptionPane.showMessageDialog(null, ex.getMessage(), "Informasi", JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
    setListData(v);
    return this;

    OMG ! the code i posted before is incomplete
    sorry...
    here's the complete one, pls help :
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.util.*;
    import javax.swing.border.*;
    import javax.swing.plaf.basic.*;
    public class GroupableHeaderExample extends JFrame {
        GroupableHeaderExample() {
            super("Groupable Header Example");
            JScrollPane sp = new JScrollPane();
            Object[][] data = {{"b1k1", "b1k2", "b1k3", "b1k4", "b1k5"}, {"b2k1", "b2k2", "b2k3", "b2k4", "b2k5"}};
            JTable table = new JTable(new DefaultTableModel(data, new Object[]{"Kol1", "Kol2\nmmm", "Kol3", "kol4\nmmm\nnnn", "Kol5\nmmm"})) {
                protected JTableHeader createDefaultTableHeader() {
                    return new GroupableTableHeader(columnModel);
            table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            ColumnGroup cg = new ColumnGroup("CG", 0, 4);
            ColumnGroup cg2 = new ColumnGroup("CG2\nmmm", 1, 4);
            ColumnGroup cg3 = new ColumnGroup("CG3", 1, 2);
            ColumnGroup cg4 = new ColumnGroup("CG4", 3, 4);
            GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader();
            header.addColumnGroup(cg4);
            header.addColumnGroup(cg2);
            header.addColumnGroup(cg3);
            header.addColumnGroup(cg);
            header.fitHeight();
            sp.setViewportView(table);
            getContentPane().add(sp);
            setSize(400, 300);  
        public static void main(String[] args) {
            GroupableHeaderExample frame = new GroupableHeaderExample();
            frame.addWindowListener( new WindowAdapter() {
                public void windowClosing( WindowEvent e ) {
                    System.exit(0);
            frame.setVisible(true);
    class GroupableTableHeader extends JTableHeader {
        private Vector<ColumnGroup> columnGroups = new Vector<ColumnGroup>(1, 1);
        public GroupableTableHeader(TableColumnModel model) {
            super(model);
            setUI(new GroupableTableHeaderUI());
            setReorderingAllowed(false);
        public void addColumnGroup(ColumnGroup cg) {
            if(columnGroups.size() == 0) {
                columnGroups.addElement(cg);
                return;
            int size = columnGroups.size();
            for(int i = 0; i < size; i++) {
                if(cg.getLength() > ((ColumnGroup)columnGroups.elementAt(i)).getLength()) {
                    columnGroups.insertElementAt(cg, i);
                    break;
                else {
                    if(i == size - 1)
                        columnGroups.addElement(cg);           
        public void fitHeight() {
            int[] counter = new int[getTable().getColumnCount()];
            for(int i = 0; i < getTable().getColumnCount(); i++) {
                int level = 0;
                for(int j = 0; j < columnGroups.size(); j++) {
                    if(i >= ((ColumnGroup)columnGroups.elementAt(j)).getStartIndex() && i <= ((ColumnGroup)columnGroups.elementAt(j)).getEndIndex())
                        level = level + getNewLineCount(((ColumnGroup)columnGroups.elementAt(j)).getText());
                counter[i] = level + getNewLineCount(table.getColumnModel().getColumn(i).getHeaderValue().toString());
            int maxCounter = counter[0];
            for(int i = 0; i < counter.length; i++) {
                if(counter[i] > maxCounter)
                    maxCounter = counter;
    setPreferredSize(new Dimension(100, (maxCounter) * 20));
    public Vector getColumnGroups() {
    return columnGroups;
    public int getNewLineCount(String str) {
    BufferedReader br = new BufferedReader(new StringReader(str));
    String line;
    Vector<String> v = new Vector<String>(1, 1);
    try {           
    while((line = br.readLine()) != null) {
    v.addElement(line);
    catch(IOException ex) {
    JOptionPane.showMessageDialog(null, ex.getMessage(), "Informasi", JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
    int i = 0;
    boolean b = false;
    for(i = 0; i < v.size(); i++) {
    for(int j = 0; j < v.elementAt(i).length(); j++) {
    if(v.elementAt(i).charAt(j) != ' ') {
    b = true;
    break;
    if(b)
    break;
    if(i == v.size())
    i = 0;
    return v.size() - i;
    public void updateUI(){
    setUI(new GroupableTableHeaderUI());
    class GroupableTableHeaderUI extends BasicTableHeaderUI {     
    public void paint(Graphics g, JComponent c) {
    TableCellRenderer renderer = new MultiLineHeaderRendererEx();
    Component[] cmp = new Component[header.getColumnModel().getColumnCount()];
    Vector cg = ((GroupableTableHeader)header).getColumnGroups();
    Component[] cmpGroup = new Component[cg.size()];
    TableColumnModel tcm = header.getTable().getColumnModel();
    for(int i = 0; i < cmpGroup.length; i++) {
    cmpGroup[i] = renderer.getTableCellRendererComponent(header.getTable(), ((ColumnGroup)cg.elementAt(i)).getText(), false, false, -1, i);
    int x = 0;
    int y = 0;
    int height = 20 * ((GroupableTableHeader)header).getNewLineCount(((ColumnGroup)cg.elementAt(i)).getText());
    for(int j = 0; j < ((ColumnGroup)cg.elementAt(i)).getStartIndex(); j++)
    x += tcm.getColumn(j).getWidth();
    for(int j = 0; j < cmpGroup.length; j++) {
    if(i == j)
    continue;
    if(((ColumnGroup)cg.elementAt(i)).getStartIndex() >= ((ColumnGroup)cg.elementAt(j)).getStartIndex() && ((ColumnGroup)cg.elementAt(i)).getEndIndex() <= ((ColumnGroup)cg.elementAt(j)).getEndIndex())
    y = ((ColumnGroup)cg.elementAt(j)).getY() + ((ColumnGroup)cg.elementAt(j)).getHeight();
    ((ColumnGroup)cg.elementAt(i)).setY(y);
    ((ColumnGroup)cg.elementAt(i)).setHeight(height);
    int width = 0;
    for(int j = ((ColumnGroup)cg.elementAt(i)).getStartIndex(); j <= ((ColumnGroup)cg.elementAt(i)).getEndIndex(); j++)
    width += tcm.getColumn(j).getWidth();
    rendererPane.add(cmpGroup[i]);
    rendererPane.paintComponent(g, cmpGroup[i], header, x, y, width, height, true);
    for(int i = 0; i < cmp.length; i++) {
    cmp[i] = renderer.getTableCellRendererComponent(header.getTable(), header.getColumnModel().getColumn(i).getHeaderValue(), false, false, -1, i);
    int x = 0;
    int y = 0;
    for(int j = 0; j < i; j++)
    x += tcm.getColumn(j).getWidth();
    for(int j = 0; j < cmpGroup.length; j++) {
    if(i >= ((ColumnGroup)cg.elementAt(j)).getStartIndex() && i <= ((ColumnGroup)cg.elementAt(j)).getEndIndex())
    y = ((ColumnGroup)cg.elementAt(j)).getY() + ((ColumnGroup)cg.elementAt(j)).getHeight();
    rendererPane.add(cmp[i]);
    rendererPane.paintComponent(g, cmp[i], header, x, y, tcm.getColumn(i).getWidth(), (header.getPreferredSize().height - y), true);
    class MultiLineHeaderRendererEx extends JList implements TableCellRenderer {
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    if(((GroupableTableHeader)table.getTableHeader()).getNewLineCount(value.toString()) == 1) {
    JLabel header = new JLabel();
    header.setForeground(table.getTableHeader().getForeground());
    header.setBackground(table.getTableHeader().getBackground());
    header.setFont(table.getTableHeader().getFont());
    header.setHorizontalAlignment(JLabel.CENTER);
    header.setText(value.toString());
    header.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    return header;
    else {
    setOpaque(true);
    setForeground(UIManager.getColor("TableHeader.foreground"));
    setBackground(UIManager.getColor("TableHeader.background"));
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    setFont(UIManager.getFont("TableHeader.font"));
    ListCellRenderer renderer = getCellRenderer();
    ((JLabel)renderer).setHorizontalAlignment(SwingConstants.CENTER);
    setCellRenderer(renderer);
    String str = value.toString();
    BufferedReader br = new BufferedReader(new StringReader(str));
    String line;
    Vector<String> v = new Vector<String>(1, 1);
    try {           
    while((line = br.readLine()) != null) {
    v.addElement(line);
    catch(IOException ex) {
    JOptionPane.showMessageDialog(null, ex.getMessage(), "Informasi", JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
    setListData(v);
    return this;
    class ColumnGroup {
    private String text;
    private int startIndex, endIndex, y, height;
    public ColumnGroup(String text, int startIndex, int endIndex) {
    this.text = text;
    this.startIndex = startIndex;
    this.endIndex = endIndex;
    public int getEndIndex() {
    return endIndex;
    public int getHeight() {
    return height;
    public int getLength() {
    return endIndex - startIndex;
    public int getStartIndex() {
    return startIndex;
    public String getText() {
    return text;
    public int getY() {
    return y;
    public void setHeight(int height) {
    this.height = height;
    public void setY(int y) {
    this.y = y;

  • JTable - Groupable/Multiline Header

    Hi Everybody,
    I found this code to create a groupable/multiline header for a JTable. It seems to be working fine with JDK 1.1 and we are using 1.4 now. I keep getting 2 errors with the GroupableTableHeaderUI class and has been busy the whole weekend trying to fix it, with no success. Can someone please help? Thanks. Here is the code:
    * |-----------------------------------------------------|
    * | | Name | Language |
    * | |-----------------|--------------------------|
    * | SNo. | | | | Others |
    * | | 1 | 2 | Native |-----------------|
    * | | | | | 2 | 3 |
    * |-----------------------------------------------------|
    * | | | | | | |
    package tableheader;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import swing.table.*;
    public class GroupableHeaderExample extends JFrame {
    GroupableHeaderExample() {
    super( "Groupable Header Example" );
    DefaultTableModel dm = new DefaultTableModel();
    dm.setDataVector(new Object[][]{
    {"119","foo","bar","ja","ko","zh"},
    {"911","bar","foo","en","fr","pt"}},
    new Object[]{"SNo.","1","2","Native","2","3"});
    JTable table = new JTable( dm ) {
    protected JTableHeader createDefaultTableHeader() {
         return new GroupableTableHeader(columnModel);
    TableColumnModel cm = table.getColumnModel();
    ColumnGroup g_name = new ColumnGroup("Name");
    g_name.add(cm.getColumn(1));
    g_name.add(cm.getColumn(2));
    ColumnGroup g_lang = new ColumnGroup("Language");
    g_lang.add(cm.getColumn(3));
    ColumnGroup g_other = new ColumnGroup("Others");
    g_other.add(cm.getColumn(4));
    g_other.add(cm.getColumn(5));
    g_lang.add(g_other);
    GroupableTableHeader header = (GroupableTableHeader)table.getTableHeader();
    header.addColumnGroup(g_name);
    header.addColumnGroup(g_lang);
    JScrollPane scroll = new JScrollPane( table );
    getContentPane().add( scroll );
    setSize( 400, 120 );
    public static void main(String[] args) {
    GroupableHeaderExample frame = new GroupableHeaderExample();
    frame.addWindowListener( new WindowAdapter() {
    public void windowClosing( WindowEvent e ) {
         System.exit(0);
    frame.setVisible(true);
    package swing.table;
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class GroupableTableHeader extends JTableHeader {
    private static final String uiClassID = "GroupableTableHeaderUI";
    protected Vector columnGroups = null;
    public GroupableTableHeader(TableColumnModel model) {
    super(model);
    setUI(new GroupableTableHeaderUI());
    setReorderingAllowed(false);
    public void setReorderingAllowed(boolean b) {
    reorderingAllowed = false;
    public void addColumnGroup(ColumnGroup g) {
    if (columnGroups == null) {
    columnGroups = new Vector();
    columnGroups.addElement(g);
    public Enumeration getColumnGroups(TableColumn col) {
    if (columnGroups == null) return null;
    Enumeration enum = columnGroups.elements();
    while (enum.hasMoreElements()) {
    ColumnGroup cGroup = (ColumnGroup)enum.nextElement();
    Vector v_ret = (Vector)cGroup.getColumnGroups(col,new Vector());
    if (v_ret != null) {
         return v_ret.elements();
    return null;
    public void setColumnMargin() {
    if (columnGroups == null) return;
    int columnMargin = getColumnModel().getColumnMargin();
    Enumeration enum = columnGroups.elements();
    while (enum.hasMoreElements()) {
    ColumnGroup cGroup = (ColumnGroup)enum.nextElement();
    cGroup.setColumnMargin(columnMargin);
    package swing.table;
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.plaf.basic.*;
    public class GroupableTableHeaderUI extends BasicTableHeaderUI {
    public void paint(Graphics g, JComponent c) {
    Rectangle clipBounds = g.getClipBounds();
    if (header.getColumnModel() == null) return;
    ((GroupableTableHeader)header).setColumnMargin();
    int column = 0;
    Dimension size = header.getSize();
    Rectangle cellRect = new Rectangle(0, 0, size.width, size.height);
    Hashtable h = new Hashtable();
    int columnMargin = header.getColumnModel().getColumnMargin();
    Enumeration enumeration = header.getColumnModel().getColumns();
    while (enumeration.hasMoreElements()) {
    cellRect.height = size.height;
    cellRect.y = 0;
    TableColumn aColumn = (TableColumn)enumeration.nextElement();
    Enumeration cGroups = ((GroupableTableHeader)header).getColumnGroups(aColumn);
    if (cGroups != null) {
    int groupHeight = 0;
    while (cGroups.hasMoreElements()) {
    ColumnGroup cGroup = (ColumnGroup)cGroups.nextElement();
    Rectangle groupRect = (Rectangle)h.get(cGroup);
    if (groupRect == null) {
    groupRect = new Rectangle(cellRect);
    Dimension d = cGroup.getSize(header.getTable());
    groupRect.width = d.width;
    groupRect.height = d.height;
    h.put(cGroup, groupRect);
    paintCell(g, groupRect, cGroup);
    groupHeight += groupRect.height;
    cellRect.height = size.height - groupHeight;
    cellRect.y = groupHeight;
    cellRect.width = aColumn.getWidth() + columnMargin;
    if (cellRect.intersects(clipBounds)) {
    paintCell(g, cellRect, column);
    cellRect.x += cellRect.width;
    column++;
    private void paintCell(Graphics g, Rectangle cellRect, int columnIndex) {
    TableColumn aColumn = header.getColumnModel().getColumn(columnIndex);
    TableCellRenderer renderer = aColumn.getHeaderRenderer();
    Component component = renderer.getTableCellRendererComponent(
    header.getTable(), aColumn.getHeaderValue(),false, false, -1, columnIndex);
    rendererPane.add(component);
    rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y,
                        cellRect.width, cellRect.height, true);
    private void paintCell(Graphics g, Rectangle cellRect,ColumnGroup cGroup) {
    TableCellRenderer renderer = cGroup.getHeaderRenderer();
    Component component = renderer.getTableCellRendererComponent(
    header.getTable(), cGroup.getHeaderValue(),false, false, -1, -1);
    rendererPane.add(component);
    rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y,
                        cellRect.width, cellRect.height, true);
    private int getHeaderHeight() {
    int height = 0;
    TableColumnModel columnModel = header.getColumnModel();
    for(int column = 0; column < columnModel.getColumnCount(); column++) {
    TableColumn aColumn = columnModel.getColumn(column);
    TableCellRenderer renderer = aColumn.getHeaderRenderer();
    Component comp = renderer.getTableCellRendererComponent(
    header.getTable(), aColumn.getHeaderValue(), false, false,-1, column);
    int cHeight = comp.getPreferredSize().height;
    Enumeration enum = ((GroupableTableHeader)header).getColumnGroups(aColumn);
    if (enum != null) {
    while (enum.hasMoreElements()) {
    ColumnGroup cGroup = (ColumnGroup)enum.nextElement();
    cHeight += cGroup.getSize(header.getTable()).height;
    height = Math.max(height, cHeight);
    return height;
    private Dimension createHeaderSize(long width) {
    TableColumnModel columnModel = header.getColumnModel();
    width += columnModel.getColumnMargin() * columnModel.getColumnCount();
    if (width > Integer.MAX_VALUE) {
    width = Integer.MAX_VALUE;
    return new Dimension((int)width, getHeaderHeight());
    public Dimension getPreferredSize(JComponent c) {
    long width = 0;
    Enumeration enumeration = header.getColumnModel().getColumns();
    while (enumeration.hasMoreElements()) {
    TableColumn aColumn = (TableColumn)enumeration.nextElement();
    width = width + aColumn.getPreferredWidth();
    return createHeaderSize(width);
    package swing.table;
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class ColumnGroup {
    protected TableCellRenderer renderer;
    protected Vector v;
    protected String text;
    protected int margin=0;
    public ColumnGroup(String text) {
    this(null,text);
    public ColumnGroup(TableCellRenderer renderer,String text) {
    if (renderer == null) {
    this.renderer = new DefaultTableCellRenderer() {
         public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
         JTableHeader header = table.getTableHeader();
         if (header != null) {
         setForeground(header.getForeground());
         setBackground(header.getBackground());
         setFont(header.getFont());
    setHorizontalAlignment(JLabel.CENTER);
    setText((value == null) ? "" : value.toString());
         setBorder(UIManager.getBorder("TableHeader.cellBorder"));
         return this;
    } else {
    this.renderer = renderer;
    this.text = text;
    v = new Vector();
    * @param obj TableColumn or ColumnGroup
    public void add(Object obj) {
    if (obj == null) { return; }
    v.addElement(obj);
    * @param c TableColumn
    * @param v ColumnGroups
    public Vector getColumnGroups(TableColumn c, Vector g) {
    g.addElement(this);
    if (v.contains(c)) return g;
    Enumeration enum = v.elements();
    while (enum.hasMoreElements()) {
    Object obj = enum.nextElement();
    if (obj instanceof ColumnGroup) {
    Vector groups =
    (Vector)((ColumnGroup)obj).getColumnGroups(c,(Vector)g.clone());
    if (groups != null) return groups;
    return null;
    public TableCellRenderer getHeaderRenderer() {
    return renderer;
    public void setHeaderRenderer(TableCellRenderer renderer) {
    if (renderer != null) {
    this.renderer = renderer;
    public Object getHeaderValue() {
    return text;
    public Dimension getSize(JTable table) {
    Component comp = renderer.getTableCellRendererComponent(
    table, getHeaderValue(), false, false,-1, -1);
    int height = comp.getPreferredSize().height;
    int width = 0;
    Enumeration enum = v.elements();
    while (enum.hasMoreElements()) {
    Object obj = enum.nextElement();
    if (obj instanceof TableColumn) {
    TableColumn aColumn = (TableColumn)obj;
    width += aColumn.getWidth();
    width += margin;
    } else {
    width += ((ColumnGroup)obj).getSize(table).width;
    return new Dimension(width, height);
    public void setColumnMargin(int margin) {
    this.margin = margin;
    Enumeration enum = v.elements();
    while (enum.hasMoreElements()) {
    Object obj = enum.nextElement();
    if (obj instanceof ColumnGroup) {
    ((ColumnGroup)obj).setColumnMargin(margin);

    in GroupableTableHeaderUI class replace "aColumn.getHeaderRenderer();" by "header.getDefaultRenderer ();" and try again..
    this should solve ur problem ..
    Indranil

  • Returning strings to JLabel

    I'm making a program which included returning abstract string from the other class to the label. It works good, but the only problem is that the string is always displayed in one line in the label. I use the correct command to make a multiline string and it works perfectly when I implement the string alone in a test program, but when I return it to the label it again displays in single line. Any advices on this one ?

    A JLabel always displays as a single line of text (unless you use HTML),
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Japanese characters in JEditorPane HTML

    We have an application that displays HTML in a JEditorPane to take advantage of the font changes. The string starts off with <html><body><font face='Dialog' size='-1'><b>One of our translation testers is complaining that some of the Japanese characters look "jaggy" (I think because they look like italics to me). However, most of the Japanese characters in the same field look fine (albiet bold). At no point in the string to I switch to italic, in fact everything in this case is bold.
    We don't seem to have this problem anywhere else in our UI with traditional JLabels, JOptionPanes, etc. Is there something querky about JEditorPane and/or HTML rendering, the mapping of the Dialog font, or something? Any suggestions on anything else to check.

    Hi David, yes 'Content-type: text/html; charset=utf-8' is in
    the header...
    Thanks for the note on the poor Japanese translations,
    someone else is
    proofing it now.
    J
    "David Powers" <[email protected]> wrote in message
    news:epvh06$dq6$[email protected]..
    > James Noon wrote:
    > > My web app sends confirmation emails to customers
    in multiple languages,
    all
    > > work fine apart from Japanese which display all as
    ? on the email.
    > >
    > > Part of of my email code is formatted as this (ie
    sending as utf-8)
    >
    > What is the Content-type header of the email?
    >
    > It needs to be 'Content-type: text/html; charset=utf-8'.
    >
    > This needs to be sent as an email header, not just in
    the body of the
    HTML.
    >
    > --
    > David Powers, Adobe Community Expert
    > Author, "Foundation PHP for Dreamweaver 8" (friends of
    ED)
    > Author, "PHP Solutions" (friends of ED)
    >
    http://foundationphp.com/

Maybe you are looking for

  • Xml slideshow controls, need help!

    Hello, I am new to actionscript and am trying to make a slideshow with next and previous controls. The info for the slideshow is coming via xml. I have it up and running but there are two issues. When clicking on the next or previous buttons the new

  • Restoring Mac Book Pro

    Im restoring my Macbook pro retina after i backup the hardrive to timemachine, but i was wondering if i have to reinstall Mountain lion before i can reistall the time machine data?

  • When opening Mail, sending mail won't stop searching?

    When I open mail App. On my MBP, running Lion mail loads all my accounts fine, but sending mail doesn't stop searching for sbcglobal.net account. Therefor can't send any mail from any accounts.

  • Im keep loosing wifi on my iPad2 while I'm playing games or other application

    I'm keep loosing wifi connection while I'm using my iPad by playing games and using other application and I need to join my wifi network again

  • What are the symptoms of a failing fusion drive?

    My 2012 iMac with a 3 TB fusion drive is suddenly behaving erratically.  What are the symptoms of a failing fusion drive? I'm experiencing random freeze, sluggish performance, and long boot ups with an occasional universal "NO" icon at boot. I have A