Custom enum

Hi all,
I was looking at some code earlier and saw a strange looking enum and would like to know how to replicate how it looks.
The two enums in the picture are the same (Copied and pasted) but how do I make the one on the right look like the one on the left.  They appear the same on the block diagram.
Lewis Gear CLD
Check out my LabVIEW UAV
Solved!
Go to Solution.
Attachments:
Custom Enum.vi ‏7 KB

Tabs work in a similar way.  On the front panel the control looks like a tab interface, but the block diagram has it acting like an enum.  This can be useful if you have a case in a state machine to update the user interface.  You can use wire the current value of the tab into a case statement, and only update the controls on that page of the tab control.
Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

Similar Messages

  • How to map a custom enum list to a custom form property in an extended incident class

    Hi,
    I'm struggeling to understand how to map a custom enum list to a custom form property in an extended incident class.
    Here's what i want to have happen:
    I am going to publish a request offering on my SMPortal for allowing users to submit basic IT incidents. I want the form to include "Whom does this problem affect" (answers(This is the custom enum list): Me, Multiple Users, Whole department or Whole
    company), "What is the problem about", "Description" and "Attachments".
    Here's what i've done:
    In the authoring tool i created a MP for the custom enum list and put only the list in it. I sealed the MP and imported it.
    I created another unsealed MP called TST.Incident.Library for storing incident library customizations and extended the incident class to add an extension class i called ClassExtension_Affected scope with a custom property i called AffectedScope. Then i am trying
    to set the datatype of this property to "list". In the "select a list" dialog i cannot chose my previously sealed MP with the custom enum list in it. Why?
    - Do i need to scratch the sealed MP and put the custom enum list in the latter TST.Incident.Library MP instead?
    - If so, can i do that and keep this MP unsealed, or will i get an error on import saying "Unsealed management packs should not contain type definitions"
    - Should i create one sealed MP for both the custom enum list and the extension class + custom property?

    Hi,
    Authoring Tool simply isn't informed about your list. Open the sealed management pack where you define the root of the list in the Authoring Tool and in the same time open TST.Incident.Library. You will have two opened MPs in the Authoring
    Tool and be able to add a custom list for your custom field.
    Cheers,
    Marat
    Site: www.scutils.com  Twitter:
      LinkedIn:
      Facebook:

  • Enum value not displaying in view - correct method to display in column?

    Hello again Experts,
    Having trouble with certain columns not populating in my custom class. I know I must have entered them incorrectly, hoping someone can shed some light on it.
    Its a custom work item class, so I borrowed the Work Item Status property but am obviously referencing it wrong...
    under my class properties its listed as follows:
    <Property ID="Status" Type="enum" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="56" MinLength="0" Required="false" Scale="0" EnumType="WorkItem!IncidentStatusEnum" />
    In my Columns definition its entered like this (this is where I made the mistake I think):
    <mux:Column Name="Status.DisplayName" DisplayMemberBinding="{Binding Path=IncidentStatusEnum.DisplayName, Mode=OneWay}" Width="100" DisplayName="Status" Property="Status.DisplayName" DataType="s:String" />
    Next is a custom enum called Source_List, here is the property again followed by the column definition:
    <Property ID="Source" Type="enum" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" EnumType="Source_List" />
    <mux:Column Name="Source.DisplayName" DisplayMemberBinding="{Binding Path=Source_List.DisplayName, Mode=OneWay}" Width="100" DisplayName="Source List" Property="Source.DisplayName" DataType="s:String" />
    The last one is "Destination FSL", below are the property and column definitions:
    <Property ID="Target_FSL" Type="enum" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" EnumType="Destination_FSL_List" />
    <mux:Column Name="Destination_FSL_List" DisplayMemberBinding="{Binding Path=Destination_FSL_List, Mode=OneWay}" Width="100" DisplayName="Destination FSL" Property="Target_FSL" DataType="s:String" />
    I know I've mucked them up pretty bad... I kept trying to change things around hoping I could get it to work so pls forgive my newbiness! Thanks in advance.

    Look at other views in Service Manager's management packs to get insight into how enum columns are configured.
    Change your binding paths to Status.DisplayName, Source.DisplayName, and Target_FSL.DisplayName respectively. You have to bind your columns to your object properties, not your lists.

  • Managed-property enum

    Hi,
    I would like to use a member of Java 5 enum as the value of a managed-property but I can't seem to get it to work. I have tried the following configurations in faces-config.xml
    <managed-property>
    <property-name>fieldName</property-name>
    <property-class>com.foo.MyEnum</property-class>
    <value>enumValue</value>
    </managed-property>
    Which produces the error:
    Can't instantiate class: 'enumValue'. I presume therefore that enums are not beans and don't have a default constructor. I sort of expected the valueOf method to be called but perhaps I was expecting to much.
    <managed-property>
    <property-name>fieldName</property-name>
    <property-class>com.foo.MyEnum.enumValue</property-class>
    <value>enumValue</value>
    </managed-property>
    Which claims it can't set the value of fieldName
    The enum is correct as I already use it elsewhere
    TIA
    Graham

    I found a solution.
    I needed to implement a PropertyEditor for my custom enum.
    Basically I had to create a class in the same package and have the same name as my enum with "Editor" suffixed.

  • Why does DISABLED disable a SCREEN RECTANGLE instead of just the control?

    I have solved this problem, but wanted to post it here for discussion.
    LabVIEW 7.0, Windows.
    I have a cluster: Item 0 is a custom enum control, item 1 is a string control.
    Under certain conditions in my program, the string field must be disabled (and grayed out), because it's not applicable.
    When I did that, I found that the enum was disabled as well. Actually, it would sometimes work if I hit the up-arrow just right, but the menu would never pop up. It worked find if the string was enabled.
    The string field (item 1) had a label above the left side of it. The enum (item 0) was positioned immediately above the right side of it.
    So why was item 0 disabled if item 1 was? I verified that the DISABLED property was NOT getting set to disabled (it reported 0 when I read it). There were no other property nodes to item 0.
    As it turns out, it seems that when the string was disabled, there was a RECTANGLE on screen which was disabled. In spite of the fact that neither the string field not its label overlapped the enum, the fact that the enum was within the string's RECTANGLE was disabling it. The fact that the enum's up-arrow extended above this rectangle is what made it work if I hit it just right (the top 1 or two pixels, i guess). I found this out by moving the enum off to the right (out from under this rectangle.
    My eventual solution was to go to the typedef for this cluster and move the enum IN FRONT of the string. I did not change the cluster order, just the physical front-to-back ordering. Now it works, with the enum back where I wanted it in the first place.
    I have attached a VI which demonstrates this. I tested it on LV 7.1 / OSX and it still fails. Not sure if it's a bug, or intended behavior.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks
    Attachments:
    BugTest.vi ‏34 KB

    I would say this is most probably optimation. While you can of course escalate a user event message all the way down to any of the lowest controls only to see in most cases that the control did not care about this message for whatever reasons, this adds significant delay to the event handling. So having the top level control (cluster) do a quick and dirty rectangular check to see which control should receive the message if any and only passing it to that control speeds things up significantly.
    Doing anything but a rectangular area check is again a performance problem as well as a never ending story of special cases which need to be handled just this tiny bit different to the rest, and any modification for a particular situation has often several undesired consequences for other cases.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Customizing Tab control and Enum

    I am trying to do two things here regarding customizing controls.
    The first is to add a down-arrow decoration to an enum so that it looks kind of like a menu ring (click the down arrow to drop down the selections).  If I simply paste it on top of the control, the decoration will intercept the click and not drop the selections down.  I want to have the control colored, so putting it behind and making the ring text background transparent doesn't really work either.  If I make it part of the "Ring Text" background element, it's fine for that one size, but if I resize the control it gets all stretched out.
    The second is to modify the "Page Labels Display" in a tab control.  The only selection allowed when attempting to customize the tab control is to "replace" the page labels display with a different control type.  Every enum or ring that I've tried has simply beeped at me with no replacement.  I would really like to get the aforementioned Ring-styled enum in this box as well.
    One other quirk that I haven't noticed before (Maybe since I haven't done a lot of work with tabs in the past), but when I'm trying to get context help for anything inside of a tab, the only thing that shows up is the context help for the tab itself.  Is that "working as expected"?
    Regards,
    Mike

    hi Mike, 
    there is another discussion forum covering your first question, but it sounds like your best bet would be a ComboBox: 
    This will give you the appearance you want, and behaves the same as an Enum.
    In order to set up a similar drop down menu of the pages of a Tab Control, it will be a little more indirect. Take a look at the attached example, which populates a combo box with the pages of a Tab Control. 
    That quirk you mentioned with the Context Help and Tab Controls is a known bug, and is fixed in LabVIEW 2011. Hope this helps!
    ~kgarrett
    Applications Engineer
    National Instruments
    Attachments:
    ex get pages from tab control.vi ‏10 KB

  • HOWTO: Create a Boot Configuration That Has No Driver Signature Checks. Disable Driver Integrity Checks and Install a Custom Non-Signed Driver

    Hello,
    Recently, I had a task where I needed to install a custom non-signed driver onto my Windows 8 64-bit setup. As it is known, Windows has driver enforcement policies that, as a security measure, do not allow you to install non-signed drivers.
    I did not want to alter my current boot configuration so I decided to create a separate boot entry that would have driver signing policies disabled. For some reason I did not find any good source that would contain a step-by-step instruction on completing
    this task, so I decided that I'd better share my experience here.
    Lastly, there are multiple ways how you could turn off driver enforcement policies, but I find the way to do this via boot manager.
    Here's how you can do that.
    1. Press WindowsKey and type 'cmd' (without quotes) to find Command prompt, then click Command prompt icon. If you have User Account Control turned on, hold Ctrl+Shift keys pressed when clicking the icon.
    This will force Windows to ask you for elevation of command prompt. Elevation is necessary for editing Boot Configuration Database (BCD), the database used by Windows boot manager to store boot settings.
    2. In the User Account Control window click Yes to confirm elevation of command shell.
    3. At the command prompt type
    bcdedit
    to list your BCD entries.
    This will give you an output like:
    Windows Boot Manager
    identifier {bootmgr}
    device partition=\Device\HarddiskVolume2
    path \EFI\Microsoft\Boot\bootmgfw.efi
    description Windows Boot Manager
    locale en-US
    inherit {globalsettings}
    integrityservices Enable
    default {current}
    resumeobject {a329b5cf-fb29-11e1-a74d-f2c962d62240}
    displayorder {a329b5d0-fb29-11e1-a74d-f2c962d62240}
    {a329b5cc-fb29-11e1-a74d-f2c962d62240}
    {a329b5ca-fb29-11e1-a74d-f2c962d62240}
    {a329b5c2-fb29-11e1-a74d-f2c962d62240}
    {current}
    {a329b5d8-fb29-11e1-a74d-f2c962d62240}
    toolsdisplayorder {memdiag}
    timeout 30
    Windows Boot Loader
    identifier {a329b5d0-fb29-11e1-a74d-f2c962d62240}
    device vhd=[D:]\win8prowmc01.vhdx
    path \Windows\system32\winload.efi
    description Windows 8
    locale en-US
    inherit {bootloadersettings}
    recoverysequence {a329b5d1-fb29-11e1-a74d-f2c962d62240}
    recoveryenabled Yes
    isolatedcontext Yes
    allowedinmemorysettings 0x15000075
    osdevice vhd=[D:]\win8prowmc01.vhdx
    systemroot \Windows
    resumeobject {a329b5cf-fb29-11e1-a74d-f2c962d62240}
    nx OptIn
    bootmenupolicy Standard
    The section that starts with Windows Boot Manager lists current settings for the boot menu. Here you find what boot entry is chosen by default, this is the one what you will boot into if you do not select any boot entry in the
    boot menu.
    The following record
    default {current}
    indicates that by default my Windows boots into configuration which I use at the moment (currently booted Windows configuration).
    To find out what exactly is current configuration, look into the list of boot entries, records that contain boot loader configuration and are titled as Windows Boot Loader in the bcdedit output.
    For example, the entry shown above is one of my boot configurations. This is one of the boot entries listed on the boot manager screen when I start my PC and it looks like:
    Windows Boot Loader
    identifier {a329b5d0-fb29-11e1-a74d-f2c962d62240}
    device vhd=[D:]\win8prowmc01.vhdx
    path \Windows\system32\winload.efi
    description Windows 8
    locale en-US
    inherit {bootloadersettings}
    recoverysequence {a329b5d1-fb29-11e1-a74d-f2c962d62240}
    recoveryenabled Yes
    isolatedcontext Yes
    allowedinmemorysettings 0x15000075
    osdevice vhd=[D:]\win8prowmc01.vhdx
    systemroot \Windows
    resumeobject {a329b5cf-fb29-11e1-a74d-f2c962d62240}
    nx OptIn
    bootmenupolicy Standard
    This record has a unique GUID identifier that can be used to reference this boot entry, which is:
    identifier {a329b5d0-fb29-11e1-a74d-f2c962d62240}
    If we look at the Windows Boot Manager settings, we'll see this entry is the first in order to be displayed in the boot menu on OS start (I marked the unique bits):
    displayorder {a329b5d0-fb29-11e1-a74d-f2c962d62240}
    {a329b5cc-fb29-11e1-a74d-f2c962d62240}
    It references my VHD drive, a virtual hard drive where my Windwos 8 setup is residing:
    device vhd=[D:]\win8prowmc01.vhdx
    And it also specifies that the boot manager must use UEFI BIOS extension code to access my Windows boot partition:
    path \EFI\Microsoft\Boot\bootmgfw.efi
    3. Now locate the current boot entry.
    Current boot entry contains boot settings used to boot into Windows configuration to which you are currently booted. It is referenced in the list of boot entries as a Windows Boot Loader record that has the {current} keyword inside and may
    look like:
    Windows Boot Loader
    identifier {current}
    device vhd=[D:]\win8rtm.vhdx
    path \Windows\system32\winload.efi
    description Windows 8 Enterprise RTM
    locale en-US
    inherit {bootloadersettings}
    recoverysequence {a329b5c3-fb29-11e1-a74d-f2c962d62240}
    integrityservices Enable
    recoveryenabled Yes
    isolatedcontext Yes
    allowedinmemorysettings 0x15000075
    osdevice vhd=[D:]\win8rtm.vhdx
    systemroot \Windows
    resumeobject {a329b5c1-fb29-11e1-a74d-f2c962d62240}
    nx OptIn
    bootmenupolicy Standard
    hypervisorlaunchtype Auto
    Because we are more than happy with current configuration and want to base our new boot configuration on these settings, we need to copy this boot entry ({current}) to a new boot entry.
    This is done by running the following command:
    C:\Windows\system32>bcdedit /copy {current} /d "No Driver Signature Check"
    Parameter /d here indicates that the following sequence of characters specifies the display name for the new boot entry that we are creating. The name inside the double quotes will be displayed in the boot menu when you boot your Windows.
    In other words, if you know restart your system, you'll see the new No Driver Signature Check in the boot menu.
    When copied, the entry is automatically given a new GUID identifier, so upon running the command above, you'll see the following line returned (you'll have an other GUID since these are unique identifiers):
    The entry was successfully copied to {a329b5d8-fb29-11e1-a74d-f2c962d62240}.
    4. Make sure the entry has been successfully created.
    Run the same bcdedit. (You may specify /enum or /v, or both /enum /v parameters at the prompt to get more detail about boot entries, but simple bcdedit is just enough to see the new entry):
    C:\Windows\system32>bcdedit
    Windows Boot Manager
    identifier {bootmgr}
    device partition=\Device\HarddiskVolume2
    path \EFI\Microsoft\Boot\bootmgfw.efi
    description Windows Boot Manager
    locale en-US
    inherit {globalsettings}
    integrityservices Enable
    default {current}
    resumeobject {a329b5cf-fb29-11e1-a74d-f2c962d62240}
    displayorder {a329b5d0-fb29-11e1-a74d-f2c962d62240}
    {a329b5cc-fb29-11e1-a74d-f2c962d62240}
    {a329b5ca-fb29-11e1-a74d-f2c962d62240}
    {a329b5c2-fb29-11e1-a74d-f2c962d62240}
    {current}
    {a329b5d8-fb29-11e1-a74d-f2c962d62240}
    toolsdisplayorder {memdiag}
    timeout 30
    Windows Boot Loader
    identifier {current}
    device vhd=[D:]\win8rtm.vhdx
    path \Windows\system32\winload.efi
    description Windows 8 Enterprise RTM
    locale en-US
    inherit {bootloadersettings}
    recoverysequence {a329b5c3-fb29-11e1-a74d-f2c962d62240}
    integrityservices Enable
    recoveryenabled Yes
    isolatedcontext Yes
    allowedinmemorysettings 0x15000075
    osdevice vhd=[D:]\win8rtm.vhdx
    systemroot \Windows
    resumeobject {a329b5c1-fb29-11e1-a74d-f2c962d62240}
    nx OptIn
    bootmenupolicy Standard
    hypervisorlaunchtype Auto
    Windows Boot Loader
    identifier {a329b5d8-fb29-11e1-a74d-f2c962d62240}
    device vhd=[D:]\win8rtm.vhdx
    path \Windows\system32\winload.efi
    description No Driver Signature Check
    locale en-US
    inherit {bootloadersettings}
    recoverysequence {a329b5c3-fb29-11e1-a74d-f2c962d62240}
    integrityservices Enable
    recoveryenabled Yes
    isolatedcontext Yes
    allowedinmemorysettings 0x15000075
    osdevice vhd=[D:]\win8rtm.vhdx
    systemroot \Windows
    resumeobject {a329b5c1-fb29-11e1-a74d-f2c962d62240}
    nx OptIn
    bootmenupolicy Standard
    hypervisorlaunchtype Auto
    The entry has been created and given a unique a329b5d8-fb29-11e1-a74d-f2c962d62240 ID. It now has exactly same boot settings as the boot entry we used to boot into current configuration of Windows.
    5. Modify created  No Driver Signature Check entry and specify that Windows must have driver integrity checks disabled when booted using this boot entry.
    Any modifications to boot entries are made using /set parameter. To indicate that we modify a specific boot entry, we must specify the GUID for the No Driver Signature Check record, which is:
    identifier {a329b5d8-fb29-11e1-a74d-f2c962d62240}
    In other words, to edit (add or change) an option for the boot entry, we need to use the following command syntax:
    C:\Windows\system32>bcdedit /set GUID <boot_option> [<option_value>]
    First, we must specify that we don't want integrity checks be made. This is done by adding the loadoptions option and setting it to DISABLE_INTEGRITY_CHECKS value:
    C:\Windows\system32>bcdedit /set {a329b5d8-fb29-11e1-a74d-f2c962d62240} loadopti
    ons DISABLE_INTEGRITY_CHECKS
    The operation completed successfully.
    6. Verify that load option has been added.
    Run the bcdedit command:
    Windows Boot Loader
    identifier {current}
    device vhd=[D:]\win8rtm.vhdx
    path \Windows\system32\winload.efi
    description Windows 8 Enterprise RTM
    locale en-US
    inherit {bootloadersettings}
    recoverysequence {a329b5c3-fb29-11e1-a74d-f2c962d62240}
    integrityservices Enable
    recoveryenabled Yes
    isolatedcontext Yes
    allowedinmemorysettings 0x15000075
    osdevice vhd=[D:]\win8rtm.vhdx
    systemroot \Windows
    resumeobject {a329b5c1-fb29-11e1-a74d-f2c962d62240}
    nx OptIn
    bootmenupolicy Standard
    hypervisorlaunchtype Auto
    Windows Boot Loader
    identifier {a329b5d8-fb29-11e1-a74d-f2c962d62240}
    device vhd=[D:]\win8rtm.vhdx
    path \Windows\system32\winload.efi
    description No Driver Signature Check
    locale en-US
    loadoptions DISABLE_INTEGRITY_CHECKS
    inherit {bootloadersettings}
    recoverysequence {a329b5c3-fb29-11e1-a74d-f2c962d62240}
    integrityservices Enable
    recoveryenabled Yes
    isolatedcontext Yes
    allowedinmemorysettings 0x15000075
    osdevice vhd=[D:]\win8rtm.vhdx
    systemroot \Windows
    resumeobject {a329b5c1-fb29-11e1-a74d-f2c962d62240}
    nx OptIn
    bootmenupolicy Standard
    hypervisorlaunchtype Auto
    7. Add the option that turns on test signing mode and disables checks of driver signature.
    Adding the testsigning option and setting it to ON does the trick for us:
    C:\Windows\system32>bcdedit /set {a329b5d8-fb29-11e1-a74d-f2c962d62240} TESTSIGNING ON
    8. Now we have a boot entry that enables Windows not to do integrity checks and digital signature validation.
    We check it by running bcdedit:
    Windows Boot Loader
    identifier {a329b5d8-fb29-11e1-a74d-f2c962d62240}
    device vhd=[D:]\win8rtm.vhdx
    path \Windows\system32\winload.efi
    description No Driver Signature Check
    locale en-US
    loadoptions DISABLE_INTEGRITY_CHECKS
    inherit {bootloadersettings}
    recoverysequence {a329b5c3-fb29-11e1-a74d-f2c962d62240}
    integrityservices Enable
    recoveryenabled Yes
    testsigning Yes
    isolatedcontext Yes
    allowedinmemorysettings 0x15000075
    osdevice vhd=[D:]\win8rtm.vhdx
    systemroot \Windows
    resumeobject {a329b5c1-fb29-11e1-a74d-f2c962d62240}
    nx OptIn
    bootmenupolicy Standard
    hypervisorlaunchtype Auto
    9. Type 'exit' without quotes to exit from command prompt, and restart Windows.
    Upon booting you will be present with a new boot option to start Windows in configuration that allows you to install custom non-signed drivers.
    Hope this will help anybody to create their own custom boot configurations.
    Well this is the world we live in And these are the hands we're given...

    Hi,
    Thank you for sharing the solutions & experience here. It will be very beneficial for other community members who have similar questions. 
    Regards,
    Kelvin hsu
    TechNet Community Support

  • How to use in enums in multiple places?

    How does one use an enum set in multiple places in a vi?
    I have resorted to just copying an existing one when I need the same set of enum values in a different spot, but doing it this way will be a big hassle if/when I want to add items to the enum, because I would have to locate every copy of the enum and update them idividually.
    Is it possible?

    It's not so much the "custom control" part as it is the typedef part. A typedef enforces the datatype for all its instances, including constants, so changing it will propogate through your entire code. To create it the easiest way is to create a front panel enum control and then right click it and select Advanced>>Customize. You can then change it into a typedef and save it under any name you want.
    From this point on, you can simply use that typedef in your code.
    To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
    Try to take over the world!

  • How can I establish an enum typedef for use with state machines and action engines?

    Hey all--
    I have an action engine with several instances.  Any time that I add a method to the engine, I have to modify all of the calling code to update the constant that determines the method being called.  There must be a smarter way to address this problem but my LV experience is insufficient to identify it.  Can any of you wiz-bangs tell me if it is possible to make a type def (I can do this) and use it with each instance of the action engine call so that changing any instance also updates the typedef?
    Thanks.

    Take your enumerator.  If it is not a control (ie constant), change it to a control.
    Under File Menu, select New > Custom Control.
    Move (or copy) your Enum Control to the Custom Control.  Change the Control to Strict Type Def (the selection to the right of the wrench).  Save it.
    (EDIT: ** OOps, the picture shows the wrong one.. sorry**)
    Copy that new Strict Type Def control to your code.
    See images below.
    OR.. If you're using LV8.x, and using a project, I would recomment that you do it from within your project explorer.  Simply insert a new "Control".  The rest of the steps are similar, except that you can insert it from your project. 
    R
    Message Edited by JoeLabView on 07-08-2008 06:47 PM
    Attachments:
    TypeDef.PNG ‏33 KB

  • Problem with focus border and ListCellRenderer in custom listbox

    I have a bug in some code that I adapted from another posting on this board -- basically what I've done is I have a class that implements a custom "key/value" mapping listbox in which each list item/cell is actually a JPanel consisting of 3 JLabels: the first label is the "key", the second is a fixed "==>" mapping string, and the 3rd is the value to which "key" is mapped.
    The code works fine as long as the list cell doesn't have the focus. When it does, it draws a border rectangle to indicate focus, but if the listbox needs to scroll horizontally to display all the text, part of the text gets cut off (i.e. "sometex..." where "sometext" should be displayed).
    The ListCellRenderer creates a Gridlayout to lay out the 3 labels in the cell's JPanel.
    What can I do to remedy this situation? I'm not sure what I'd need to do in terms of setting the size of the panel so that all the text gets displayed OK within the listbox. Or if there's something else I can do to fix this. The code and a main() to run the code are provided below. To reproduce the problem, click the Add Left and Add Right buttons to add a "mapping" -- when it doesn't have focus, everything displays fine, but when you give it focus, note the text on the right label gets cut off.
    //======================================================================
    // Begin Source Listing
    //======================================================================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.Vector;
    import java.util.Enumeration;
    public class TwoColumnListbox extends JPanel
    private JList m_list;
    private JScrollPane m_Pane;
    public TwoColumnListbox(Collection c)
         DataMapListModel model = new DataMapListModel();
         if (c != null)
         Iterator it = c.iterator();
         while (it.hasNext())
         model.addElement(it.next());
         m_list = new JList(model);
         ListBoxRenderer renderer= new ListBoxRenderer();
              m_list.setCellRenderer(renderer);
              setLayout(new BorderLayout());
              m_list.setVisibleRowCount(4);
              m_Pane = new JScrollPane(m_list);
              add(m_Pane, BorderLayout.NORTH);
    public JList getList()
    return m_list;
    public JScrollPane getScrollPane()
    return m_Pane;
    public static void main(String s[])
              JFrame frame = new JFrame("TwoColumnListbox");
              frame.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {System.exit(0);}
    final DataMappings dm = new DataMappings();
    final TwoColumnListbox lb = new TwoColumnListbox(dm.getMappings());
              final DataMap map = new DataMap();
              JButton leftAddBtn = new JButton("Add Left");
              leftAddBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e)
              map.setSource("JButton1");
              DefaultListModel model = new DefaultListModel();
              model.addElement(map);
              lb.getList().setModel(model);
              JButton leftRemoveBtn = new JButton("Remove Left");
              leftRemoveBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e)
              map.setSource("");
              DefaultListModel model = new DefaultListModel();
              model.addElement(map);
              lb.getList().setModel(model);
              JButton rightAddBtn = new JButton("Add Right");
    rightAddBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e)
              map.setDestination("/getQuote/symbol[]");
              DefaultListModel model = new DefaultListModel();
              model.addElement(map);
              lb.getList().setModel(model);
              JButton rightRemoveBtn = new JButton("Remove Right");
    rightRemoveBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e)
              map.setDestination("");
              DefaultListModel model = new DefaultListModel();
              model.addElement(map);
              lb.getList().setModel(model);
              JPanel leftPanel = new JPanel(new BorderLayout());
              leftPanel.add(leftAddBtn, BorderLayout.NORTH);
              leftPanel.add(leftRemoveBtn, BorderLayout.SOUTH);
    JPanel rightPanel = new JPanel(new BorderLayout());
              rightPanel.add(rightAddBtn, BorderLayout.NORTH);
              rightPanel.add(rightRemoveBtn, BorderLayout.SOUTH);
    frame.getContentPane().add(leftPanel, BorderLayout.WEST);
              frame.getContentPane().add(lb,BorderLayout.CENTER);
    frame.getContentPane().add(rightPanel, BorderLayout.EAST);
              frame.pack();
              frame.setVisible(true);
         class ListBoxRenderer extends JPanel implements ListCellRenderer
              private JLabel left;
              private JLabel arrow;
              private JLabel right;
              private Color clrForeground = UIManager.getColor("List.foreground");
    private Color clrBackground = UIManager.getColor("List.background");
    private Color clrSelectionForeground = UIManager.getColor("List.selectionForeground");
    private Color clrSelectionBackground = UIManager.getColor("List.selection.Background");
              public ListBoxRenderer()
                   setLayout(new GridLayout(1, 2, 10, 0));
                   //setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
                   left = new JLabel("");
                   left.setForeground(clrForeground);               
                   arrow = new JLabel("");
                   arrow.setHorizontalAlignment(SwingConstants.CENTER);
                   arrow.setForeground(clrForeground);
                   right = new JLabel("");
                   right.setHorizontalAlignment(SwingConstants.RIGHT);
                   right.setForeground(clrForeground);
                   add(left);
                   add(arrow);
                   add(right);
              public Component getListCellRendererComponent(JList list, Object value,
                        int index, boolean isSelected, boolean cellHasFocus)
                   if (isSelected)
                        setBackground(list.getSelectionBackground());
                        setForeground(list.getSelectionForeground());
                        left.setForeground(clrSelectionForeground);
                        arrow.setForeground(clrSelectionForeground);
                        right.setForeground(clrSelectionForeground);
                   else
                        setBackground(list.getBackground());
                        setForeground(list.getForeground());
                   left.setForeground(clrForeground);
                        arrow.setForeground(clrForeground);
                        right.setForeground(clrForeground);               
                   // draw focus rectangle if control has focus. Problem with focus
    // and cut off text!!
                   if (cellHasFocus)
                   // FIXME: for Windows LAF I'm not getting the correct thing here for some reason.
                   // Looks OK on Metal though.
                   setBorder(BorderFactory.createLineBorder(UIManager.getColor("focusCellHighlightBorder")));
                   else
                   setBorder(BorderFactory.createEmptyBorder());               
    DataMap map = (DataMap) value;
                   String displaySource = map.getSource();
                   String displayDest = map.getDestination();
                   left.setText(displaySource);
                   arrow.setText("=>to<=");
                   right.setText(displayDest);
                   return this;
    /** Interface for macro editor UI
    * @version 1.0
    class DataMappings
    private Collection mappings;
    public DataMappings()
    setMappings(new Vector(0));
    public DataMappings(Collection maps)
    setMappings(maps);
    /** gets mapping value of a specified source object
    * @param src -- the "key" or source object, what is mapped.
    * @return what the source object is mapped to
    * @version 1.0
    public Object getValue(String src)
    if (src != null)
    Iterator it = mappings.iterator();
    while (it.hasNext());
    DataMap thisMap = (DataMap) it.next();
    if (thisMap.getSource().equals(src))
    return thisMap.getDestination();
    return null;
    /** sets mapping value of a specified source object
    * @param src -- the "key" or source object, what is mapped.
    * @param what the source object is to be mapped to
    * @version 1.0
    public void setValue(String src, String dest)
    if (src != null)
    // see if the value is in there first.
    Iterator it = mappings.iterator();
    while (it.hasNext())
    DataMap thisMap = (DataMap) it.next();
    if (thisMap.getSource().equals(src))
    thisMap.setDestination(dest);
    return;
    // not in the collection, add it
    mappings.add(new DataMap(src, dest));
    /** gets collection of mappings
    * @return a collection of all mappings in this object.
    * @version 1.0
    public Collection getMappings()
    return mappings;
    /** sets collection of mappings
    * @param maps a collection of src to destination mappings.
    * @version 1.0
    public void setMappings(Collection maps)
    mappings = maps;
    /** adds a DataMap
    * @param map a DataMap to add to the mappings
    * @version 1.0
    public void add(DataMap map)
    if (map != null)
    mappings.add(map);
    class DataMap
    public DataMap() {}
    public DataMap(String source, String destination)
    m_source = source;
    m_destination = destination;
    public String getSource()
    return m_source;
    public void setSource(String s)
    m_source = s;
    public String getDestination()
    return m_destination;
    public void setDestination(String s)
    m_destination = s;
    protected String m_source = null;
    protected String m_destination = null;
    /** list model for datamaps that provides ways
    * to determine whether a source is already mapped or
    * a destination is already mapped.
    class DataMapListModel extends DefaultListModel
    public DataMapListModel()
    super();          
    /** determines whether a source is already mapped
    * @param src -- the source property of a datamapping
    * @return true if the source is in the list, false if not
    public boolean containsSource(Object src)
    Enumeration enum = elements();
    while (enum.hasMoreElements())
    DataMap dm = (DataMap) enum.nextElement();
    if (dm.getSource().equals(src))
    return true;
    return false;
    /** determines whether a destination is already mapped
    * @param dest -- the destination property of a datamapping
    * @return true if the destination is in the list, false if not
    public boolean containsDest(Object dest)
    Enumeration enum = elements();
    while (enum.hasMoreElements())
    DataMap dm = (DataMap) enum.nextElement();
    if (dm.getDestination().equals(dest))
    return true;
    return false;
    public DataMappings getDataMaps()
    DataMappings maps = new DataMappings();
    // add all the datamaps in the model
    Enumeration enum = elements();
    while (enum.hasMoreElements())
    DataMap dm = (DataMap) enum.nextElement();
    maps.add(dm);
    return maps;
    //======================================================================
    // End of Source Listing
    //======================================================================

    I did not read the program, but the chopping looks like a layout problem.
    I think it's heavy to use a panel + 3 components in a gridlayout for each cell. look at this sample where i draw the Cell myself,
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    public class Jlist3 extends JFrame 
         Vector      v  = new Vector();
         JList       jc = new JList(v);
         JScrollPane js = new JScrollPane(jc);
    public Jlist3()
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         for (int j=0; j < 70; j++)     v.add(""+j*1000+"a  d"+j);
           setBounds(1,1,400,310);
         getContentPane().add(js);
         js.setPreferredSize(new Dimension(230,259));
         jc.setSelectedIndex(1);
         jc.setCellRenderer(new MyCellRenderer());
         getContentPane().setLayout(new FlowLayout());
         setVisible(true);
    public class MyCellRenderer extends JLabel implements ListCellRenderer
         String  txt;
         int     idx;
         boolean sel;
    public Component getListCellRendererComponent(JList list,
                             Object  value,           // value to display
                             int     index,           // cell index
                             boolean isSelected,      // is the cell selected
                             boolean cellHasFocus)    // the list and the cell have the focus
         idx = index;
         txt = value.toString();
         sel = isSelected;
         setText(txt);
         return(this);
    public void paintComponent(Graphics g)
         if (idx%2 == 1) g.setColor(Color.white);
              else        g.setColor(Color.lightGray);
         if (sel)        g.setColor(Color.blue);
         g.fillRect(0,0,getWidth(),getHeight());
         StringTokenizer st = new StringTokenizer(txt.trim()," ");
         g.setColor(Color.black);
         if (st.hasMoreTokens())     g.drawString(st.nextToken(),1,14);
         g.setColor(Color.red);
         g.drawString("===>",70,14);
         g.setColor(Color.black);
         if (st.hasMoreTokens())     g.drawString(st.nextToken(),110,14);
    public static void main (String[] args) 
         new Jlist3();
    Noah
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    public class Jlist3 extends JFrame
         Vector v = new Vector();
         JList jc = new JList(v);
         JScrollPane js = new JScrollPane(jc);
    public Jlist3()
         addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         for (int j=0; j < 70; j++)     v.add(""+j*1000+"a d"+j);
         setBounds(1,1,400,310);
         getContentPane().add(js);
         js.setPreferredSize(new Dimension(230,259));
         jc.setSelectedIndex(1);
         jc.setCellRenderer(new MyCellRenderer());
         getContentPane().setLayout(new FlowLayout());
         setVisible(true);
    public class MyCellRenderer extends JLabel implements ListCellRenderer
         String txt;
         int idx;
         boolean sel;
    public Component getListCellRendererComponent(JList list,
                             Object value, // value to display
                             int index, // cell index
                             boolean isSelected, // is the cell selected
                             boolean cellHasFocus) // the list and the cell have the focus
         idx = index;
         txt = value.toString();
         sel = isSelected;
         setText(txt);
         return(this);
    public void paintComponent(Graphics g)
         if (idx%2 == 1) g.setColor(Color.white);
              else g.setColor(Color.lightGray);
         if (sel) g.setColor(Color.blue);
         g.fillRect(0,0,getWidth(),getHeight());
         StringTokenizer st = new StringTokenizer(txt.trim()," ");
         g.setColor(Color.black);
         if (st.hasMoreTokens())     g.drawString(st.nextToken(),1,14);
         g.setColor(Color.red);
         g.drawString("===>",70,14);
         g.setColor(Color.black);
         if (st.hasMoreTokens())     g.drawString(st.nextToken(),110,14);
    public static void main (String[] args)
         new Jlist3();
    }

  • Custom ComboBoxEditor and event notification at the end of the edition

    Hi,
    I am trying to write a custom ComboBoxEditor that delegates editing to a JFormattedTextField for inputing only integers in a JComboBox. However unlike the JTable and JTree editors, I find that the documentation is not clear on how to notify the parent combo box that the editing has finished and the user value has been validated. Since ComboBoxEditor has the addActionListener() and removeActionListener() methods in its signature, I naturally assumed that I could fire an ActionEvent to notify the combo when for example the JFormattedTextField just fired a PropertyChangeEvent on the "value" property.
    While it looks like this is working OK at first, this causes the following issue: when the component is displayed in a JOptionPane, the dialog box is closed as soon as the ActionEvent is fired which is definitely not the behavior we want the user to experience (note: the event is fired when the delegated editor loses focus for exemple by clicking in the JTextArea in the provided example). I find this quite odd as the default ComboBoxEditor does not behave this way: when the editor looses focus, the combo box simply fires an ItemEvent; however the code from the basic UI or the metal UI never fire an ActionEvent and thus supposedly never notify the parent combo (!). Of course if I disable the ActionEvent firing, the JOptionPane does not close but the JComboBox never fire an ItemEvent...
    Do you have any idea or suggestions to fix this problem?
    Note : for testing purposes, I also made a custom ComboBoxEditor delegating to a JSpinner*. This one experiences exactly the same issue than the one delegating to a JFormattedTextField.
    *Speaking of which: how come JSpinner does not have an API for its own editor??
    package test;
    import java.awt.*;
    import java.awt.event.*;
    import java.beans.*;
    import java.text.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    * @author  fabriceb
    public class TestComboBoxEditor extends JPanel {
      enum Flavor {
        J_FORMATTED_TEXT_FIELD, J_SPINNER, DEFAULT;
      private static final long serialVersionUID = 1l;
       * Default font sizes.
      private static final int[] DEFAULT_SIZE = {8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72};
       * Editing flag.
      private boolean isEditing;
      private JComboBox sizeCombo = new JComboBox(new DefaultComboBoxModel());
      private JTextArea textArea = new JTextArea("abcdefghijklmnopqrstuvwxyz\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n1234567890.:,;()[]{}<>/\\+-*=!?_'\"@#$%^%&\nThe quick brown fox jumps over the lazy dog. 1234567890");
      private Flavor flavor = Flavor.J_FORMATTED_TEXT_FIELD;
      private boolean fireActionPerformed = true;
      public TestComboBoxEditor(Flavor flavor) {
        super();
        setPreferredSize(new Dimension(500, 150));
        this.flavor = flavor;
        setLayout(new BorderLayout());
        add(sizeCombo, BorderLayout.NORTH);
        add(new JScrollPane(textArea), BorderLayout.CENTER);
        textArea.setEditable(false);
        textArea.setLineWrap(true);
        textArea.setRows(5);
        sizeCombo.setEditable(true);
        sizeCombo.setMaximumRowCount(5);
        switch (flavor) {
          case J_FORMATTED_TEXT_FIELD:
            sizeCombo.setEditor(new SizeComboBoxEditor());
            break;
          case J_SPINNER: {
            sizeCombo.setEditor(new Size2ComboBoxEditor());
        DefaultComboBoxModel sizeModel = (DefaultComboBoxModel) sizeCombo.getModel();
        for (int size : DEFAULT_SIZE) {
          sizeModel.addElement(size);
        sizeCombo.setSelectedItem(textArea.getFont().getSize());
        sizeCombo.addItemListener(new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent event) {
            if (isEditing) {
              return;
            switch (event.getStateChange()) {
              case ItemEvent.SELECTED:
                  Object value = sizeCombo.getSelectedItem();
                  System.out.println("Received " + value + "\t" + value.getClass());
                  if ((value instanceof Integer) || (value instanceof Long)) {
                    int size = ((Number) value).intValue();
                    DefaultComboBoxModel sizeModel = (DefaultComboBoxModel) sizeCombo.getModel();
                    int sizeCount = sizeModel.getSize();
                    for (int i = 0; i <
                      sizeCount; i++) {
                      int val = ((Number) sizeModel.getElementAt(i)).intValue();
                      // Value already in combo.
                      if (size == val) {
                        break;
    // Insert before current value.
                      else if (val > size) {
                        sizeModel.insertElementAt(size, i);
                        break;
                      // Add at end.
                      else if (i == sizeCount - 1) {
                        sizeModel.addElement(size);
                        break;
                    applyNewFont();
                break;
       * Produces a new font from the user input.
      protected void applyNewFont() {
        int size = ((Number) sizeCombo.getSelectedItem()).intValue();
        Font font = textArea.getFont().deriveFont((float) size);
        textArea.setFont(font);
       * Self-test main.
       * @param args Arguments from the command line.
      public static void main(String... args) {
        SwingUtilities.invokeLater(new Runnable() {
           * {@inheritDoc}
          @Override
          public void run() {
            try {
              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              final JFrame frame = new JFrame("Test");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
              for (final Flavor flavor : Flavor.values()) {
                JPanel panel = new JPanel();
                panel.setLayout(new FlowLayout(FlowLayout.LEFT));
                panel.add(new TestComboBoxEditor(flavor));
                switch (flavor) {
                  case J_FORMATTED_TEXT_FIELD:
                  case J_SPINNER:
                    JButton forwardEventButton = new JButton("Forward event");
                    forwardEventButton.addActionListener(new ActionListener() {
                      @Override
                      public void actionPerformed(ActionEvent event) {
                        JOptionPane.showMessageDialog(frame, new TestComboBoxEditor(flavor), flavor + " - Event forwarded", JOptionPane.INFORMATION_MESSAGE);
                    panel.add(forwardEventButton);
                    JButton doNotForwardEventButton = new JButton("Do Not Forward event");
                    doNotForwardEventButton.addActionListener(new ActionListener() {
                      @Override
                      public void actionPerformed(ActionEvent event) {
                        TestComboBoxEditor test = new TestComboBoxEditor(flavor);
                        test.fireActionPerformed = false;
                        JOptionPane.showMessageDialog(frame, test, flavor + " - Event not forwarded", JOptionPane.INFORMATION_MESSAGE);
                    panel.add(doNotForwardEventButton);
                    break;
                  case DEFAULT:
                    JButton openButton = new JButton("Dialog");
                    openButton.addActionListener(new ActionListener() {
                      @Override
                      public void actionPerformed(ActionEvent event) {
                        JOptionPane.showMessageDialog(frame, new TestComboBoxEditor(flavor), flavor + " - Default editor", JOptionPane.INFORMATION_MESSAGE);
                    panel.add(openButton);
                frame.add(panel);
              frame.pack();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
            catch (Exception e) {
              e.printStackTrace();
       * A combo box editor that only accepts integers.
       * @author  fabriceb
      private class SizeComboBoxEditor implements ComboBoxEditor, PropertyChangeListener, FocusListener {
        private JFormattedTextField delegated = new JFormattedTextField(new NumberFormatter(NumberFormat.getIntegerInstance()));
        private EventListenerList listenerList = new EventListenerList();
        private boolean isEditing;
         * Creates a new instance.
        public SizeComboBoxEditor() {
          delegated.addPropertyChangeListener("value", this);
          delegated.addFocusListener(this);
          delegated.setBorder(null);
         * {@inheritDoc}
        @Override
        public Component getEditorComponent() {
          return delegated;
         * {@inheritDoc}
        @Override
        public void selectAll() {
          delegated.selectAll();
          delegated.requestFocus();
         * {@inheritDoc}
        @Override
        public void setItem(Object anObject) {
          isEditing = true;
          if (delegated.getValue() == null || !delegated.getValue().equals(anObject)) {
            delegated.setValue(anObject);
          isEditing = false;
         * {@inheritDoc}
        @Override
        public Object getItem() {
          return delegated.getValue();
         * {@inheritDoc}
        @Override
        public void addActionListener(ActionListener l) {
          listenerList.add(ActionListener.class, l);
         * {@inheritDoc}
        @Override
        public void removeActionListener(ActionListener l) {
          listenerList.remove(ActionListener.class, l);
        protected void fireActionEvent(Integer value) {
          Object listeners[] = listenerList.getListenerList();
          ActionEvent actionEvent = null;
          for (int i = listeners.length - 2; i >= 0; i -= 2) {
            if (listeners[i] == ActionListener.class) {
              // Lazily create the event.
              if (actionEvent == null) {
                actionEvent = new ActionEvent(delegated, ActionEvent.ACTION_PERFORMED, String.valueOf(value));
              ((ActionListener) listeners[i + 1]).actionPerformed(actionEvent);
         * {@inheritDoc}
        @Override
        public void propertyChange(PropertyChangeEvent event) {
          if (!isEditing) {
            Object value = delegated.getValue();
            if (value == null) {
              return;
            int val = ((Number) value).intValue();
            System.out.println("Should forward " + value);
            if (fireActionPerformed) {
              fireActionEvent(val);
        @Override
        public void focusGained(FocusEvent e) {
          System.out.println("JFormattedTextField: Focus gained.");
        @Override
        public void focusLost(FocusEvent e) {
          System.out.println("JFormattedTextField: Focus lost.");
       * A combo box editor that only accepts integers.
       * @author  fabriceb
      private class Size2ComboBoxEditor implements ComboBoxEditor, ChangeListener, FocusListener {
        private SpinnerNumberModel model = new SpinnerNumberModel(1, 1, 100, 1);
        private JSpinner delegated = new JSpinner(model);
        private EventListenerList listenerList = new EventListenerList();
        private boolean isEditing;
         * Creates a new instance.
        public Size2ComboBoxEditor() {
          delegated.addChangeListener(this);
          delegated.addFocusListener(this);
          delegated.setBorder(null);
         * {@inheritDoc}
        @Override
        public Component getEditorComponent() {
          return delegated;
         * {@inheritDoc}
        @Override
        public void selectAll() {
          //delegated.getEditor().selectAll();
          delegated.requestFocus();
         * {@inheritDoc}
        @Override
        public void setItem(Object anObject) {
          isEditing = true;
          if ((anObject != null) && (delegated.getValue() == null || !delegated.getValue().equals(anObject))) {
            delegated.setValue(anObject);
          isEditing = false;
         * {@inheritDoc}
        @Override
        public Object getItem() {
          return delegated.getValue();
         * {@inheritDoc}
        @Override
        public void addActionListener(ActionListener l) {
          listenerList.add(ActionListener.class, l);
         * {@inheritDoc}
        @Override
        public void removeActionListener(ActionListener l) {
          listenerList.remove(ActionListener.class, l);
        protected void fireActionEvent(Integer value) {
          Object listeners[] = listenerList.getListenerList();
          ActionEvent actionEvent = null;
          for (int i = listeners.length - 2; i >= 0; i -= 2) {
            if (listeners[i] == ActionListener.class) {
              // Lazily create the event.
              if (actionEvent == null) {
                actionEvent = new ActionEvent(delegated, ActionEvent.ACTION_PERFORMED, String.valueOf(value));
              ((ActionListener) listeners[i + 1]).actionPerformed(actionEvent);
         * {@inheritDoc}
        @Override
        public void stateChanged(ChangeEvent event) {
          if (!isEditing) {
            Object value = delegated.getValue();
            if (value == null) {
              return;
            int val = ((Number) value).intValue();
            System.out.println("Should forward " + value);
            if (fireActionPerformed) {
              fireActionEvent(val);
        @Override
        public void focusGained(FocusEvent e) {
          System.out.println("JSpinner: Focus gained.");
        @Override
        public void focusLost(FocusEvent e) {
          System.out.println("JSpinner: Focus lost.");
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

    Thanks for the advice but that's not what I am looking for. My itend is to later have a fully custimized editor that implied pattern configuration (for currency, scientific units, etc..) as well as context popup support as well as complitly different kinds of editors (ie: not-textfield based) but that still fit within the combo area (ie: the address bar for Vista's Explorer).
    I am still considering keeping a (weak) reference to the parent combo to manually edit its content when the PropertyChangeEvent is received.
    Edited by: bouye on Sep 1, 2008 2:23 PM

  • Creating a step type "launcher" that would insert the appropriate built-in or custom step type at edit time

    Hi everybody,
    I'm looking for tips, pointers,directions... to be able to perform this operation in TS 4.0 sequence Editor, if it's even possible...
    I'm managing a test system with a "home-made" virtual instruments abstraction Layer complementary to IVI classes for instruments which do not have classes defined, customizing the sequence editor accordingly for developpers of my department.
    So basically when the instrument is IVI, the developper uses the built-in IVI step-type type and when it is not, he uses the the custom step types that I developped for this particular class of instruments.  
    However there are classes where I do have both IVI and specific drivers available and I do need to use both in the test sequence.
    For example let's say there are two sources of DC power available in the testbench, one being a programmable IVI compliant DC power supply, and the other one composed of fixed "blocks" of DC power supply managed by externals relays and you need to use them both in the test sequence.
    What I would like to be able to do in the sequence editor is inserting the appropriate step type at edit time just by selecting the source of power supply (by a ring or enum for eg), and if the first ressource is selected, it inserts IVI step type, and if the second ressource is chosen, it inserts the appropriate custom step type.
    Any Ideas on how to accomplish this ?
    Regards,
    Cyril
    Cyril Bouton
    Active LabVIEW Developper
    Solved!
    Go to Solution.

    Hello Cyril,
    Here is an idea that could be done:
    You could create a dynamic step by having a step that holds all the properties for both configurations (the superset of the necessary variables) and an extra one that indicates which 'mode' the step is in.  Then you create the main Edit substep in whichever language you desire.  That substep window will then have a box/dropdown/etc. at the top you can use to choose between modes A & B.  When the user changes the value, you would dynamically change the rest of the window to contain the appropriate properties for mode A or B.  You then copy the property values in that window to the Step properties, and copy the mode to your variable and you can run the step in that mode.  When the step then runs, it checks the mode variable, and depending on its value, it will run the step in mode A or B.
    Now we could add a dialog that allows us to choose when we put a step down but we should still allow the user to change later via the Edit substep we create.
    I don't think we can create something that inserts a completely different step, but we can have one step that has the ability to do both and we can pick which one we execute.  Also note we still don't have the ability to edit the Panels for a step, so we have to use a new window that we call from our Edit substep to complete the step.
    Hope this helps.
    Regards,
    Olivier L. | Certified LabVIEW Developer

  • How to create Image as Custom Property Type used in Configurable Web Part?

    I wanted to create custom configurable web part property for Image.
    Example - the screenshot of Image property used in Image web part is shown below:
    My goal is to create as many images as possible in custom configurable web part.
    I tried to write the code:
    [WebBrowsable(true),
    WebDisplayName("Example Photo"),
    WebDescription("Example Photo of the user"),
    Category("Custom User Profile"),
    Personalizable(PersonalizationScope.Shared)]
    public Image ExampleUserPhoto { get; set; }
    However, the result does not display Image configurable web part property.
    I wonder why the data type Image does not cause the custom web part to have Image configurable web part property.
    Other data types such as Boolean, Enum, Integer, String and DateTime can be used.
    How can I create Image as Custom Property Type used in Configurable Web Part?

    I have examined that context node __00 has been enhanced,and  has a class name  z___00. But  when I created a new attirubute by right click " Attributes" with wizard under context node __00.There is still  a error message "view is not enhaced or copied with wizard".
    But  when  I created a method  "getvaliation "  in the class of context node zcl__00, the attribute  'valiation' automatically created(at the same time the method "getvaliation' automatically  created for the attribute 'valiation') and I need not to create attibute 'validation' by wizard .  It seemed as if the problem is resloved. But when I make test for it in web ui .There is a runtime erro message.
    Do I need to make some configurations in  the business object layer  for the checkbox? but  the checkbox is only used as a flag  to decide whether a backgoud job is needed to be executed.
    Edited by: samhuman on Jun 22, 2010 10:31 AM

  • How do I use a Labview Enum as a Variable Parameter for Teststant

    I have a Labview VI that performs a relay setup based on a Port selection that is an Enumerated  Type Def. The Control comes in as a drop dwon box in test stand. The question is how can I use that same dropdown as a variable to pass into a subsequence. I am not sure how to get it to show up as a custom  Type in test stand. I am using Labview 8.2 and Test Stand 4.0
    Thanks,

    As of TestStand 2010 there is not a way to natively create enums in TS.  A quick google or bing search using "TestStand Enum" should reveal all those who have tried before you.  I believe that in the Ideas Exchange there is already a note to have TS do this and I'm positive the TS developers are aware...
    In answer to your question you will have to save it as a numeric and pass it down to the sequence.  Or I kinda like this idea:
    http://forums.ni.com/t5/NI-TestStand/Using-Enumerated-data-type-in-NI-Teststand/td-p/773312
    Regards,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Enum property editor not rendering

    I am trying to get a simple Enum property editor to work for my custom component but I keep getting an error: "Failed to load/render Property Editor"
    The component XML is:
    <input-parameter  hidden="false"  name="level" required="true" title="Log Level" type="org.apache.log4j.Level">
              <default-value>
            </default-value>
          <property-editor editor-id="com.adobe.idp.dsc.propertyeditor.system.Enum" />
      </input-parameter>
    <class-path>
          libs/log4j.jar
       </class-path>
    Log4j.jar is in the component package and in the component class path
    I have tried the com.adobe.idp.dsc.propertyeditor.system.Enum Class as described in the docs here: http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=001419.html
    I also tried using com.adobe.idp.dsc.propertyeditor.system.EnumPropertyEditorComponent as described here: http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=001379.html
    Both give the same error. I even tried using my own Enum class insteasd of org.apache.log4j.Level and referencing that, but still get the same error.
    Any ideas would be helpful - thanks
    (Adobe LiveCycle Workbench ES2
    Version: 9.0.0.1.20100511.1.236086)

    Ok after some playing about and changing random things, I seem to have figured it out.
    - org.apache.log4j.Level is not an Enum class, it is a collection of static vars.
    - I refactored my own Enum class to remove everything but the Enumeration values (no constructor, methods or construction parameters)
    - I used com.adobe.idp.dsc.propertyeditor.system.Enum and not com.adobe.idp.dsc.propertyeditor.system.EnumPropertyEditorComponent
    - I added my Enum class to the <export-packages> XML parameter
    Hope this helps someone else with the same issues

Maybe you are looking for

  • 49 Service Error - Turn Off then On - LaserJet Pro 200 M276nw

    I was adding to another post for a different printer but didn't want anyone with MY printer to MISS this problem. ***UPDATE*** (at least for my LaserJet Pro 200 M276nw) I have found the root cause but will need further assistance from someone at HP t

  • IE8 crashes printing to Acrobat 9 from Yahoo message

    Anyone who belongs to a Yahoo list area is probably familiar with the print command to print a message either to a printer or to Acrobat (this is not the print command at the top of IE to print the whole page). With IE7, I had no problems printing to

  • Mail Attachment window defaulting to bottom file

    When attaching a document to an email, the window opens up and defaults to the bottom file, the oldest. This only happens in Mail.   Does this happen to anybody else?

  • Where are the zone files located for BIND??

    I found what should be named.conf in /etc/dns/ and in this file (which apple calls publicView.conf.apple ....wth?) it links to the zone files: +file "db.domain.org.";+ But db.domain.org isnt in /etc/dns so where can I find the zone files? Thanks

  • Problem in xi installation

    HI All, I have installed XI3.0 in my system, the installation is success. However, I missed out copying the client from 000 to someother before the installation of J2EE stack. Hence its giving problem in post installation activites while generating t