Changeset 4381

Show
Ignore:
Timestamp:
01/11/08 00:46:48 (5 years ago)
Author:
nori090
Message:

lang/java/lib2chj: JTree test

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/java/lib2chj/trunk/lib2chj/src/main/java/lib2chj/SimpleGUI.java

    • Property svn:keywords set to LastChangedDate LastChangedRevision
    r4237 r4381  
    3838import javax.swing.JList; 
    3939import javax.swing.JScrollPane; 
     40import javax.swing.JTree; 
    4041import javax.swing.UIManager; 
    4142import javax.swing.border.Border; 
     
    5960public class SimpleGUI 
    6061    extends JFrame { 
     62 
     63    private JTree menutree; 
     64 
    6165    private JList menulist; 
    6266 
     
    8286        throws HeadlessException { 
    8387        super(); 
     88 
     89        menutree = new JTree( menu.toArray() ) { 
     90            @Override 
     91            public String convertValueToText( Object value, boolean selected, boolean expanded, boolean leaf, int row, 
     92                                              boolean hasFocus ) { 
     93                if ( value != null ) { 
     94                    if ( value instanceof DynamicUtilTreeNode ) { 
     95                        DynamicUtilTreeNode node = (DynamicUtilTreeNode) value; 
     96                        Object text = null; 
     97                        try { 
     98                            Object target = node.getUserObject(); 
     99                            Method m = target.getClass().getMethod( "view" ); 
     100                            text = m.invoke( target ); 
     101                        } 
     102                        catch ( Exception e ) { 
     103                            e.printStackTrace(); 
     104                        } 
     105                        if ( text == null ) { 
     106                            return ( ( value == null ) ? "" : value.toString() ); 
     107                        } 
     108                        else { 
     109                            return ( text.toString() ); 
     110                        } 
     111                    } 
     112                    else { 
     113                        return value.toString(); 
     114                    } 
     115                } 
     116                else { 
     117                    return ""; 
     118                } 
     119            } 
     120        }; 
    84121 
    85122        menulist = new JList( menu.toArray() ); 
     
    188225        subjectlist.addMouseListener( mouseListener3 ); 
    189226 
     227        menutree.setFont( new Font( "Serif", Font.PLAIN, 12 ) ); 
    190228        menulist.setFont( new Font( "Serif", Font.PLAIN, 12 ) ); 
    191229        italist.setFont( new Font( "Serif", Font.PLAIN, 12 ) ); 
     
    193231        commentlist.setFont( new Font( "MS ゴシック", Font.PLAIN, 12 ) ); 
    194232 
     233        this.add( menutree, BorderLayout.NORTH ); 
    195234        this.add( menulist, BorderLayout.WEST ); 
    196235        this.add( italist, BorderLayout.CENTER ); 
     
    209248        JScrollPane scroll4 = new JScrollPane( commentlist ); 
    210249        this.add( scroll4, BorderLayout.SOUTH ); 
     250 
     251        JScrollPane scroll5 = new JScrollPane( menutree ); 
     252        this.add( scroll5, BorderLayout.NORTH ); 
    211253 
    212254        this.setSize( new Dimension( 800, 600 ) );