JComponent Class

#The JComponent Class
 !introduction
   !!from which all Swing components whose names begin with "J" descend,except for the top-level containers
   !!extends the Container class,which itself extends Component.
#JComponent Features
  !Tool tips:by specifying a string with the setToolTipText method,you can provide help to users of a component.
   !!how-to:
     !!!to add tool tips to three buttons,you add only three lines of code:
    b1.setToolTipText("Click this button to disable the middle button.");
b2.setToolTipText("This middle button does nothing when you click it.");
b3.setToolTipText("Click this button to enable the middle button.");
    !!!When you implement a tabbed pane, you can specify the tab-specific tool-tip text in an argument to the addTab or setToolTipTextAt method.(examples?????)
    !!!do the job youself(even in components that have no API for setting part-specific tool-tip text.)
    !!!!renderer,with which we can set the tool tip text on a custom renderer.
    !!!creating a subclass of the component and overriding its getToolTipText(MouseEvent) method.
   !!The Tool tip API(most of the API you need to set up tool tips is in the JComponent class,and thus is inherited by most Swing components.More tool-tip API is in individual classes such as JTabbedPane.you usually dont need to deal directly with the implementing classes,JToolTip and ToolTipManager.)
    !!!setToolTipText(String)
    !!!String getToolTipText()
    !!!String getToolTipText(MouseEvent)
    !!!Point getToolTipText(MouseEvent)
  !Painting and borders(the setBorder method allows you to specify the border that a component displays around its edges.to paint the inside of a component,override the paintComponent method.)
  !!how to use borders(every JComponent can have one or more borders.draw the edges of Swing components.not also for drawing lines and fancy edges,but also for providing titles and empty space around components.
  NOTE: In general,when you want to set a border on a standard Swing component other than JPanel or JLabel,we recommend that you put the component in a JPanel and set the border on the JPanel.)
   !!!put a border:setBorder
   !!!creat most of the borders:BorderFactory.
   !!!Border reference:Border.
   !!!Using the Borders Provided by Swing
   !!!Creating Custom Borders:
     If BorderFactory doesn't offer you enough control over a border's form, then you might need to directly use the API in the border package — or even define your own border.
   !!!The Border API
    !!!!Creating a Border with BorderFactory
    !!!!Setting or Getting a Component's Border
   !!Performing Custom Painting(you might not need to read this lesson at all.if you can't find a way to make a component look the way you want it to,then read on.)
    (TO BE...)
 !Application-wide pluggable look and feel
  IMPORTATION:Behind the scenes,each JComponent object has a corresponding ComponentUI object that performs all the drawing,event handling,size determination,and so on for that JComponent.Exactly which ComponentUI object is used depends on the current look and feel,which you can set using the UIManager.setLookAndFeel methos.
  !Custom properties(to be....)
   you cna associate one or more properties(name/object pairs) with any JComponent.
  !Support for layout
   (TO BE...)
  !Support for accessibility(see how to support assistive technologies.
 TO BE...)
   YOU might be wondering what exactly assistive technologies are ,and why you should care.Primarily,assistive technologies exist to enable people with permanent or temporary disabilities to use the computer.
 !Support for drag and drop
    see Introduction to Drag and Drop and Data   Transfer.
  (TO BE ...)
 !Double buffering
  smooths on-screen painting.
 !Key dindings
   makes components react when the user presses a key on the keyboard.
#The JComponent API
 
  
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值