Making an existing component to wear a scrollpane

I don't want to have a scrollpane. I just want TheComponent that wears a scrollpane. For example, I want to put a scrollpane on the editor component of a combobox. Or more generically and as a related question, how could we write a class extending C, of which object is C in OOP parlance, that has a scrollpane put on it?
Is it an impossible dream in current Swing?

you should be able to create a custom editor that uses a JScrollPane containing a JTextFieldAnd I'm afraid we are not. Here's another failure:
import javax.swing.plaf.metal.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ScrollingComboBoxEditor extends MetalComboBoxEditor{
  JScrollPane jsc;
  JTextField jtf;
  public ScrollingComboBoxEditor(JScrollPane js){
    jsc = js;
    jtf = (JTextField)(js.getViewport().getView());
  public JTextField createEditorComponent(){
    return jtf;
  public Component getEditorComponent(){
    return jsc;
  public Object getItem(){
    return jtf.getText();
  public void selectAll(){
    jtf.selectAll();
  public void setItem(Object anObject){
    jtf.setText((String)anObject);
  public static void main(String[] args){
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTextField jtf = new JTextField(20);
    JScrollPane jsp = new JScrollPane
     (jtf,  JScrollPane.VERTICAL_SCROLLBAR_NEVER,
      JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    final JComboBox jcb
      = new JComboBox(new String[]{"alpha", "beta", "gamma"});
    jcb.setEditor(new ScrollingComboBoxEditor(jsp));
    jcb.setEditable(true);
    jcb.configureEditor(jcb.getEditor(),
        "alonglonglonglonglonglonglonglonglonglonglongonelinetext");
    jcb.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
        String newSelection = (String)jcb.getSelectedItem();
        jcb.addItem(newSelection);
    frame.getContentPane().add(jcb, java.awt.BorderLayout.NORTH);
    frame.pack();
    frame.setVisible(true);
}

Similar Messages

  • Custom components : contains other existing component

    How do i write a component with the use of existing component, i mean i need a component in which user can enter his address information. so i need 2 or 3 textboxes, a combo etc,.
    right now i doing this in my custom component class, but not working.
    HtmlInputText address = new HtmlInputText();
    address.setValue( "test address" );
    context.getViewRoot().getChildren().add( address );
    but my address field is not added.

    You create a new component as a child of UIViewRoot.
    But UIViewRoot's rendersChildren property is false;
    that means encodeChildren method is not invoked.
    Encodeing of other components under <f:view> is done by the corresponding
    Tag Handler; whereas your new component has no corresponding one.
    I think you should create a new component under some one
    whose rendersChildren property is true (e.g. PanelGrid).

  • Existing component with layout like new google images?

    I've been asked to create a tile list like the new google image search:
         even rows
         variable width contents so uneven columns
         grid is fixed width
         vertical scroll
    Is there an existing component that I can use (such as an S:List with some fancy parameters)?
    Any number of items
    Grid is fixed width
    Vertical can scroll
    XX X XXX X XX   <- different width items in each row means different numbers of items in each row.
    X XX XX XXX X
    XXX XXX X XXX

    Hi,
    We don't have such stock layout in the SDK, but writing a custom one and using it with List shouldn't be too hard.  I have an example of such a layout that maybe a good starting point. It's posted on my blog here http://evtimmy.com/2009/06/flowlayout-part-2-gap-verticalalign-and-scrolling/
    -Evtim

  • Ipad 4 to HDTV via existing Component AV leads?

    I realise the Lightning to 30-pin adapter blurb states it doesn't support video output - so with my new ipad 4 - I'd like to know if it's possible to utilise my existing Apple Component AV leads (these were a snip at c.£35!) with a new Lightning to 30-pin Adapter (just £25!) to play movies on a HDTV? 
    I appreciate the full HD experience would be achieved if I shelled-out £39 on a new Lightning Digital AV Adapter plus another HDMI cable - but would settle for a cheaper 720p solution if it were possible?    

    no it's because the component cable does not! support mirror
    it will only display on the tv when the app being used support the old tvout option
    only the digital av like hdmi and vga support mirror

  • String to existing component conversion

    Hi there,
    I have a program which have components like JPanels.
    And I put the names of these components into a database. Then
    somewhere in my code, I get these names (as you know) as String types.
    But the problem is with these string names I want to get existing
    components not new ones. And then I will show this panel.
    I thought I can do this with a new function which converts string
    to component. But how?
    Can you help me urgently, please...
    Thanks...

    If you have a set of component objects that you've already created, and each component is represented by a unique string identifier, and you want to be able to get the appropriate component for a particular string, then you probably want to use a Hashtable.
    See http://java.sun.com/j2se/1.4.1/docs/api/java/util/Hashtable.html.
    After you create each component, store it with its name using put(), and when you want to get the component back, use get(). Since Hashtables work with java.lang.Object, you can store any kind of object in them, but you have to cast the object back to its correct type when you retrieve it using get().
    Hope this helps.

  • Making the flv component accessible?

    I am using the flv player component and am having trouble adding the players buttons to the tab order.
    I opened the FLA for the skin I am attaching to the component, and individually selected the play, close caption and full screen button and assigned them each a tab order number within the Accessibility window. I also selected the "make object accessible" checkbox for each button within the Accessibility window. Doing that didnt seem to work, so I looked further and found that there is an accessibility class and I have now tried to utilize that class with the following code:
    import fl.accessibility.ButtonAccImpl;
    ButtonAccImpl.enableAccessibility();
    but still dont seem to be doing something right?
    does anyone have experience accessibility and the flv player component?
    many thanks in advance.
    corey.

    i found this on adobes site but the code dosent seem to be correct? it throws this error when i publish:
    Scene 1, Layer 'actions', Frame1, Line 10 1046: Type was not found or was not a complie-time constant: Void.
    DESCRIPTION:
    The FLVPlayback component skins with captioning support were designed with keyboard and screen reader access in mind. The class mx.video.skins.AccessibleSkin assigns a text label to each of the FLVPlayback controls. The AccessibleSkin class also provides the method assignTabIndexes for assigning tab index values to the FLVPlayback controls and incorporating them into the logical tab order of your Flash application. The assignTabIndexes method accepts a start index as a numeric parameter, iterates through the FLVPlayback controls assigning a unique tab index value to each control, and returns the next available tab index number.
    CODE:
    // The starting tabIndex for the FLVPlayback controls
    var nextTabIndex:Number = 10;
    // define a listener object
    var listenerObject:Object = new Object();
    // define a skinLoaded event handler
    listenerObject.skinLoaded = function (eventObject:Object):Void
        // this is technically a hack since the skin_mc is
        // a private property of the FLVPlayback component
        var accessibleSkin = eventObject.target.skin_mc.accessibleSkin;
        if(accessibleSkin){
            // It's best to wait a frame until
            // all FLVPlayback controls initialize
            var intID:Number;
            intID = setInterval( function(){
                // assign tabIndexes starting at nextTabIndex
                nextTabIndex = accessibleSkin.assignTabIndexes(nextTabIndex);
                // trace the next tab index after
                // FLVPlayback controls
                trace( nextTabIndex );
            clearInterval(intID);
            }, 100 );
    // register listenerObject to handle "skinLoaded" event.
    // this code assumes that your FLVPlayback component instance is
    // named "myFLVPlayback_flvp"
    myFLVPlayback_flvp.addEventListener("skinLoaded",listenerObject);
    i miss good old AS2
    thanks again in advance for any help.
    corey

  • Making a new component paint over top of others.

    Hi,
    I'm trying to make my own custom component (by extending Component). In the paint method, I just would like to draw a rectangle of some size at a certain point on the screen. I want this rectangle to be able to be drawn over top of any components that may already be there, much like a menu is drawn on the screen.
    My question is, how can I do this? Oh, and I'm restricted to the AWT package only (no Swing). What graphics object do I need to do this?
    Thanks in advance!

    you must ensure that your component remains on top of the components you wish to draw over. thats how menus do it. they use a glass pane or some such which is always on top of the other items. This is maintained by the main window the menu is added too. that window knows to always add other things beneath this glass pane which is on top. You should be able to do what you wish.

  • JTree Problem, Making Sure Selected Node is Visible in ScrollPane

    Is it possible to find out if the node selected in a JTree is visible in the JScrollPane in which it is contained? And if it isn't to scroll so that the node is visible?
    Thanks

    hello again dosteov,
    You can get the rectangle based on a row or a TreePath. Given the rectangle, you can call scrollPane.scrollRectToVisible() with the rectangle returned from tree.getRowBounds(row).
    Note that you will need to do some rectangle movement if your tree is in a container rather than directly in the scrollpane.
    -jonathan

  • Adding actionscript to existing component

    Is it possible to add actionscript to a component. For
    example, can you add AS to the play/pause button on the FLV
    playback component? thanks!

    LuigiL’s recommendation may work perfectly fine however
    I wouldn’t recommend it for the same reasons as senocular
    mentioned on his website. Senocular as an alternative way for
    'editing' such classes…;
    http://www.senocular.com/?id=1.378

  • Making an existing row cell mandatory

    We have a requirement to make an existing cell on each order row mandatory. i.e. if the cell is filled from a dropdown list this is not a problem. i.e. the list appear if the tab key is selectged whilst in the cell. However, the user can click the subsequent cell, hence bypassing the cell that we would like to have the mandatory entry.
    Help!

    Hi,
    this is how i make a column in a matrix mandatory.This is done onclick of the add/update button before its action.
    If pVal.FormType = "149" And pVal.ItemUID = "1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED And pVal.Before_Action = True Then
                    Dim strPrftCd As String '*** a variable that stores your Cost Code
                    oDataSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                    oForm = SBO_Appln.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
                    oMatrix = oForm.Items.Item("38").Specific
                    For i = 1 To oMatrix.RowCount - 1
                        strPrftCd = oMatrix.Columns.Item("30").Cells.Item(i).Specific.value
                        If strPrjCd = "" Then
                                    SBO_Appln.SetStatusBarMessage("Cost Code is empty", SAPbouiCOM.BoMessageTime.bmt_Short, True)
                                    BubbleEvent = False
                                    Exit Sub
                        End If
                  Next         
            End If
    Hope That helps
    Manu

  • Breakpnt is not stoping in any meth in New Zcomponent in existing component

    Hi
    created ne z comp.
    added in runtimerepository viewset of bt126h_appt.
    made avialable as assignment block.
    saving is perfect.
    want to provide f4 help or dropdown for the new fields mof my view which is in zcomp.
    when i go from crm_ui   in any method of zcomp  it is not stopping after keeping breakpoint.  in my zimpl class also it is not stopping (in zcomp)
      please suggest.
    thanks
    ram

    allways external breakpoints for the debugging of the webclient UI

  • Making existing frequency become zero frequency

    Hye. Help me, I got a probem on making the existing frequency from read from measurement data become zero. Is that possible?
    Because the data should have 0Hz of its frequency. For now it have around 0.05Hz, so i want it to become 0. I has attach my snippet here. Thanks.
    Best regards,
    Fatin.

    I recommend a simple software debounce.  it has been very effective in the past.
    any equipment that vibrates and product spurious edges on a tach or encoder.
    see attached.  it is a modified version of one from NI  set n= 5 0r 10 for your case and see how it works
    Stu McFarlane
    Viewpoint Systems, Inc.
    Attachments:
    debounce.png ‏21 KB

  • Trying to focus in on a DateField component

    Has anyone ever had trouble sending keyboard focus to the
    DateField component? Try this: create a new Flash document and
    insert a TextInput component named textItem, a DateField component
    named dateItem and a ComboBox component named ComboItem. Then
    insert the following code:
    textItem.tabIndex=1;
    dateItem.tabIndex=2;
    comboItem.tabIndex=3;
    stop();
    Test the movie and try to tab over to the DateField component
    from the TextInput component. Why does the focus skip over the
    DateField? Is this something easy to fix, or are we going to have
    to wait and spend more $$$ for a new release from
    Adobe/Macromedia?

    Same here....
    Haven't seen a response from Adobe either. "Mum is the word"
    apparently.
    Also, finding the documentation to set a default value to be
    non-existant as well.
    What should be as easy as setting "instance.date = xxxx;"
    appears to have been obfuscated to the point of making this little
    component nigh unusable.
    Bah...not happy

  • Change Button text during component use of WDR_SELECT_OPTIONS

    Hello,
    I have implemented a WD component (WD for ABAP) by making use of component WDR_SELECT_OPTIONS. The selection screen is getting displayed. But the selection screen contains the button Copy, Check, Cancel and Reset.
    I want to rename the button tex "Copy" to "Search". Is it possible to do so?
    Please help!
    Thanks and Besd Regards,
    Maya

    Hi Maya,
    Unfortunately, this is not possible. There is also a translation bug while translating it from German into English. The button should have been translated into "Apply" instead of "Copy". This is issue is being addressed and should be fixed within one of the upcoming service packs.
    Nonetheless, there is a solution to your problem. Just hide the button (or the whole row) by calling method SET_GLOBAL_OPTIONS and add your own buttons below or above where you embed the SelectOptions component. The handler interface contains methods to reset the selection screen as well as for input validation.
    Kind regards,
    Thomas

  • How to print the components in scrollpane

    hi there,
    can anyone tell me how to print the scrollpane components, i mean the headers & the main view of the component. i've a scrollpane with the following code and i want to print the components:
    JScrollPane pane = new JScrollPane(aTextPane);
    pane.setRowHeaderView(aLineNumberComponent);my requirement is i've a editor & lineno component as textpanes and added to scrollpane & when asked to print it should print the lineno component which resides in scrollpane's row header & the editor textpane which is the main view in the scrollpane. how can i achieve this?
    i'd would appreciate any suggestions & codes given.
    thanx in advance.

    After adding/removing components to/from a panel try:
    panel.revalidate();
    panel.repaint() // sometimes this is also needed, I'm
    not sure whyI'm not certain, but I think that panel.revalidate() implicitly calls repaint() only if something actually changed in the layout. If nothing changed, it sees no reason to repaint; hence, if something changed in appearance but not in layout, you have to repaint it yourself.
    Or something like that. I'm no expert. ;)

Maybe you are looking for

  • I am unable to create a table using procedure..

    Hi everyone, I have given CREATE ANY TABLE privilege to user A and wants to insert data into TAB1 in schema B using a procedure "INSERT INTO B.TAB1 AS SELECT * FROM A.TAB1" but it shows the message-- PL/SQL: ORA-01031: insufficient privileges Which p

  • AppleScript save email to pdf file issues

    HI, 1. Can I use AppleScript save Apple mail message to pdf file, I mean not using GUI script. 2. If possible for point 1, can it save the email message to network folder? Thanks in advance. patrick

  • 2 date columns and one dimension hierarchy

    Hi, I have one question in OBIEE 10g. I have one dimension table with 2 date columns (insertedOn, updatedOn) I created insertedOnYear, insertedOnMonth and updatedOnYear, updatedOnMonth columns from my date columns. I have hierarchy Year -> Month -> D

  • My Ipad 2 screen went black, tried all fixes i could find.  none worked.  any ideas?

    My 13 month old Ipad 2 screen went black while sitting on the table.  NO drops or damage.  Tried both reboots, synced with itunes (it was there, fully charged) and rest to factory settings.  still no screen.  now the store wants to charge me a minimu

  • BAPI_ENRTYSHEET_CREATE and services without service-code

    Hi, I would like to create a SES using a planned service without service-code. Is it possibile and how can i do using BAPI_ENTRYSHEET_CREATE? Thanks Luca