CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Java >  Eclipse

JBuider9 项目转移到 Eclipse 中出错.请教!

楼主yaoyuan200(遥远)2005-05-03 20:13:36 在 Java / Eclipse 提问

import   com.borland.jbcl.layout.*;    
  出错   Eclipse   好象没有这个功能  
  如何解决啊  
  import   datechooser.DateChooser;  
  出错  
  如何解决啊  
   
  如上两个基本错误导致程序很多布局出错!  
  如何解决啊,请教高手!  
   
   
  问题点数:0、回复次数:3Top

1 楼wu_bjcn(咖啡的味道)回复于 2005-05-04 14:24:32 得分 0

你大概是用了Borland的VerticalFlowLayout吧?没有好的办法,必须把你Import的类给加过来。  
   
   
  我也遇到过类似的问题,那时,自己动手改了一下Sun   JDK中的FlowLayout,改成了竖排版的(也就是VerticalFlowLayout),代码如下,希望对你有帮助:  
   
  import   java.awt.Component;  
  import   java.awt.Container;  
  import   java.awt.Dimension;  
  import   java.awt.Insets;  
  import   java.awt.LayoutManager;  
   
  public   class   VerticalFlowLayout   implements   LayoutManager   {  
  /**  
            *   This   value   indicates   that   each   row   of   components   should   be   left-justified.  
            */  
  public   static   final   int   LEFT   =   0;  
   
  /**  
            *   This   value   indicates   that   each   row   of   components   should   be   center-justified.  
            */  
  public   static   final   int   CENTER   =   1;  
   
  /**  
            *   This   value   indicates   that   each   row   of   components   should   be   right-justified.  
            */  
  public   static   final   int   RIGHT   =   2;  
   
  /**  
            *   <code>align</code>   is   the   property   that   determines    
            *   how   each   row   distributes   empty   space.  
            *   It   can   be   one   of   the   following   values:  
            *   <ul>  
            *   <code>LEFT</code>  
            *   <code>RIGHT</code>  
            *   <code>CENTER</code>  
            *   </ul>  
            */  
  private   int   align;  
   
  /**  
    *   The   vertical   flow   layout   manager   allows   a   seperation   of   components   with  
    *   gaps.   The   horizontal   gap   will   specify   the   space   between   components   and  
    *   between   the   components   and   the   borders   of   the   <code>Container</code>.  
    */  
  private   int   hgap;  
   
  /**  
    *   The   vertical   flow   layout   manager   allows   a   seperation   of   components   with  
    *   gaps.   The   vertical   gap   will   specify   the   space   between   rows   and   between   the  
    *   the   rows   and   the   borders   of   the   <code>Container</code>.  
    */  
  private   int   vgap;  
   
  /**  
            *   Constructs   a   new   <em>VerticalFlowLayout</em>   manager   with   the   indicated    
            *   alignment   and   the   indicated   horizontal   and   vertical   gaps.  
            *   The   value   of   the   alignment   argument   must   be   one   of   below   :  
            *   <p>  
            *   <li>VerticalFlowLayout.LEFT,  
            *   <li>VerticalFlowLayout.RIGHT,  
            *   <li>or   VerticalFlowLayout.CENTER.  
            */  
  public   VerticalFlowLayout(int   align,   int   hgap,   int   vgap)   {  
  this.hgap   =   hgap;  
  this.vgap   =   vgap;  
  setAlignment(align);  
  }  
   
  /**  
            *   Constructs   a   new   <em>VerticalFlowLayout</em>   manager   with   the   specified  
            *   alignment   and   a   default   5-unit   horizontal   and   vertical   gap.  
            *   The   value   of   the   alignment   argument   must   be   one   of   below   :  
            *   <p>  
            *   <li>VerticalFlowLayout.LEFT,    
            *   <li>VerticalFlowLayout.RIGHT,  
            *   <li>or   VerticalFlowLayout.CENTER.  
            */  
  public   VerticalFlowLayout(int   align)   {  
  this(align,   5,   5);  
  }  
   
  /**  
            *   Constructs   a   new   <em>VerticalFlowLayout</em>   with   a   left   alignment   and   a  
            *   default   5-unit   horizontal   and   vertical   gap.  
            */  
  public   VerticalFlowLayout()   {  
  this(LEFT,   5,   5);  
  }Top

2 楼wu_bjcn(咖啡的味道)回复于 2005-05-04 14:25:02 得分 0

/**  
            *   Adds   the   specified   component   to   the   layout.  
            *   Not   used   by   this   class.  
            */  
  public   void   addLayoutComponent(String   name,   Component   comp)   {  
  //   Empty.  
  }  
   
  /**  
            *   Removes   the   specified   component   from   the   layout.  
            *   Not   used   by   this   class.  
            */  
  public   void   removeLayoutComponent(Component   comp)   {  
  //   Empty.  
  }  
   
  /**  
            *   Returns   the   preferred   dimensions   for   this   layout   given   the    
            *   visible   components   in   the   specified   target   container.  
            *    
            *   @param   target   the   container   that   needs   to   be   laid   out  
            *    
            *   @return         the   preferred   dimensions   to   lay   out   the  
            *                         subcomponents   of   the   specified   container  
            */  
  public   Dimension   preferredLayoutSize(Container   target)   {  
  Dimension   dim   =   new   Dimension(0,   0);  
  int   nmembers   =   target.getComponentCount();  
  boolean   firstVisibleComponent   =   true;  
   
  Component   m;  
  Dimension   d;  
  for   (int   i   =   0;   i   <   nmembers;   i++)   {  
  m   =   target.getComponent(i);  
  if   (m.isVisible())   {  
  d   =   m.getPreferredSize();  
  dim.width   =   Math.max(dim.width,   d.width);  
  if   (firstVisibleComponent)  
  firstVisibleComponent   =   false;  
  else  
  dim.height   +=   vgap;  
  dim.height   +=   d.height;  
  }  
  }  
  Insets   insets   =   target.getInsets();  
  dim.width   +=   insets.left   +   insets.right   +   hgap   *   2;  
  dim.height   +=   insets.top   +   insets.bottom   +   vgap   *   2;  
  return   dim;  
  }  
   
  /**  
            *   Returns   the   minimum   dimensions   needed   to   layout   the   visible  
            *   components   contained   in   the   specified   target   container.  
            *    
            *   @param   target   the   container   that   needs   to   be   laid   out  
            *    
            *   @return         the   minimum   dimensions   to   lay   out   the  
            *                         subcomponents   of   the   specified   container  
            */  
  public   Dimension   minimumLayoutSize(Container   target)   {  
  synchronized   (target.getTreeLock())   {  
  Dimension   dim   =   new   Dimension(0,   0);  
  int   nmembers   =   target.getComponentCount();  
   
  Component   m;  
  Dimension   d;  
  for   (int   i   =   0;   i   <   nmembers;   i++)   {  
  m   =   target.getComponent(i);  
  if   (m.isVisible())   {  
  d   =   m.getMinimumSize();  
  dim.width   =   Math.max(dim.width,   d.width);  
  if   (i   >   0)  
  dim.height   +=   vgap;  
  dim.height   +=   d.height;  
  }  
  }  
  Insets   insets   =   target.getInsets();  
  dim.width   +=   insets.left   +   insets.right   +   hgap   *   2;  
  dim.height   +=   insets.top   +   insets.bottom   +   vgap   *   2;  
  return   dim;  
  }  
  }  
   
  /**  
    *   Lays   out   the   container.   This   method   lets   each   visible   component   take    
    *   its   preferred   size   by   reshaping   the   components   in   the   target   container    
    *   in   order   to   satisfy   the   alignment   of   this   VerticalFlowLayout   object.  
    *    
    *   @param   target   the   specified   component   being   laid   out  
    */  
  public   void   layoutContainer(Container   target)   {  
  Insets   insets   =   target.getInsets();  
  int   maxheight   =   target.getHeight()  
  -   (insets.top   +   insets.bottom   +   vgap   *   2);  
  int   nmembers   =   target.getComponentCount();  
  int   x   =   insets.left   +   hgap,   y   =   0;  
  int   roww   =   0,   start   =   0;  
   
  Component   m;  
  Dimension   d;  
  for   (int   i   =   0;   i   <   nmembers;   i++)   {  
  m   =   target.getComponent(i);  
  if   (m.isVisible())   {  
  d   =   m.getPreferredSize();  
  m.setSize(d.width,   d.height);  
   
  if   ((y   ==   0)   ||   ((y   +   d.height)   <=   maxheight))   {  
  if   (y   >   0)  
  y   +=   vgap;  
  y   +=   d.height;  
  roww   =   Math.max(roww,   d.width);  
  }   else   {  
  moveComponents(target,   x,   insets.top   +   vgap,   roww,    
  maxheight   -   y,   start,   i);  
  y   =   d.height;  
  x   +=   hgap   +   roww;  
  roww   =   d.width;  
  start   =   i;  
  }  
  }  
  }  
  moveComponents(target,   x,   insets.top   +   vgap,   roww,   maxheight   -   y,    
  start,   nmembers);  
  }  
   
  /**  
            *   Sets   the   alignment   for   this   layout.  
            *   Possible   values   are  
            *   <ul>  
            *   <li><code>FlowLayout.LEFT</code>  
            *   <li><code>FlowLayout.RIGHT</code>  
            *   <li><code>FlowLayout.CENTER</code>  
            *   </ul>  
            *    
            *   @param   align   one   of   the   alignment   values   shown   above  
            */  
  public   void   setAlignment(int   align)   {  
  this.align   =   align;  
  }  
   
  /**  
            *   Gets   the   alignment   for   this   layout.  
            *    
            *   @return           the   alignment   value   for   this   layout  
            */  
  public   int   getAlignment()   {  
  return   align;  
  }  
   
  /**  
    *   Sets   the   horizontal   gap   between   components   and   between    
    *   the   components   and   the   borders   of   the   Container.  
    *    
    *   @param   hgap   the   horizontal   gap   between   components  
            *                           and   between   the   components   and   the   borders  
            *                           of   the   <code>Container</code>  
    */  
  public   void   setHgap(int   hgap)   {  
  this.hgap   =   hgap;  
  }  
   
  /**  
    *   Gets   the   horizontal   gap   between   components   and   between    
    *   the   components   and   the   borders   of   the   Container.  
    *    
    *   @return           the   horizontal   gap   between   components  
            *                           and   between   the   components   and   the   borders  
            *                           of   the   <code>Container</code>  
    */  
  public   int   getHgap()   {  
  return   hgap;  
  }  
   
  /**  
            *   Sets   the   vertical   gap   between   components   and   between  
            *   the   components   and   the   borders   of   the   Container.  
            *    
            *   @param   vgap   the   vertical   gap   between   components  
            *                           and   between   the   components   and   the   borders  
            *                           of   the   <code>Container</code>  
            */  
  public   void   setVgap(int   vgap)   {  
  this.vgap   =   vgap;  
  }  
   
  /**  
            *   Gets   the   vertical   gap   between   components   and   between    
            *   the   components   and   the   borders   of   the   Container.  
            *    
            *   @return           the   vertical   gap   between   components  
            *                           and   between   the   components   and   the   borders  
            *                           of   the   <code>Container</code>  
            */  
  public   int   getVgap()   {  
  return   vgap;  
  }  
   
  /**  
            *   Returns   a   string   representation   of   this   VerticalFlowLayout  
            *   object   and   its   values.  
            *    
            *   @return           a   string   representation   of   this   layout  
            */  
  public   String   toString()   {  
  String   str   =   "";  
  switch   (align)   {  
  case   LEFT:  
  str   =   ",align=left";  
  break;  
  case   CENTER:  
  str   =   ",align=center";  
  break;  
  case   RIGHT:  
  str   =   ",align=right";  
  break;  
  }  
  return   getClass().getName()   +   "[hgap="   +   hgap   +   ",vgap="   +   vgap   +   str   +   "]";  
  }  
   
  /**  
            *   Centers   the   elements   in   the   specified   row,   if   there   is   any   slack.  
            *    
            *   @param   target           the   component   which   needs   to   be   moved  
            *   @param   x                     the   x   coordinate  
            *   @param   y                     the   y   coordinate  
            *   @param   width             the   width   dimensions  
            *   @param   height           the   height   dimensions  
            *   @param   first             the   first   component  
            *   @param   last               the   last   component  
            */  
  private   void   moveComponents(Container   target,   int   x,   int   y,   int   width,  
  int   height,   int   first,   int   last)   {  
  synchronized   (target.getTreeLock())   {  
  Component   m;  
  for   (int   i   =   first;   i   <   last;   i++)   {  
  m   =   target.getComponent(i);  
  if   (m.isVisible())   {  
  switch   (align)   {  
  case   LEFT:  
  m.setLocation(x,   y);  
  break;  
  case   CENTER:  
  m.setLocation((target.getWidth()   -   m.getWidth())   /   2,   y);  
  break;  
  case   RIGHT:  
  m.setLocation(target.getWidth()   -   x   -   m.getWidth(),   y);  
  break;  
  }  
  y   +=   m.getHeight()   +   vgap;  
  }  
  }  
  }  
  }  
  }Top

3 楼yaoyuan200(遥远)回复于 2005-05-04 17:51:34 得分 0

感谢   wu_bjcn(咖啡的味道)!研究研究!  
  看来是不大好改,我用了很多XYlayout,错的都是XYlayout。Top

相关问题

  • 出错eclipse+lobmoz做j2ee项目出错
  • eclipse新建项目出错?
  • eclipse出错
  • eclipse启动出错
  • 新建项目出错
  • 打开struts项目时,总是进行update jsp index导致eclipse出错,请问如何解决
  • EClipse共享目录出错
  • eclipse中运行Spring出错
  • 在eclipse中总是出错......
  • IDEA4.5建立JSP项目出错

关键词

  • component
  • verticalflowlayout
  • vgap
  • hgap
  • insets
  • roww
  • gap
  • align
  • dimensions
  • vertical

得分解答快速导航

  • 帖主:yaoyuan200

相关链接

  • CSDN Java频道
  • Java类图书
  • Java类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo