How to set a third state in a JCheckBox

Hello
Does someone know how can I set a third state (for example if the value is null instead of true or false) on a JCheckBox.
The goal is that I can set this state myself with a click on the checkbox, so the method setEnabled(false) doesn't work.
Thanks

How about tinkering with the "enabled" property?
That is, a 3-state check box is a check box that
the user can disable/enable by clicking on it.
I changed the code, assuming that the UI asks the
model if the control is enabled. It apparently works
(I'm using 1.3)
Any comments?
import java.awt.*;
import javax.swing.*;
// A Three State JCheckBox which takes an int via getSelected/setSelected methods
// The null state is drawn as "disabled"
// after http://forum.java.sun.com/thread.jsp?forum=57&thread=124056
public class ThreeCheckBox extends JCheckBox
     ThreeToggleButtonModel theModel = new ThreeToggleButtonModel();
     public ThreeCheckBox(String aString)
          this(aString, 2);
     public ThreeCheckBox(String aString, int v)
          super(aString);
          theModel.setSelected(v);
          setModel(theModel);
     public void paintComponent(Graphics g)
          theModel.beforePaint();          
          super.paintComponent(g);
          theModel.afterPaint();          
     public int getSelected() { return theModel.getSelected(); }
     public void setSelected(int v)
          theModel.setSelected(v);
     class ThreeToggleButtonModel extends JToggleButton.ToggleButtonModel
          private boolean isPaint = false;
          private int theValue = 2;
          public int getSelected() { return theValue; }
          public boolean isEnabled()
               return isPaint && theValue > 1 ? false : super.isEnabled();
          public void beforePaint() { isPaint = true; }
          public void afterPaint() { isPaint = false; }
          public void setSelected(int v)
               theValue = v < 0 ? 2 : v;
               super.setSelected(v == 1);
          public void setSelected(boolean b)
               theValue = (theValue + 1) % 3;
               super.setSelected(theValue == 1);

Similar Messages

  • How to set Background Activity state as error

    HI Experts,
                    In case of foregruond activities,i know we can make the status as ' in progress' by exit_cancelled.What I want to do is,in case of background activity, if some error comes,i should be able to generate some sort of message, seeing which administrator can come to know that there is some problem.If I use exit_cancelled ,that doesnt solve the purpose.I think something should be there but I'm totally unaware.Please help me know how is that done .

    Hello Vivek,
    position your cursor in the object builder on the method declaration; then push the button "Exception".
    Declare an exception 9001 or greater, which is marked as "Application" or "System" error (both of these types will result in a error state of the work item, later on). Choose some useful message id.
    In the implementation of the object's method, use the macro
    exit_return 9001 <var1> <var2> <var3> <var4>.
    If you're not using any variables, use SPACE.
    Instead of setting the error state for a work item immediatly, you could also set the exception type to "temporary". If you do so, the workflow runtime system will re-execute the work item 3 times after every 20 minutes (if you're using the SAP standard settings). Only after the third exception the work item will be set to error state.
    Best wishes,
    Florin

  • How to set Query SQL Statement parameter dynamically in Sender JDBCAdpter

    Hi All,
    I have one scenario in which we are using JDBC Sender Adapter.
    Now in this case,we need to set Query SQL Statement with a SELECT statement based on some fields.
    This SQL statement is not constant, it would need to be changed.
    Means sometimes receiver will want to execute SQL statement with these fields and sometimes they will want to execute it with different fields.
    We can create separate channels for each SQL statement but again that is not an optimum solution.
    So ,I am looking out for a way to set these parameters dynamically or set SQL statement at Runtime.
    Can you all please help me to get this?

    Shweta ,
    <i>Sometimes receiver will want to execute SQL statement dynamically</i>....
    How you will get the query dynamically? Ok Let me assume, consider they are sending the query through file, then its definitely possible. But u need BPM and also not sender JDBC receiver adapter instead, receiver JDBC adapter.
    SQL Query File ->BPM>Synchronous send [Fetch data from DB]--->Response -
    >...............
    Do u think the above design will suit's ur case!!!!
    Best regards,
    raj.

  • How to set field "third party" in the Web Adi, General Ledger - Journals?

    Hello,
    We are trying to find how to set the field "Third Party" in the template WebAdi, and validate data and also can display in the form of general ledger journals.
    thanks for the collaboration.

    hi,
    just make the input feild as mandatory in properties and use the following code.
    data:
    lo_view_controller type ref to if_wd_view_controller,
    lo_dyn type ref to cl_wd_dynamic_tool.
    Create Object
    create object lo_dyn.
    data lt_messages type lo_dyn->t_check_result_message_tab.
    Get view controller reference
    lo_view_controller = wd_this->wd_get_api( ).
    Call Method to verify the element has the value or not
    call method cl_wd_dynamic_tool=>check_mandatory_attr_on_view
    exporting
    view_controller = lo_view_controller
    display_messages = ABAP_TRUE
    importing
    messages = lt_messages .
    endmethod.
    Regards,
    Kranthi

  • How to set transaction (or statement) timeout in PL/SQL program

    Hi to all.
    I need to set a timeout before executing a very long transaction so if it take longer than a specified value, it should be broken.
    Is there something like transaction timeout or statement timeout?
    Here is a brief pseudo code of what I'm trying to do:
    BEGIN
    set timeout = 1 hour
    perform some long operations
    END;
    Thanks a lot in advance. Any help will be appreciated!
    Best regards, Beroetz

    There is no transaction timeout period.
    One option would be to create a profile for the user that terminated that user's sessions if a particular statement or session used too much CPU/ IO/ some combination. This would probably require a dedicated user for this sort of job, but that's probably not too big a deal.
    If you will be doing a lot of small operations, you could also register for an alert, submit a background job that signals the alert in an hour, and look for the alert periodically in your code.
    Justin

  • How can I set a third party application to access my organizations intranet through my organizations network

    how can I set a third party application to access my organizations intranet through my organizations network  . I am using blackberry bold 9700 OS 6

    Hi deepajithesh
    This feature is not available. Applications access the BlackBerry Network using the connection to BIS.
    Thanks
    -CptS
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • How can I set the United States as my country when opening PSE 10?

    How can I set the United States as my country when opening PSE 10 so I don't have to scroll down every time?

    Why do you have to scroll down every time? You should only see the country window the very first time you launch PSE after installing it.

  • How to set "like" field of the query in statements

    Hi,
    Im trying to set the "like" field of the statement.but it is not executing as expected.Could anybody please tell me,"how to set the like field in statements.
    Here is my code.
    PreparedStatement psum=con.prepareStatement("select count(bill_amount) from master where bill_date like ? and whos_bu=?");
    String myStr=month+"/??/"+year;
    psum.setString(1,myStr);
    psum.setString(2,employeeTray[1]);
    ResultSet rs=psum.executeQuery();

    Tnx a lot vidyut .using % is working.
    Could you plz tell me why the previous one using question mark is not
    working. using quesion mark is correct as per the query syntax.and also i tried with asterisk,it is also not working.
    ps:have some duke dollars.

  • How to execute sets of DDL Statements in 1 command?

    Hi All,
    I've been trying to look for a way to run a set of DDL statements. I normally have text files with DDL Statements on it. So what I do is load the contents of this text file into a Textbox and then set the Textbox.Text as the CommandText of my command object. Unfortunately I get errors.
    Here's my code...
        Private Sub btnLoadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim OpenDiag As New OpenFileDialog
            Dim txtReader As StreamReader
            OpenDiag.ShowDialog()
            If OpenDiag.FileName <> "" Then
                txtReader = File.OpenText(OpenDiag.FileName)
                CommandTextBox.Text = txtReader.ReadToEnd
            End If
        End Sub
        Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim myConn As New OracleConnection(My.Settings.ConnectionString)
            Dim myComm As New OracleCommand(CommandTextBox.Text, myConn)
            Try
                myConn.Open()
                myComm.ExecuteNonQuery()
                myConn.Close()
            Catch ex As OracleException
                MessageBox.Show(ex.Code & ": " & ex.Message)
            End Try
        End SubThe errors that I get are
    "ORA-00900: Invalid SQL Statement"
    - Not sure how I get this but I noticed that if i had remarks/comments in my text file, this is the error that i get. Although i don't get this error if i execute in SQL Plus.
    "ORA-00911: Invalid Character"
    - after removing the remarks/comments, i get this error. i tried removing the semi-colon ";" then it works okay if i'm running 1 DDL statement in my file.. but if i my file contains to DDL statements for example, then i get the this error "ORA-00922: Missing or Invalid Options".
    can anyone help me with this?
    thanks.

    yes. i have BEGIN and END in their corresponding places.
    i found out that removing linefeeds and semi-colons somehow fixes the problem for DDL statements. also, if i use a RichTextBox and uses its RichTextBox.LoadFile(filename, RichTextBoxStreamType.PlainText) instead of the File.OpenText(filename), it works fine as well. although its not something i would want. so what i did was to create a PL/SQL Anonymous Block instead. this too works if i use a RichTextBox.LoadFile instead of a textbox. but i'm using these controls to see the contents. eventually i will need to use a variable to store the contents of the file and i'm worried that it won't work with it.
    unfortunately it doesn't work when i use a string. i'm guessing because of the linefeeds and semi-colons are still there.

  • How can I change the state in the shipment info in the account setting?

    How can I change the state in the shipment info in the account setting?
    I was trying to buy an Apple TV from the store but, I live in Italy and at the moment (for long time) I'm in Deutschland.
    From the shipment information i didn't find the possibility to change the state. From default is ITALY but I need to receive in Deutschland.
    Did somebody know how to???
    Thanks in advance!!!

    Hi 7oaksGaz,
    1) Due to tax reasons, it's not possible to change the country associated with an existing Adobe ID.
    Follow the steps mentioned in the below link as a workaround to create an Adobe ID with the email address you currently use for the existing Adobe ID.
    http://helpx.adobe.com/x-productkb/policy-pricing/change-country-associated-with-adobe-id. html
    2) You can change the language of the application from AAM preferences
    Please find the link below for the article with the steps
    http://helpx.adobe.com/creative-cloud/kb/creative-cloud-trial-mode.html
    Thanks!
    Eshant

  • How to set the number of rings for the agent phone rings before it get the not prepared state

    hi, how to set the number of rings for the agent phone rings?  before it get the not prepared state.
    thanks

    The following assumes that you are using ICM with an IPIVR etc (not using CVP), as the answer is different for CVP
    What you are looking for is called "Ring no answer time".  It is set in the Agent Desk Setting List tool.
    Regards,
    Kevin

  • I wish to set a repeat for an event but I do not get a customise option on my iphone 4s so cannot set the third monday of the month - only day, weekly 2 weekly monthly or annually - how do I resolve the problem ?

    I wish to set a repeat for an event but I do not get a customise option on my iphone 4s so cannot set the third monday of the month - only day, weekly 2 weekly monthly or annually - how do I resolve the problem ?

    Week Cal uses the calender database already on your phone. It's just a different front end.

  • How to set radio buttons in horizontal state in the JRadioButtonGroup

    How to set horizontal alignment in the JRadioButtonGroup

    I don't know of any JRadioButtonGroup class.
    A ButtonGroup is just a simple data structure that ensures that only one button is selected. It is not a component.
    Just add your JRadioButtons to a JPanel with any LayoutManager you wish.

  • How to set  state-manager ? need to help!

    In my App I use Myfaces1.2.6 + RichFaces3.3.0, the <state-manager> setting in faces-config.xml which is right?
    NO.1:
    <state-manager>org.apache.myfaces.application.jsp.JspStateManagerImpl</state-manager>NO.2:
    <state-manager>org.ajax4jsf.application.AjaxStateManager</state-manager>And what is different between NO.1 and NO.2 , and do not set anything in <state-manager>?
    Edited by: ben_gan on Mar 12, 2009 3:18 AM

    1 will use MyFaces' state manager.
    2 will use Ajax4jsf's state manager.
    No setting will likely pick up the default setting, which is most probably the MyFaces state manager.

  • How can i set a adresse/state Kosovo on my contacts?

    Hallo,
    ich versuche bei "meine kontakte" die Adresse zu bearbeiten, ist aber nicht möglich weil Kosovo gar nicht auf der Liste steht. Ich hätte es gern die adresse gehabt das wenn ich Navigon oder auch andere apps benutze direkt über Kontakte die Adresse entziehen kann, so muss ich die Adresse manuell eintippen die ich dann merken oder per hand irgendwo schreiben müsste, was nicht der Sinn der Apple Entwicklung ist. Es mag sein das das eine Kleinichkeit für Apple ist aber ich würde mich freuen wenn ich auch die gleiche Vorteile wie andere User habe.
    MfG

    Hi Taffy078
    Hope these answers help with some of the issues you have raised.
    How do people save a link / bookmark to the new login process?
    For easy access to BT Yahoo mail through the BT login page, people can save or bookmark the BT.com homepage, They can then access this page and click the email link in the main navigation bar to access the new login page.  Instructions on how to set BT.com as your homepage if they wish can be found here: http://www.bt.com/static/includes/account/portal/
    Why is the experience different on different machines / laptops?
    We’re in the middle of a process of altering the login process for BT Yahoo email and during the next few weeks it’s possible you’ll see both the old and new experience if you use different laptops, computers or devices while this transition happens.  Very soon all access to the BT Yahoo web email clients will be through BT.com
    Thanks
    Stuart
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

Maybe you are looking for

  • How to display imaged documents on  EP   (.prop filename extension)

    Hello All Situation is, the business desires ability to display and optionally print multiple imaged invoices at one time.  These images are stored on the Content Server as ".prop" files.  On R/3 these files are displayed through the SD Viewer.   The

  • Developement XI-Content for Enterprise Services

    Hi, What is XI-Content? And what must be defined in XI-Content for Enterprise Service Enabling? We have defined some services as provider, these services are goint to be in XI-Content. But we are also requesting some infromation to business partner,

  • Formula using a between statement

    I have a two part question... First, I need to calculate the number of years based between two dates.  Currently the formula states DateA - Date B / 365.  Which doesn't give me the exact years b/c the 365 does not accommodate the extra days during le

  • Camera Roll 100 photos missing.

    I updated my iphone 3g to the new software version 4.0.1 a few weeks ago. I had taken over 100 photos from my iphone after that. 2 days ago I plugged in my iphone to my computer to put the pictures on my computer. When I plugged my phone in itunes po

  • Schedule Line releases in APO do not show in IDoc

    Hey Guys, 1) The scheduling agreements are released to ECC via /sapapo/pwbsch1 even though i do not maintain any release profile, confirmation profile or process in the /sapapo/pwbsrc1 under the Sch. Agmt tab.   I have the distribution definition mai