コード例 #1
0
ファイル: StyledLabelExample.java プロジェクト: wjase/cntools
  public static void main(String[] args) {
    try {
      WoodLookAndFeel.setUI();
      System.out.println(System.getProperty("java.class.path"));
      // SystemLook.set();
      ShapedPanel jp = new ShapedPanel();
      jp.setBackgroundPainter(
          new ImageFillEffect(
              ImageLoader.loadBufferedImage(
                  ResourcesRoot.getResource("gui/images/tiles/walnut.png"))));

      StyledLabel sl = new StyledLabel("This is italic semi-opaque", StyledLabel.ITALIC);
      sl.setPaintEffect(new CompositeAdjust(0.6));
      sl.setBackground(Color.black);
      sl.setForeground(Color.white);
      sl.setOpaque(true);

      jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
      jp.add(new StyledLabel("This is bold", StyledLabel.BOLD));
      jp.add(new StyledLabel("This is normal", StyledLabel.NORMAL));
      jp.add(new StyledLabel("This is grey", StyledLabel.GREY));
      jp.add(new StyledLabel("This is italic", StyledLabel.ITALIC));
      jp.add(sl);

      JFrame jf = new JFrame("StyledLabel test");
      jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      jf.getContentPane().add(jp);
      jf.setVisible(true);
      jf.pack();
    } catch (IOException ex) {
      Logger.getLogger(StyledLabelExample.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
コード例 #2
0
  public static void main(String[] a) {
    // System.out.printf("start\n");
    WoodLookAndFeel.setUI();
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    try {
      Thread.sleep(600);
    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    final FileSystemPanel fsp = new FileSystemPanel();
    frame.add(fsp);
    // fsp.selectPath( "C:\\data\\java" );

    // System.out.println( "selectd path is now " +
    // fsp.getSelectedPathText() );

    frame.setSize(300, 200);
    frame.setVisible(true);

    fsp.getTree()
        .addTreeSelectionListener(
            new TreeSelectionListener() {

              @Override
              public void valueChanged(TreeSelectionEvent e) {
                TreePath tp = e.getNewLeadSelectionPath();
                if (tp != null) {
                  // System.out.println( tp.getLastPathComponent().toString()
                  // );
                  String[] kids = fsp.getCurrentChildren("");
                  if (kids != null) {
                    for (String eachKid : kids) {
                      // System.out.println( eachKid );
                    }
                  }
                }
              }
            });
  }