How to make a check box appear to the user when he does a specific action

hi all
i have created a check box and i want if the user does not do a specific action the check box appears ?

so sorry i ment a frame with an error message
remember my last program about randomization
i want if the user did not enter the first name
a message appear to warn
and if he did not enter the second name
a message appear to warn
here i created a created a second frame to appear as
awarning message
and the action to allow the error frame to appear
else
c2.setVisible();
but the compiler didnot recognized c2
is that not legal to create two objects from
container c2=getcontentpane();
i want to understand this problem
and making my code right
and making my code right
Code:
import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.awt.event.*;
class MyMatching extends JFrame
     final JTextField txt1=new JTextField("Name1",10);
     JLabel lbl3=new JLabel("Love");
     final JTextField txt2=new JTextField("Name2",10);
     JButton btn=new JButton("Result");
     JTextField txt3=new JTextField("%",5);
     JTextArea ta=new JTextArea(10,40);
     ImageIcon img=new ImageIcon("D:\\Mastering Java\\Java Projects\\Icons\\alert_lrg.gif ");
     JLabel lbl=new      JLabel(" Do You Love Computer Science?",img,JLabel.LEFT);
     JPanel pnl1=new JPanel();
     JPanel pnl2=new JPanel();
JPanel pnl3=new JPanel();
     MyInner inner;
     MyMatching()
          setupGUI();
     private void setupGUI()
          setSize(500,300);
          setTitle("Love Matching v1");
          Container c=getContentPane();
     Container c2=getContentPane();
          c.setLayout(new BorderLayout());
          pnl3.setLayout(new BorderLayout());
          pnl1.setLayout(new FlowLayout());
pnl1.add(txt1);
pnl1.add(lbl3);
pnl1.add(txt2);
pnl1.add(btn);
pnl1.add(txt3);
pnl2.add(ta);
c.add("North",pnl1);
c.add("Center",pnl2);
lbl.setIcon(img);
     pnl3.add("Center",lbl);
     c2.add(pnl3);
setVisible(true);
inner=new MyInner ();     
btn.addActionListener( inner);
// txt1.addActionListener( inner);
// txt2.addActionListener( inner);
class MyInner implements ActionListener
public void actionPerformed(ActionEvent e)
if(!txt1.getText().equals("Name1") && !txt2.getText().equals("Name2"))
     if (e.getActionCommand().equals("Result"))
//First process
int random= ((int)(50*Math.random()))+50;
txt3.setText(random+"%");
//second process
String msg[ ]={"Love Can Touch Us One Time And Last For The Life Time\nYou Are A True Lovers.","Your Feelings Are Different \nYou Should Forget it."
,"Love Is A Passion\nYou Must Be More Romantic.","You Are An Angel\n But Your Lover Is A Liar."
,"You Must Think Deeply Before That Choice\nLove Is Not An Entertainment.","Do Not Lie To Your Hart\nYou Still Love Your First Lover."
,"You Cannot Love Again\nYour First Lover is So Lovely And Cannot Be Forotten."};
ta.setText( msg[((int)( msg.length*Math.random()))] );
/* breaking up the code
double random = Math.random();
int index = (int) (msg.length*random);
String message = msg[index];
ta.setText(message);*/
ta.setForeground(Color.RED);
else
c2.setVisible();
     public static void main(String[]args)
          MyMatching mtch=new MyMatching();
}

Similar Messages

  • How can i prevent the result from the user until he does a specific action

    hi again
    1-i have created two textfields for the user to enter two names
    2-i have created a result button when the user hit it a result will appear
    in any case if the user hits the result button the result will appear
    even if he does not enter the two names
    i want to make the result available only if the user enters the two names
    by checking the inputs before the result appear
    if he enteres the names the result appear
    if he does not enter an error message appear?
    how can i do that process?

    lol i think he was talking about formating your messages on the forum.
    look at an example that i just created hope it helps. If not then read up on the GUI chapter of your java book.
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JTextField;
    import java.awt.BorderLayout;
    public class ButtonTest{
        public static void main(String args []){
            JFrame frame = new JFrame();
            JPanel panel = new JPanel();
            final JTextField textA = new JTextField(10);
            final JTextField textB = new JTextField(10);
            JButton button = new JButton("Perform Action");
            class Listener implements ActionListener{
                public void actionPerformed(ActionEvent e){
                    if(!textA.getText().equals("") && !textB.getText().equals("")){
                        System.out.println(textA.getText()+" "+textB.getText());
           ActionListener listener = new Listener();
            button.addActionListener(listener);
            panel.add(textA);
            panel.add(textB);
            panel.add(button);
            frame.getContentPane().add(panel,BorderLayout.SOUTH);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.show();
    }

  • How to make your folder list appear at the top when opening a finder window

    Sorry if this has been asked before but couldn't find it in the threads... About the only thing I miss from Windows, is the way file mgr displays list in folders, i.e. starting with folders, then listing the files.
    Any way we can do this in Leopard?? The closest I get is by displaying content in list, then sort by type, but obviously my Adobe documents are listed before my folders... I'd really love to get my folders on top.
    Thanks for the help!
    Jean-Francois.

    FYI, I found this trick posted at another board:
    Sorting by kind with folders at the top can be done in Leopard with a little hacking:
    OBLIGATORY WARNING:
    If you're not comfortable with this, don't do it!
    With that out of the way:
    - navigate to: /System/Library/CoreServices/
    - right-click Finder.app and select Show package contents...
    - navigate to: Contents>Resources>English.lproj
    - backup InfoPlist.strings
    - open the original InfoPlist.strings in a text editor
    - locate the line that says:
    Code:
    "Folder" = "Folder";
    - add a space at the start of the second "Folder":
    Code:
    "Folder" = " Folder";
    - save the file
    - reboot or relaunch Finder
    The space in front of "Folder" forces folders to the top of the list when sorting alphabetically by kind.

  • How to insert a dialog box which prompt the user enter the general information in the SDI application?

    Im using the SDI application to build a system and now i would like to insert a dialog box which allow the user to enter the general information about themselves and then it will be saved into a text file. How to insert the dialog box and show the dialog box at the beginning of the program.

    Hi Lee,
    The easyest way to achieve this is to declare an object of your dialog box derived class (e.g. CUserInfo, public CDialog) into the InitInstance method of the main application class.
    Depending on the behavior you want you can place the code before dispatching the commands from command line (in which case the main frame of the SDI application will not be shown), or after, in which case the UserInfo dialog box will be shown over the main application window as modal.
    The code snipped bellow can be more helpfull:
    BOOL CSDIApp::InitInstance()
    AfxEnableControlContainer();
    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    //prompt user for data
    CUserInfo dlg;
    if (dlg.DoModal() == IDOK)
    //do something here with the data
    else
    return FALSE;//i.e. quit the application if the user presses the 'Cancel' button
    // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    return FALSE;
    // The one and only window has been initialized, so show and update it.
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();
    return TRUE;
    Hope this helps,
    Silvius
    Silvius Iancu

  • How to make a check box non-updatable through personalization

    Hi All,
    I have a requirement where I need to make check box read only in a case when user select some values from the drop down list box. Is it possible through personalization?
    For example if there is a list box which contains 5 values and for three valuse one check box needs to be make as read only and where as for remaining it can be checked/un-checked.
    Please let me know if this can be acheived through personalization.
    Thanks,
    Sandeep

    If there is some event (e.g. fire partial action) present on selection of any value the drop down, then you can achive this using java script.
    Create a raw text item and in the text property put java script to handle this case.
    For sample java script code refer
    How to set particular segment value of key flex field in Controller
    -Anand

  • How to make most recent messages appear at the top of the list?

    I can not find a place in Mail preferences to make my messages in each mailbox ALWAYS appear with the most recent at the top of the list. They seem to revert to the reverse order, even though I laboriously change the order in each mailbox via clicking the top of the date column. I am using primarily .Mac addresses in IMAP format, and three computers. It seems that after I shut down, then restart the next day and my computers all sycn with .Mac, the order goes back to oldest first. How can I fix this? Thanks!

    Everytime i have used webmail, the view is always retained with my previous settings. In fact the .Mac web mail help menu says the same thing (see below)
    Therefore the last thing i would recommend is to simply reset safari (which will empty the cache), delete all your Mail plist files, and not turn .Mac sync on fully until all systems are sorting consistently on their own....
    (from the .mac help menu)
    ===================
    Sorting message lists
    When you use .Mac Mail on the web, you can sort your messages, drafts, and sent messages lists by their column headers. Sorting is helpful when you want to quickly locate specific emails or groups of emails, such as all messages received from a specific sender or all flagged messages.
    To sort a message list:
    If you're not already in .Mac Mail on the web, go to www.mac.com and click Mail (at the top of the page), and log in.
    Access a message list by opening a folder.
    Click any column header to sort the list by that parameter. Clicking the same column header again reverses the order in which the list is sorted.
    When you sort a message list, all email messages in the list are sorted, not just those showing on the current page.
    Column headers vary slightly by list. The Drafts list, for example, has no From column.
    After you have sorted a list, it retains that order until you re-sort it.

  • How can I add check boxes without using the form widget?

    I would like to use check boxes for our facets for our search engine.  You can see an example below.  Is there anyway to do this without using the form widget?
    PJM - Site Updates

    It is not possible to accomplish this with the Muse's Form Widgets. You may need to look for other online solutions and fetch the source code and add to the Muse page using the Insert HTML feature.
    Cheers,
    Vikas

  • How to make a group name appear as the group name and not "Undisclosed Reci

    About Group Names:
    I made a group of about 15 people. I named that group “BASEBALLERS." I have another group that I labeled ”BASKETBALLERS." When I want to send info that pertains to both, I type out each group name and they both appear in the “To:” field with those names I created.
    However, when I receive copies of this email, the group names BASEBALLERS and BASKETBALLERS gets changed to boring old ”Undisclosed Recipients.“
    Is it possible for everyone to receive my emails and see the two group names instead of ”Undisclosed recipients“?
    Thank you. According to the Help Menu in Mail, it should be possible. Or does it have to do with individual ISPs?
    -Lorna in Southern California
    http://web.mac.com/lorna6

    Hi DazFaz,
    true, but with an array with length of 1 rounding down
    prevents an index
    out of range error.
    In you original code you 'round down' by multiplying by the
    length of
    the array -1 while I round down with Math.floor (and multiply
    by the
    actual length of the array).
    Is there a difference in result?
    The code below can yield 1 while the array may just be 1 item
    long:
    var arrayLength:Number = 1;
    var rnd:Number = Math.random() * arrayLength;
    var rndV1 = Math.floor(rnd);// Rounds ONLY down to the
    nearest integer
    var rndV2 = Math.round(rnd);// rounds up OR down to the
    nearest integer
    trace(rnd + "\t" + rndV1 + "\t" + rndV2);
    so either decrement the length or floor the number. Same
    difference (No?)
    I love puzzels :)
    DazFaz wrote:
    > Hi Manno Bult.
    >
    > The problem with user Math.floor is that it only moves
    in one direction and
    > that is down to an integer.
    > With Math.round ir rounds off the number to the nearest
    integer.
    >
    > If you run the code I have modified from yours, you will
    see what I mean. You
    > will notice that rndV1 always stays at 0 yet rndV2 will
    deviate from 0 to 1.
    > Making it a more accurate way of finding a true random
    number.
    >
    > var rnd:Number = Math.random();
    > var rndV1 = Math.floor(rnd);// Rounds ONLY down to the
    nearest integer
    > var rndV2 = Math.round(rnd);// rounds up OR down to the
    nearest integer
    >
    > trace(rnd + "\t" + rndV1 + "\t" + rndV2);
    >
    Manno Bult
    [email protected]

  • How to make my iphone app appear in the share list of another specific app (in browser)

    I know it is possible in android, but not sure about ios.
    Thanks

    Yepp I know that, but can we make a service which behaves like facebook or twitter app.?
    For e.g. When we click on share, it would show myapp in this share list. So I could share links with myapp.
    I heard about "Custom URL Schemes" through which third-party apps can communicate, but how could I implement this for every link on ios browser?
    Any suggestion would be helpfull for me.
    Thanks

  • How to make my appointments / events appear on the home or lock screen

    After being spoiled with the Omnia and Droid I'm really missing this feature. appointments are the main reason I have a smart phone. But going into calendar to view upcoming events is counter productive. If you go into calendar then you didnt really need a reminder.
    I want the option to glance at my home screen and see the next 24hrs of appts. This feature has saved me a number of times as your reminded of appointmets everytime you get a call, check the time etc. Theses gotta be a fix or an app out there.

    It's currently not a feature of the iPhone, and third party apps from the AppStore are not able to effect the lockscreen. You can set an alarm for appointments but that is about it.
    You can make a suggestion to apple:
    Http://www.apple.com/feedback

  • How to make sales order items appear on the billing due list?

    Dear All,
    We are using SAP CRM 5.0 standalone and we want to use CRM Billing.
    All necessary configuration has been done to enable CRM Billing on sales orders.
    Here is the list of what have been done:
    1. Defined Billing unit and assigned to my sales organization.
    2. Created billing document type for sales order (F2 as standard).
    3. Defined billing item category (TAN as transaction-based billing after complete)
    4. Defined billing item category determination (for trans. type TA, item category TAN, billing item category will be TAN)
    With all the above configuration, when I created a sales order (TA), set the order status to 'completed' and save it, I checked the item status, it is 'completed for billing'. However, when I ran 'Process Billing Due List', nothing has been picked up.
    I checked the order line item, and found that the 'Delivered Qty' field is 0. Could this be the reason? I set the item category TAN billing relevancy to be 'Transaction-based after completion', then it should not care about delivery, right?
    Please provide your input. Thanks so much in advance!
    Regards,
    Leon

    Dear Rekha,
    Thanks for your detailed reply. It seems that all the config points you mentioned in your email have already been covered. However I still don't see anything on my billing due list.
    Here is the list of what have been done:
    1. Defined Billing unit and assigned to my sales organization.
    2. Created billing document type for sales order (F2 as standard).
    3. Defined billing item category (TAN as transaction-based billing after complete)
    4. Defined billing item category determination (for trans. type TA, item category TAN, billing item category will be TAN)
    With all the above configuration, when I created a sales order (TA), set the order status to 'completed' and save it, I checked the item status, it is 'completed for billing'. However, when I ran 'Process Billing Due List', nothing has been picked up.
    I checked the order line item, and found that the 'Delivered Qty' field is 0. Could this be the reason? I set the item category TAN billing relevancy to be 'Transaction-based after completion', then it should not care about delivery, right?
    Please provide your input. Thanks so much in advance!
    Regards,
    Leon

  • How to make iCloud calendar appointments appear in the To-Do Bar in Outlook 2010

    I'm using Win 7 and iCloud control panel 4.0.  I understand that only the default calendar shows up in the to do bar.
    I tried setting iCloud as the default data file but then I can't write an email because I use IMAP which requires write access to the data file.
    I've seen posts here saying this can't be done but I know it can as I have a friend who is doing it but they are 3000 miles away and I can't see their PC to see what might be different.
    I'd appreciate any help...

    forget to mention that the categories are present in outlook but not in my ipad.

  • How can I click on a button and make a text box appear or disappear

    How can I click on a button and make a text box appear or disappear?
    Thanks ahead of time for your help,
    Doug

    Hi Denes,
    I just thought that the example you pointed the OP to, is far more complex than what I understood he needs. The OP was talking about using a button, which I thought was a very basic and simple case. Your example is much more complicated. If memory serves, the radio group item, at the time (prior to 3.1 fieldset) behaved differently, so you needed to create a new value retrieving function, and then was the need to preserve the items show/hide status upon reloading the page. In short, I thought maybe I didn’t see the complexity in the OP post, but it seems that his requirement was indeed a simple one.
    Regards,
    Arie.

  • How can I make a check box active ONLY if another check box is activated?

    How can I make a check box active ONLY if another check box is activated?
    I have an editable PDF for a client, which contains text fields and check box fields.
    There are three main check boxes (let's call them A, B and C) that the user is required to choose from, and I have given all three the same name in the Name tab of the General tab menu but different export values in order that ONLY one of the boxes can be checked at any time. Ticking one will deactivate another if it is already checked, etc.
    However, I then have a further two check boxes which I wish to become available ONLY if the second one of the above three boxes is checked. Other than that I do not wish the user to have access to them.
    I'm guessing it requires some kind of Action Script or Javascript, which is not my forté! Any help would be much appreciated.
    Regards
    Tony

    See Disabling (graying-out) Form Fields by Thom Parker. It covers both Acrobat and LiveCycle forms.

  • How can I make a check box hidden (invisible) if a radio button is selected?

    I am using Adobe Acrobat X Standard, and I can't seem to find a JavaScript that will do what I want.
    I need one check box to be invisible or hidden if a certain radio button is selected.
    Ex: if a user selects "yes" from the radio button list, I need one of 2 check boxes lower on the form to be invisible/hidden/non-selectable.
    Can someone please help me?

    Does this have something to do with a "field dependency" setting within Acrobat itself?
    I am so confused at this point, I don't even know where to look anymore.

Maybe you are looking for

  • Assigning holder to a position.

    Hi All, I have to assign a holder to a position 'A'. Then hire a new employee with supervisor as the holder of position A. Later on change the holder of position A. Please let me know the steps as I am new to this. Thanks & Regards, Soumya.

  • The screen is dark(dim)

    I just bought a Miix 2 8 online. I  found it was so difficult boot. it always keep  in a black screen. Finnally i found that the tablet had started indeed, but the screen is dim that I cannot see the loading information clearly. How can i deal with t

  • Question regarding Digital Out (COAX) not mini plug on Audigy ZS

    Hi. I have a question regarding the Digital Out and Digital In (COAX/RCA) Inputs I have on the back of my computer and if theres an easy way to hook the digital out with only a regular Digital Coax cable to a Home Theater receiver and get 5./DTS, OR

  • Word processing for iPad

    have not been able to find an Apple or 3rd party word processing ap for iPad....maybe I am not looking at the right place....can you help.

  • HP 15-b109eo Ultrabook sound cuts off suddenly

    Hello, I have week old HP 15-b109eu Ultrabook and when im on skype or on adobe connect the sound cuts out all of sudden. the mic doesnt work either and no matter what i do (take the headset off and put back), see if anything is muted etc nothing chan