Jlist with disabled selection mode

Hello,
I want a Jlist where i can switch from noselection possible to singleselection whenever i want to,
Single selection is no problem,
but no selection i founded only to disable the jlist, and thats no option.
Any suggestions,
thx in adv.
Donovan.

Hi,
this should do, maybe you need to implement a constructor:public class MyList extends JList {
     private boolean selectAllowed = true;
     public void setSelectedIndex(int index) {
          if (!selectAllowed) {
               return;
          super.setSelectedIndex(index);
     public void setSelectedIndices(int[] indices) {
          if (!selectAllowed) {
               return;
          super.setSelectedIndices(indices);
     public void setSelectedValue(Object anObject, boolean shouldScroll) {
          if (!selectAllowed) {
               return;
          super.setSelectedValue(anObject, shouldScroll);
     public void setSelectionAllowed(boolean allowed){
          if (!allowed) {
               super.clearSelection();
          selectAllowed = allowed;

Similar Messages

  • WD ALV with mandatory selection mode (1..n or 1..1)

    Hi there,
    I tried to integrate an ALV table in my WD component. The problem here is, that I chose the selection 1..1 in my data supplying context node. Now I can't start my application anymore without the following error:
    Number of Elements of Selection of VIEW_TABLE.1.DATA Violates Cardinality
    What do I need to set as ALV property to solv the problem?
    Kind regards,
    Albert

    i just want you to check the importance of this
    IF_WD_CONTEXT_NODE~SET_CHANGED_BY_CLIENT - set as true so that what ever changes you make to standard ones through coding are implemented...first donot set this parameter and test the things...if still things doesnot work out then use this parameter...Please go through the documentation before you really use this parameter.
    in ALV - you have you use if_salv_wd-table_settings~set_selection_state - > as MULTI..but if this placed you selection should be 0-n or 1-n...otherwise it may go for a dump...i guess there should be some workaround...for this..
    may be we have to debug to get the things done....
    Lukas -
    If IF_WD_CONTEXT_NODE_INFO~IS_MULTIPLE_SELECTION would be set to ABAP_TRUE... - > This will not set the value that retuns the value...
    Edited by: Lekha on Dec 29, 2011 1:38 PM

  • Problems with the selected item in a JList

    Hi,
    I am using a JList with a JTextPane as renderer, when I select an item in the list the foreground color is black instead of being white and when I go up in the list the foreground color of the items under the selected one is white (they are not visible anymore).
    Does anyone know why this list behaves like that and what I should do to prevent this?
    Thanks in advance
    Here's the code of the renderer (I suppose this is the place where the problems are):
    public class TextPaneListRenderer extends JTextPane implements ListCellRenderer
    public TextPaneListRenderer()
    setOpaque(true);
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
    this.setText(value.toString());
    if (cellHasFocus)
    setBackground(list.getSelectionBackground());
    setForeground(list.getSelectionForeground());
    else
    setBackground(list.getBackground());
    setForeground(list.getForeground());
    return this;
    getListCellRendererComponent() not yet implemented.");
    }

    Hi,
    i would use isSelected:
    if (isSelected)
    setBackground(list.getSelectionBackground());
    setForeground(list.getSelectionForeground());
    else
    setBackground(list.getBackground());
    setForeground(list.getForeground());
    It might help, just give it a try.

  • Why i cant watch youtube as youtube inform this "This video is unavailable with safety Mode enabled. To view this video, to need to disable safety mode" how can i turn off safety mode

    Why i cant watch youtube as youtube inform this "This video is unavailable with safety Mode enabled. To view this video, to need to disable safety mode" how can i turn off safety mode
    Why i cant watch youtube as youtube inform this "This video is unavailable with safety Mode enabled. To view this video, to need to disable safety mode" how can i turn off safety mode

    You need to disable Safety Mode at the bottom of the YouTube page. More info here:
    https://support.google.com/youtube/answer/174084?hl=en

  • Disable "Safe Mode with Networking in Windows 7"

    Hello,
    Does anyone know, how to disable "Safe Mode With Networking" option from Windows 7 boot menu?
    Kind Regards
    Kalle Reivilä

    Hi,
    Base on my research, there’s no official method to disable Safe Mode with networking in Windows 7.
    Thank you for your understanding.
    Regards,
    Leo  
    Huang
    Leo Huang
    TechNet Community Support
    Thank You .This is what I was afraid.
    I work  at school and We have one problematic classroom. It's http traffic is blocked by a FSecure's firewall, but students have figured out a way. They boot computers to safe mode with networking and after that
    they have access to the Internet! Now We have to change Microsofts's own firewall.
    Regards,
    Kalle Reivilä

  • JList with Multiple interval Selection

    I am trying to get all the selections that I selected when
    a button is pressed. I just don't under how it works when the selection is not contiguous. if it was I just need the first and last selected but I don't know what to do with this situtation
    Duke dollars avaiable

    If your JList allows multiple sections then this:
    1.select first item
    2. hold sown the shift key
    3. select Nth item
    will select all the items between the first and the Nth.
    Holding down the Ctrl key will select individual items.
    To make your JList accept multiple selections you use setSelectionMode

  • Checkedlistbox allows multiple selections with Selection mode set to one

    I have a simple CheckedListBox with three options. I set Selection Mode to One. When I test the form, it allows me to have more than one box checked. I can clear the other two with a program, but my understanding of Selection Mode was that it would not
    allow more than one box to be checked if set on one.

    Option Strict On
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    CheckedListBox1.SelectionMode = SelectionMode.One
    For i = 1 To 10
    CheckedListBox1.Items.Add("Number" & i.ToString)
    Next
    End Sub
    Private Sub CheckedListBox1_ItemCheckChanged(sender As Object, e As ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
    Dim ItemIndex As Integer = e.Index
    For i = 0 To CheckedListBox1.Items.Count - 1
    If i <> ItemIndex Then
    CheckedListBox1.SetItemCheckState(i, CheckState.Unchecked)
    End If
    Next
    End Sub
    End Class
    La vida loca

  • HT1212 i have an iphone 3s that was never connected to itunes but an icloud account was created and it is passcode disabled and i have tried the If you have never synced your device with iTunes recovery mode but it is still disabled

    i have an iphone 3s that was never connected to itunes but an icloud account was created and it is passcode disabled and i have tried the If you have never synced your device with iTunes recovery mode but it is still disabled it connected to itunes for a minute and then back to disabled

    Sounds like your iPhone was hacked to unlock and now updating locks back to the original carrier.
    Where did you get the iPhone?

  • DND from a JList with a single gesture

    I am writing an application that allows users to drag an item from a JList in one JInternalFrame to a JList in another. The users are complaining that "sometimes it works and sometimes it doesn't". I'm using JDK 1.4.2_02.
    As an example of the required behavior, imagine using the Windows Explorer to move a file from one directory to another. You do not have to click once on a file name to select it and click again to start the drag operation; you just click once and start dragging, whether the file was "selected" or not.
    However, when you try to drag from a JList, the gesture works only if the item you click on is already selected. Otherwise you have to click once on the item to select it and click again to start dragging. For most applications (for instance a word processor) you would expect this behavior, but for this application it is confusing and unacceptable. You feel like you're using a vaccuum cleaner that doesn't always pick up the dirt.
    The reason for the behavior can be found in the platform-dependent Swing code, in either com/sun/java/swing/plaf/gtk/SynthListUI.java or javax/swing/plaf/basic/BasicTextUI.java:
        private static final ListDragGestureRecognizer defaultDragRecognizer = new ListDragGestureRecognizer();
         * Drag gesture recognizer for JList components
        static class ListDragGestureRecognizer extends BasicDragGestureRecognizer {
          * Determines if the following are true:
          * <ul>
          * <li>the press event is located over a selection
          * <li>the dragEnabled property is true
          * <li>A TranferHandler is installed
          * </ul>
          * <p>
          * This is implemented to perform the superclass behavior
          * followed by a check if the dragEnabled
          * property is set and if the location picked is selected.
            protected boolean isDragPossible(MouseEvent e) {
             if (super.isDragPossible(e)) {
              JList list = (JList) this.getComponent(e);
              if (list.getDragEnabled()) {
                  ListUI ui = list.getUI();
                  int row = ui.locationToIndex(list, new Point(e.getX(),e.getY()));
                  if ((row != -1) && list.isSelectedIndex(row)) {
                   return true;
             return false;
        }Note that the method returns true only if the row is already selected.
    How can I fix this? The obvious method is to substitute my own version of ListDragGestureRecognizer, but that's an unsafe hack. BasicDragGestureRecognizer is not available to the application programmer and is potentially different for every platform and for different versions of the JVM. It's not "documented" that I know of, so there's no way to guarantee my own version is compatible.
    Mark Lutton

    First, see http://developer.java.sun.com/developer/bugParade/bugs/4521075.html
    There are two approaches there that worked for me: simon's and scmorr's. I prefer Simon's, but here is the code for both:
    1) based on scmorr's comments:
       private void fixListMouseListeners()
          MouseListener[] allMouseListeners = getMouseListeners();
          String listenerName = "javax.swing.plaf.basic.BasicListUI$ListDragGestureRecognizer";
          MouseListener listDragGestureRecognizer = null;
          // find the drag gesture listener we are looking for and remove it from
          // mouse listeners
          for (int i = 0; i < allMouseListeners.length; ++i)
             MouseListener currentListener = allMouseListeners[ i ];
             String currentListenerClassName = currentListener.getClass().getName();
             if (currentListenerClassName.equals(listenerName))
                listDragGestureRecognizer = currentListener;
                removeMouseListener(listDragGestureRecognizer);
                break;
          // add drag gesture listener back in at the end -- this allows the
          // mouse input handler (which does selection) to run first
          if (listDragGestureRecognizer != null)
             addMouseListener(listDragGestureRecognizer);
       }  // fixListMouseListeners()2) simon's approach:
       // the cached selection event
       private MouseEvent myCachedEvent;
        * overriding this so we can select and drag at same time
        * @param firstIndex is first interval index
        * @param lastIndex is last interval index
        * @param isAdjusting is whether event is an adjusting event
       protected void fireSelectionValueChanged(int firstIndex,
                                                int lastIndex,
                                                boolean isAdjusting)
          // now continue with update of whoever is listening to list for selection changes
          super.fireSelectionValueChanged(firstIndex, lastIndex, isAdjusting);
          // if the selection occurred and we have cached the event,
          // launch a copy of the cached event so dragging can occur right
          // away, if necessary
          if (myCachedEvent != null)
             super.processMouseEvent(new MouseEvent(               
                   (Component) myCachedEvent.getSource(),
                   myCachedEvent.getID(),     
                   myCachedEvent.getWhen(),     
                   myCachedEvent.getModifiersEx(),     
                   myCachedEvent.getX(),     
                   myCachedEvent.getY(),     
                   myCachedEvent.getClickCount(),     
                   myCachedEvent.isPopupTrigger()));
             myCachedEvent= null;
       }  // fireSelectionValueChanged()
        * overriding so we can cache the mouse event
        * @param e is the invoking event
       protected void processMouseEvent(MouseEvent e)
          int modifiers = e.getModifiersEx();
          // if clicked with left button, cache the event
          if ((modifiers & e.BUTTON1_DOWN_MASK) != 0)
             myCachedEvent = e;
          // go ahead and do normal processing on event
          super.processMouseEvent(e);
       }  // processMouseEvent()This does the job, but I had further requirements that required a bit more intervention. I am working with dragging an item between 2 JLists (single selection mode), and I am also trying to enforce that only one of my 2 lists can have a selection at any given time, using a ListSelectionListener, paying attention to events only if getValueIsAdjusting() is true.
    The problem comes if you abort a drag and then select an item in the other list that you weren't dragging from. When you drag, the list you drag from doesn't get a setValueIsAdjusting(false) since you don't get the mouseReleased() from MouseInputHandler, and leaving the list in "isAdjusting == true"-mode when a drag is aborted makes my selection stuff not work.
    My solution was to explictly call comp.setValueIsAdjusting(false) in my exportDone() function of my custom TransferHandler. Now everything is cool.

  • JList with no deselection allowed?

    Can I hav a JList (SINGLE_SELECTION selection mode). wherein the user is not allowed to deselect but only change the selection to another item????
    Is there a propery with the JList or its selection model that I can make use of??

    How about just resetting it?import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Test2 extends JFrame {
      JList jl = new JList(new String[] {"One","Two","Three","Four","Five","Six"});
      boolean inEvent=false;
      public Test2() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        content.add(new JScrollPane(jl), BorderLayout.CENTER);
        jl.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jl.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent lse) {
            if (inEvent || lse.getValueIsAdjusting()) return;
            inEvent=true;
            if (jl.getSelectedIndex()==-1) jl.setSelectedIndex(lse.getFirstIndex());
            inEvent=false;
        setSize(300,300);
      public static void main(String[] args) { new Test2().setVisible(true); }
    }

  • Disable select button in ALV report.

    Hi,
    i have an alv report with a select colunn, is there a way to disable a select botton in a specific row ?
    for example i have a report with 30 rows i want to disable the select botton in row 15.
    thanks
    Elad.

    Hi,
    Try this
    DATA ls_stylerow TYPE lvc_s_styl .
      DATA lt_styletab TYPE lvc_t_styl .
    Populate style variable (FIELD_STYLE) with style properties
      LOOP AT it_ekko INTO wa_ekko.       "loop on your internal table
        IF sy-tabix = 15.
          ls_stylerow-fieldname = 'SELECT' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
                                                 "set field to disabled
          APPEND ls_stylerow  TO wa_ekko-field_style.
          MODIFY it_ekko FROM wa_ekko.
        ENDIF.
      ENDLOOP.
    Thanks,
    Anitha A

  • Problem with checkbox selection in Tableview

    Hi All
    I am using table view with 8 columns - in the last 4 columns i have checkboxes for user input - i have a strange problem - when the table has multiple entries - for the last column i can only select the checkbox on line 1 - and i cannot select the checkbox on the remaining entries below - but for the other colums with checkboxes this is not the case
    The selection mode for the table is no line selection - since the table is already displayed with input enabled fields - this is to reduce the no of clicks for user
    Can anyone point out what is going wrong - how can i fix this - what i am doing wrong ?
    Thanks
    Sen

    Hi
    When i click on the checkbox for the 2nd or 3rd rows of the last column - nothing happens - the checkox is still active but nothing happens -
    this is the tableview code
    <htmlb:tableView id              = "Detail"
                     design          = "ALTERNATING"
                     headerText      = "Header Text"
                     onNavigate      = "onMyNavigate"
                     emptyTableText  = "test"
                     onRowSelection  = "onMyRowSelection"
                     fillUpEmptyRows = "false"
                     footerVisible   = "true"
                     visibleRowCount = "5"
                     table           = "<%= DETAILTAB %>"
                     iterator        = "<%= iterator %>" >
    and this is the code for the last column
    <htmlb:tableViewColumn columnName         = "OBSOFLGICON"
                               width               = "3"
                               type                = "user"
                               horizontalAlignment = "CENTER"
                               title               = "Obs" >
          <htmlb:checkbox />
        </htmlb:tableViewColumn>
    Thanks
    Sen

  • How to replace the existing selection screen with new selection screen

    Hi,
    I have first selection screen with parametre as a table name, then I have created dynamic selection screen as 2nd selection screen with different fields of that table as select options. This is done using genaration of dynamic report. Now If I click on button on this 2nd selction screen , then I want to replace this 2nd dynamic selection screen , with the other selection screen fields.
    Can anybody guide me, How to do replace one slection screen with different selection screen.
    and one imp thing is this selction screen is populating with dynamic fields on it.
    Regards,
    Mrunal

    As I can understand you want to make some of the screen field to disable or visible on screen  depending upon the interaction of user with screen 1.
    You may use this example code in PBO of screen 2.
    LOOP AT SCREEN.
        " action has been taken to modify the area office screen as per the option chosen at screen 99.
        CASE ACTION.
            " if the user has taken up the option of UPLOAD
          WHEN 'UP'.     " screen processing while we upload the plan
            " during upload we will make dates as output fields only
            IF SCREEN-NAME = 'ZSDTPLANVRSIO-DAT_TO' OR SCREEN-NAME = 'ZSDTPLANVRSIO-DAT_FRM'.
              SCREEN-INPUT = 0.
              MODIFY SCREEN.
            ENDIF.
            " also make 2 buttons disabled
            IF SCREEN-NAME = 'AO_DO' OR SCREEN-NAME = 'AO_VE'.
              SCREEN-ACTIVE = 0.
              MODIFY SCREEN.
            ENDIF.
          WHEN 'DN'.      " screen processing while we upload the approved plan
            " during upload we will make dates as output fields only
            IF SCREEN-NAME = 'ZSDTPLANVRSIO-DAT_TO' OR SCREEN-NAME = 'ZSDTPLANVRSIO-DAT_FRM'.
              SCREEN-INPUT = 0.
              MODIFY SCREEN.
            ENDIF.
            " also make 2 buttons disabled
            IF SCREEN-NAME = 'AO_UP' OR SCREEN-NAME = 'AO_VE'.
              SCREEN-ACTIVE = 0.
              MODIFY SCREEN.
            ENDIF.
          WHEN 'VW'.      " screen processing while we view the plan
            " during upload we will make dates as output fields only
            IF SCREEN-NAME = 'ZSDTPLANVRSIO-DAT_TO' OR SCREEN-NAME = 'ZSDTPLANVRSIO-DAT_FRM'.
              SCREEN-INPUT = 0.
              MODIFY SCREEN.
            ENDIF.
            " also make 2 buttons disabled
            IF SCREEN-NAME = 'RLGRAP-FILENAME' OR SCREEN-NAME = 'FNAME'.
              SCREEN-ACTIVE = 0.
              MODIFY SCREEN.
            ENDIF.
            " and hide the file input field
            IF SCREEN-NAME = 'AO_DO' OR SCREEN-NAME = 'AO_UP'.
              SCREEN-ACTIVE = 0.
              MODIFY SCREEN.
            ENDIF.
        ENDCASE.
      ENDLOOP.

  • How to create a table with multiple select on???

    Hi all,
            I am  new to webdynpro and my requirement is to create a  table with multiple selection on.I have to add abt 10 rows in the table but only 5 rows should be visible and moreover a verticalscroll should be available to view other rows.Can anybody explain me in detail how to do that.Please reply as if you are explaining  to a newcomer.Reply ASAP as i have to do it today.
                                                                           Thanxs

    Hi,
    1. Create a value node in your context name Table and set its cardinality to 0:n
    2. Create 2 value attributes within the Table node name value1 and value2
    3. Goto Outline view> Right click on TransparentUIContainer>Apply Template> Select Table>mark the node Table and it's attributes.
    you have created a table and binded its value to context
    Table UI properties
    4.Set Selection Mode to Multi
    5.Set Visible Row Count to 5
    6.ScrollableColCount to 5
    In your implemetaion, you can add values to table as follow:
    IPrivate<viewname>.ITableElement ele = wdContext.nodeTable().createTableElement();
    ele.setValue1(<value>);
    ele.setValue2(<value>);
    wdContext.nodeTable().addElement(ele);
    The above code will allow you to add elements to your table node.
    Regards,
    Murtuza

  • My macbook is stuck on a grey screen with language select and every time i click english it brings me back to the same gray page what do i do?

    My macbook Pro is stuck on a grey screen with language select and every time i click english it brings me back to the same gray page with language select what do i do? Also i dont have enough monet to go to the apple store to get it fix and another thing this happen after i tried to factory reset it without the disck uising coomans i found on youtube.Lastly befor doing the comands my macbook would open any applications and the finder would just blink on and off on the dock.
    Heres the link http://www.youtube.com/watch?v=Q5e5thk0O9o

    Shut down your computer and disconnect all peripherals (keyboard & mouse if pertinent) from your computer.  Now reboot.
    If the Mac starts up normally, shut it down again and then plug in one of the peripherals (keyboard or mouse first) and start up your computer again.  If it does so successfully repeat the process, adding one peripheral at a time until your Mac acts up.  At that point, disconnect the last peripheral you added, reboot your Mac and search the peripheral vendor's website for an updated driver. 
    If no driver exists or the problem remain after installing the new driver, try a different cable or a different port on your Mac.
    If none of the above works, again disconnect all peripherals from your Mac, hold down the "shift" key to start up in "Safe Boot" mode. 
    If the Mac starts up correctly, restart without pressing the "shift" key.
    If your computer still does not start up properly, shut it down and restart it while holding down the Apple+Option-P-R keys; keep holding "all 4 keys" down until you hear the startup sound "twice."
    If none of the above work Disconnect all peripherals from your computer. Boot from your install disc & run Repair Disk from the utility menu. To use the Install Mac OS X disc, insert the disc, and restart your computer while holding down the C key as it starts up.
    Select your language.
    Once on the desktop, select Utility in the menu bar.
    Select Disk Utility.
    Select the disk or volume in the list of disks and volumes, and then click First Aid.
    Click Repair Disk.
    (If Disk Utility cannot repair, you will need a stronger utility (3rd party) - Diskwarrior or Techtool PRO)
    Restart your computer when done.
    Repair permissions after you reach the desktop-http://docs.info.apple.com/article.html?artnum=25751 and restart your computer.
    Remove any 3rd party ram.
    Reinstall Leopard - This will install a "fresh" copy Leopard without archiving old system files but leaves the rest of your files in place.
    If you still want to restore your computer to factory level...
    Start up from your install disc, go to Disk Utility and select the disk and click erase - to securely erase data click Security Options and Erase Free Space which will entirely wipe your disk, overwriting it with zeros so that no data is recoverable.
    To restore read the instructions in the Mac OS X v10.5 Leopard - Installation and Setup Guide  PDF

Maybe you are looking for

  • HT3275 New macbook, old external drive for time machine

    I got a new macbook pro a few weeks ago and set it up using my last backup from time machine. I want to use the same external drive for backups but there is no room. Can I delete all of the old files from the old computer or do I need to keep them?

  • How to include a SWC using custom Console?

    Currently, it appears as if it is not possible to include an external SWC for use in a custom Console implementation. For instance, assume that I have a SWC: Foo.swc that contains the class com.test::Foo I also have a custom com.adobe.flascc.Console

  • Register soa composite has wrong hostname dest unreachable

    Hi All, I am trying to register an SOA Composite and getting dest unreachable because the hostname originally configured no longer exists. I have searched the file system looking for anything that has the old hostname but find nothing. where can i ch

  • Graphics and Textfields

    I was wondering if you use Graphics and objects like Buttons, Labels, and TextFields are they all drawn on the same graphics layer or is one of them drawn on top, if so which one?

  • Files saved at 72 ppi are showing up on user computer at 96ppi

    I am completely baffled by this one, so if anyone can help me figure it out it would be greatly appreciated. I'm creating an html email to send from an application called Vertical Response.  I created a photoshop document at 72ppi and did the designs