Place a component over another

Hello World !
First: sorry for my bad english.....
This is a great Forum with a lot of answers but I was not able to find my problem :(
I have a JTable with editable cells. Each Cell contains a CarretListener for quick validation of the entered text. But in one special cell you should be able to select entrys out of a list. The List is generated when you enter a text. The Programm serach in a list for entrys equal so the entered text, like google suggest. So far its all good. But i dont get it how to show the list at the right position. I tried the GlassPane but this doesn't work so well. I have problems to get the Cordinates of the cell and to show the JList.
Set the row height so show the whole list also dosn't work because i don't want to change the whole row.
Maybe there is a trick in the TableCellRenderer or so...?
I don't want a complete sourcecode or so, but a I need a push in the right direction.
Here is a pic of the programm: [http://img198.imageshack.us/img198/3227/sosollsseinh.jpg]
Thanks for your attention
Marc
Edited by: MercT on Nov 10, 2009 12:30 AM

hii,
that's ... http://www.java2s.com
private ArrayList<String> defListCities = new ArrayList<String>();
private final CityComboBox defCityCombo = new CityComboBox(defListCities);
//or
private ArrayList<String> defListCities = new ArrayList<String>();
private final CitiesTextField defCityTextField = new CitiesTextField(defListCities);
//or as needed
//defCityTextField.setDataList(defListCities);
//defCityTextField.setStrict(false);
import java.util.List;
import javax.swing.JTextField;
import javax.swing.text.*;
public class CitiesTextField extends JTextField {
    private static final long serialVersionUID = 1L;
    class AutoDocument extends PlainDocument {
        private static final long serialVersionUID = 1L;
        @Override
        public void replace(int i, int j, String s, AttributeSet attributeset) throws BadLocationException {
            super.remove(i, j);
            insertString(i, s, attributeset);
        @Override
        public void insertString(int i, String s, AttributeSet attributeset) throws BadLocationException {
            if (s == null || "".equals(s)) {
                return;
            String s1 = getText(0, i);
            String s2 = getMatch(s1 + s);
            int j = (i + s.length()) - 1;
            if (isStrict && s2 == null) {
                s2 = getMatch(s1);
                j--;
            } else if (!isStrict && s2 == null) {
                super.insertString(i, s, attributeset);
                return;
            if (citiesComboBox != null && s2 != null) {
                citiesComboBox.setSelectedValue(s2);
            super.remove(0, getLength());
            super.insertString(0, s2, attributeset);
            setSelectionStart(j + 1);
            //setSelectionStart(0);
            setSelectionEnd(getLength());
        @Override
        public void remove(int i, int j) throws BadLocationException {
            int k = getSelectionStart();
            if (k > 0) {
                k--;
            String s = getMatch(getText(0, k));
            if (!isStrict && s == null) {
                super.remove(i, j);
            } else {
                super.remove(0, getLength());
                super.insertString(0, s, null);
            if (citiesComboBox != null && s != null) {
                citiesComboBox.setSelectedValue(s);
            try {
                setSelectionStart(k);
                setSelectionEnd(getLength());
            } catch (Exception exception) {
    public CitiesTextField(List<String> list) {
        isCaseSensitive = false;
        isStrict = true;
        isStrict = false;
        citiesComboBox = null;
        if (list == null) {
            throw new IllegalArgumentException("values can not be null");
        } else {
            dataList = list;
            init();
            return;
    CitiesTextField(List<String> list, CitiesComboBox b) {
        isCaseSensitive = false;
        isStrict = true;
        isStrict = false;
        citiesComboBox = null;
        if (list == null) {
            throw new IllegalArgumentException("values can not be null");
        } else {
            dataList = list;
            citiesComboBox = b;
            init();
            return;
    private void init() {
        setDocument(new AutoDocument());
        if (isStrict && dataList.size() > 0) {
            setText(dataList.get(0).toString());
    private String getMatch(String s) {
        for (int i = 0; i < dataList.size(); i++) {
            String s1 = dataList.get(i).toString();
            if (s1 != null) {
                if (!isCaseSensitive && s1.toLowerCase().startsWith(s.toLowerCase())) {
                    return s1;
                if (isCaseSensitive && s1.startsWith(s)) {
                    return s1;
        return null;
    @Override
    public void replaceSelection(String s) {
        AutoDocument _lb = (AutoDocument) getDocument();
        if (_lb != null) {
            try {
                int i = Math.min(getCaret().getDot(), getCaret().getMark());
                int j = Math.max(getCaret().getDot(), getCaret().getMark());
                _lb.replace(i, j - i, s, null);
            } catch (Exception exception) {
    public boolean isCaseSensitive() {
        return isCaseSensitive;
    public void setCaseSensitive(boolean flag) {
        isCaseSensitive = flag;
    public boolean isStrict() {
        return isStrict;
    public void setStrict(boolean flag) {
        isStrict = flag;
    public List<String> getDataList() {
        return dataList;
    public void setDataList(List<String> list) {
        if (list == null) {
            throw new IllegalArgumentException("values can not be null");
        } else {
            dataList = list;
            return;
    private List<String> dataList;
    private boolean isCaseSensitive;
    private boolean isStrict;
    private CitiesComboBox citiesComboBox;
} to be continued for chained combo def.

Similar Messages

  • Placing one image over another

    How can I place one image over another image in java?

    Draw the bottom image first and then the top image. You would need to extend JComponent's paintComponent() method.

  • How do I make a textbox appear in a PDF made in InDesign CC when the cursor rolls over another textbox?

    I'm trying to make a textbox appear in a PDF made in InDesign when the user rolls the cursor over another textbox, and I want it to disappear when the cursor moves off the first textbox. I've tried the following with various setting, and it's just not working for me.
    Display a different button on rollover
    You can create a hot spot in which clicking or mousing over an object displays another object. To do this, create two buttons, hide one of the buttons, and use the Show/Hide Button action to show and hide the target button.
    Create an object to be used as the source button. In the Buttons panel, click the Convert Object To A Button icon.  
    Place the image you want to be used as the target button, and convert it to a button.  
    Select the target image and select Hidden Until Triggered at the bottom of the Buttons panel.  
    The image needs to be hidden in the exported document so that it can be displayed when the source button is moused over or clicked.  
    Select the source button and create two different actions, one to show the target image and a second to hide the target image.  
    If you want the image to appear when the mouse hovers over the source button, use the On Roll Over and On Roll Off events. If you want the image to appear when you click the source button and disappear when you release it, use the On Click and On Release events. In either case, use the Show/Hide Buttons action to display and hide the target button. See Make buttons interactive.   
    Use the Preview panel to test the buttons.  

    Here's more information about what I'm doing.
    1. create text box with a little text
    2. turn it into a button (Button 1)
    3. create another text box with some text
    4. turn this into a button (Button 2)
    5. check "Hidden Until Triggered" for Button 2
    6. For Button 1, select "On Roll Over" for Event
    7. For Button 1, click + to add Action and choose "Show/Hide Buttons and Forms"
    8. For Button 1, change icon next to Button 2 into eyeball (which I assume makes Button 2 visible on roll over).
    9. For Button 1,, select "On Roll Off" for Event
    7. For Button 1, click + to add Action and choose "Show/Hide Buttons and Forms"
    8. For Button 1, change icon next to Button 2 into crossed-out eyeball (which I assume makes Button 2 invisible on roll off).
    8. Export to PDF with modified smallest file size and include bookmarks and hyperlinks and include appearance for interactive elements.
    Both buttons are visible in the PDF, and nothing happens with roll over and off.
    What am I doing wrong?

  • How to add an Image layered over another Image?

    In our application, we display a big image file in the main application window.
    Now, we want to display customer's image(like their logo etc.,) just layered over main image on the top-left corner, restricted in size.
    Tried to visualize it !
    |------| |
    | |
    | |
    Is it possible to show a JLabel over another JLabel?

    Solution 1:
    JLabel is a container, So you can add any component on top of JLabel but normally it will not display but if you set any layout then you can see the added component.
        public static void solution1() {
         JFrame frame = new JFrame();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         JLabel bigImg = new JLabel(new ImageIcon("F:\\tmp\\bigImg.jpg"));
         JLabel logo = new JLabel(new ImageIcon("F:\\tmp\\logo.gif"));
         frame.getContentPane().add(bigImg, BorderLayout.CENTER);
         bigImg.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
         bigImg.add(logo);
         frame.pack();
         frame.setVisible(true);
        }Disadvantage : if the label size was changed depends on the layout the position of the logo goes outside of the big image(in the above example maximize the window to see that issue).
    Solution 2:
    draw the logo image on top of the big image.
        public static void solution2() {
         JFrame frame = new JFrame();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         ImageIcon bigImg = new ImageIcon("F:\\tmp\\bigImg.jpg");
         ImageIcon logo = new ImageIcon("F:\\tmp\\logo.gif");
         int w = bigImg.getIconWidth();
         int h = bigImg.getIconHeight();
         BufferedImage bf = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
         Graphics2D g2d = bf.createGraphics();
         g2d.drawImage(bigImg.getImage(), 0, 0, frame);
         g2d.drawImage(logo.getImage(), 0, 0, frame);
         JLabel label = new JLabel(new ImageIcon(bf));
         frame.getContentPane().add(label, BorderLayout.CENTER);
         frame.pack();
         frame.setVisible(true);
        }Advantage : whenever the label component size changed the logo must be on the big image of the same position because the logo was painted on top of the big image.

  • I frequently lose audio when in the middle of a call.  I am not certain whether it is a full disconnect or just an audio loss.  The person on the other end reports still being able to hear me, however, I suppose they could hear me speaking over another s

    I frequently lose audio when in the middle of a call.  I am not certain whether it is a full disconnect or just an audio loss.  The person on the other end reports still being able to hear me, however, I suppose they could hear me speaking over another source even if bluetooth disconnected. The loss of audio is always preceded by a quick shrill noise, so I can easily tell when it happens.  All I have to do to fix the problem is to select Audio Source on the call screen, temporarily switch audio back to the iPhone, and then switch back to the headset, and then it starts working again.
    My Iphone5 was replaced and having same Problem. Only does this when using bluetooth for talking.

    I have the exact same issue... I've been using a Jabra Extreme2 and just this weekend, bought a Plantronics Marque2 and today had the same issue, so it's clearly not the headset but the phone or OS.
    I might try a restore and see if it helps...

  • How to add an image over another using af:image

    How to add an image over another using af:image
    Thanks,
    Veera

    i have a image which is black strip. i have added that to af:image
    <af:image source="image1" id="image" />
    on the black strip, i need to add company logo.
    how to achieve it.
    Thanks,
    Veera.

  • Help: photoshop cs4 crashes when i drag a layer under or over another layer/try to change layer orde

    help: photoshop cs4 crashes when i drag a layer under or over another layer/try to change layer order
    this problem orcurred suddenly after having used the programm for years.
    i tried to reinstall cs4 and install all available updates, but it di not help...
    please help ! thanks

    What is the exact version and what’s your OS?
    What does the crash report state?
    Boilerplate-text:
    Are Photoshop and OS fully updated and have you performed the usual trouble-shooting routines (trashing prefs by pressing command-alt-shift/ctrl-alt-shift while starting Photoshop until the appropriate dialog appears after making sure all customized presets like Actions, Patterns, Brushes etc. have been saved and making a note of the Preferences you’ve changed, 3rd party plug-ins deactivation, system maintenance, cleaning caches, font validation, etc.)

  • How do I superimpose one image over another

    How do I super impose one image over another?

    Open image A
    Open image B
    On image B, use one of the selection tools, e.g. selection brush, lasso tool, to select the object which you wish to "superimpose"
    Go to Edit menu>copy to put the object on the clipboard
    Go back to image A
    Go to Edit>paste. The object will be on its own layer
    Get the move tool out of the toolbox, and position the object and resize, if indicated

  • How to prioritize one Wi-Fi network name as preferred over another?

    In OS X, you can set a Wi-Fi network name as preferred over another for Airport. Is there a feature like this on the iPhone OS? For example, if it sees two networks, it connects to network name B, when really I want it to connect to network name A.

    Unfortunately, you have done all that you can do since the Mac can only support one active connection at a time, regardless of the connection order of services.

  • Calling Inbound Plug of one Window of one Component in another WD Component

    Hi All,
        Can anyone please tell me how to call a Window's Inbound Plug of one WD Component in another WD Component.
    Thanks in advance!
    Best Regards,
    Devyani

    Hi Devyani,
        are you calling the view (embeded in a window ) of a component 1 in component 2. If so,
    1. Define the used component(Component 1) in the using component (Component 2)
    Component Use : Comp1
    Component        : Component 1(Name of the component)
    2. On action: using component usage window, window of component can be called as a pop up window in component 2
    If this is not your requirement, let me know. i will try to help
    Regards,
    Sankar

  • Displaying a temporary image over another image

    Hello,
    I am writing a program where I need to draw a filled rectangle over another image then disappear (without drawing on to it).
    The Image is on a JPanel.
    Obviously I can not use Graphics.drawImage because that will permantley draw the rectangle on the image.
    How can I achieve what I want to do here?
    Thanks
    Andrew

    Yes, Ill be more specific.
    I have an image and over the image there are two words: "photos" "videos".
    I want to do the following: when you scroll the mouse on top of the word "photos", the word "photos" gets underlined and you can click on it and it will have a link to another page.
    Now, I normally insert an "imagen de sustitucion" which i think is a substitute image and it works perfectly. But then I cant move that image to be ON TOP of the picture i want to use as a kind of backround to these words.

  • How does one Component access another Component via Component Interface ?

    Folks,
    Hello. I have developed my project as 2 Components ( A and B). I have created a Search Record and a Component Interface for each Component.
    Now, a push button in a page in Component A needs to access all pages in Component B via its Component Interface. What are the steps to do for Component A to access Component B via their Component Interface ?
    Thanks.

    You could define the PeopleCode to make the Component Interface work on the FieldChange event of that push button you were talking about, but it would be better to put your PeopleCode in a Save event. To do that, you would use the DoSaveNow() function on the button's FieldChange event. Then, that would trigger a save, and you could put your code on the SavePostChange of any field or on the Component itself.
    Once you decide on an event, the easiest way to start is to open the blank PeopleCode window. Also, place the Component Interface in your project. Next, drag the Component Interface from the Project and drop it into your PeopleCode editor window. This will generate a bunch of PeopleCode that you can use as a starting place.
    The Component Interface allows you to remote control a component as if your code were a user sitting at the Browser. So, when coding the program that uses the Component Interface, you have to have that mindset. It helps me to open a browser and walk through what I want my code to do. Then, I code each step as I do it online.
    There is probably a lot more that you need to know, but is this a good starting point? Is it somewhat on track with what you were asking? Let me know were to go from here with more information.

  • Trying to use a popup window as a component  in another component

    Hi guys,
    I am unable to use a popup component in another component in
    Flex .
    Its not calling the popup compopnent.
    Could anyone plz hel me.
    This is my code.
    This is the parent component TitlWindow where i want to call
    my popup
    component.
    <mx:TitleWindow xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" width="100%" height="100%"
    xmlns:util="userinterfaces.util.*"
    creationComplete="showWindow();"
    title="CREATE PROFILE">
    This is my script where i am writing a function to call a
    component
    whose name is fielupload.mxml
    <mx:Script>
    private function showWindow():void
    pop =
    fileupload(PopUpManager.createPopUp(this,fileupload,true));//
    fileupload.mxml
    is called
    pop.title = "Please enter your login information.";
    pop.showCloseButton =true;
    PopUpManager.centerPopUp(pop);
    pop.addEventListener("close",removeMe);
    </mx:TitleWindow>
    This is the code for fileupload.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:TitleWindow xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" width="100%" height="100%"
    xmlns:util="userinterfaces.util.*" title="File Upload">
    <mx:Script>
    <![CDATA[
    import mx.collections.XMLListCollection;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.events.ProgressEvent;
    import mx.controls.Alert;
    import flash.net.FileFilter;
    import flash.net.FileReference;
    import flash.events.SecurityErrorEvent;
    import mx.controls.Button;
    import mx.controls.TextInput;
    import mx.controls.ProgressBar;
    import mx.core.Application;
    import flash.net.URLRequest;
    import flash.net.URLRequestMethod;
    import mx.core.UIComponent;
    import mx.managers.PopUpManager;
    public var fileFilterImage:FileFilter = new
    FileFilter("Images","*.png;*.gif;*.jpg");
    public var fileFilterDocument:FileFilter = new
    FileFilter("Documents", "*.txt;*.doc;*.pdf;*.rtf");
    public var fileFilterArchives:FileFilter = new
    FileFilter("Archives", "*.zip;*.tar;*.hqx");
    public var fileFilterAll:FileFilter = new
    FileFilter("All", "*.*");
    public var fileRef:FileReference;
    public var selectedId:String;
    public function init():void {
    fileRef = new FileReference();
    fileRef.addEventListener(Event.CANCEL,
    traceEvent);
    fileRef.addEventListener(Event.COMPLETE,
    completeEvent);
    fileRef.addEventListener(Event.SELECT,
    selectEvent);
    fileRef.addEventListener(IOErrorEvent.IO_ERROR,
    traceEvent);
    fileRef.addEventListener(Event.OPEN, traceEvent);
    fileRef.addEventListener(ProgressEvent.PROGRESS,
    onFileProgress);
    fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
    traceEvent);
    public function traceEvent(event:Event):void {
    var tmp:String =
    "================================\n";
    public function
    ioErrorEvent(event:IOErrorEvent):void{
    Alert.show("IOError:" + event.text);
    traceEvent(event);
    public function selectEvent(event:Event):void{
    //var selectedId:String =
    selectButton(event);
    //Alert.show("i am in id" +
    Application.application.winMyProfile.selectedId);
    btnUpload.enabled = true;
    iptFile.text = fileRef.name;
    public function
    selectButton(catchButton:Event):void{
    var newButton : Button = new Button;
    newButton = catchButton.currentTarget
    as Button
    selectedId = newButton.id;
    //Alert.show("i am in id" +
    selectedId);
    public function
    onFileProgress(event:ProgressEvent):void {
    prgBarUpload.label = "Loaded " +
    event.bytesLoaded + " of " +
    event.bytesTotal + " bytes";
    prgBarUpload.setProgress(event.bytesLoaded,
    event.bytesTotal);
    public function
    completeEvent(event:Event):void {
    Alert.show("File Uploaded
    Successfully");
    btnUpload.enabled = false;
    btnBrowse.enabled = true;
    public function uploadFile(url:String):void {
    url = url + "?
    folder="+Application.application.winLogin.userInfo.getUsername();
    var req:URLRequest = new
    URLRequest(url);
    req.method = URLRequestMethod.POST;
    var folder:String =
    Application.application.winLogin.userInfo.getUsername();
    fileRef.upload(req, folder,true);
    ]]>
    </mx:Script>
    <mx:VBox id="vbMain" width="100%" height="60">
    <mx:HBox width="100%" height="22">
    <mx:TextInput height="22" id="iptFile"
    width="100"/>
    <mx:Button id="btnBrowse" label="Browse"
    click="selectButton(event),fileRef.browse([fileFilterAll]);"
    />
    <mx:Button id="btnUpload" label="Upload"
    enabled="false"
    click="uploadFile('fileupload.do');" />
    <mx:Button id="btnCancel" label="Cancel"
    enabled="false"
    click="PopUpManager.removePopUp(this);"/>
    </mx:HBox>
    <mx:ProgressBar width="200"
    source="iptFileResume" height="5"
    id="prgBarUpload" mode="manual"/>
    </mx:VBox>
    </mx:TitleWindow>
    Its not even showing any error , i dont know whats the
    problem with
    it.
    Thanks for your help,
    Mario.

    If I understand, you want to display a popup Titlewindow from
    within another popup TitleWindow? This is possible.
    Simplify your code to get it working first.
    Tracy

  • Replace a component by another in a Frame

    Hi all!
    I've a frame with several component (panels, buttons...) set with a gridbaglayout.
    I would like to know if i could replace a component by another.
    For instance.
    Frame f = new Frame();
    button b1 = new button("b1");
    panel p = new panel()....
    f.add(b1)
    /* replace b1 by p
    like :
    f.remove(b1);
    f.add(p);
    */Thanks!

    Sure, you can replace any component by enother one.
    add f.validate() in the end.

  • How do i fade a video over another?

    on imovie 11 how do i fade a viedo over another video?

    To supplement Bengt's excellent advice, see the Apple Help article on "Add transitions between clips". Be sure to view the video (see the heading "Watch the movie"). Here's the link (the article and video also appear in the iMovie menu item "Help>iMovie Help"):
    http://help.apple.com/imovie/index.html?lang=en#mova719f373
    John

Maybe you are looking for