Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 13 of 13

Thread: about countdown timer and jcombobox need help please

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default about countdown timer and jcombobox need help please

    ""CAN YOU HELP ME ? WHAT WILL I ADD SO THE PROGRAM WILL IDENTIFY IF THERES A DOUBLE CHECKED JCHECKBOX . I DONT KNOW THE EXACT CODE FOR THAT . AND PLEASE CAN YOU GUYS GIVE ME A LINK FOR ANY SOURCE OF JAVA PACKAGE. SORRY WRONG TITLE LOL ""

    import javax.swing.JApplet;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
     
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
     
     
    public class MODos extends JApplet  {
    	 JTextField ftext;
    	 JTextField stext;
    	 JTextField ctext;
    	 JButton compute;
    	 JButton clear;
    	 JButton exit;
    	 // Set to global variable scope
    	 JCheckBox add, subtract, divide, multiply;
    	 int first,sec,comp;
     
     
    	public MODos() {
    		getContentPane().setLayout(null);
     
     
     
    		JLabel lbl1 = new JLabel("Enter First Number :");
    		lbl1.setBounds(67, 78, 160, 17);
    		getContentPane().add(lbl1);
     
    		JLabel lbl2 = new JLabel("Enter Second Number  :");
    		lbl2.setBounds(67, 110, 160, 20);
    		getContentPane().add(lbl2);
     
    		final JLabel lblNewLabel_2 = new JLabel("");
    		lblNewLabel_2.setBounds(67, 175, 148, 14);
    		getContentPane().add(lblNewLabel_2);
     
    		ftext = new JTextField();
    		ftext.setBounds(237, 76, 118, 20);
    		getContentPane().add(ftext);
    		ftext.setColumns(10);
     
    		stext = new JTextField();
    		stext.setBounds(237, 110, 118, 20);
    		getContentPane().add(stext);
    		stext.setColumns(10);
     
    		ctext = new JTextField();
    		ctext.setBounds(237, 169, 118, 20);
    		getContentPane().add(ctext);
    		ctext.setColumns(10);
     
    		 compute = new JButton("Compute");
    		compute.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent arg0) {
     
     
    				if(add.isSelected()) {
     
     
    					first=Integer.parseInt(ftext.getText());
    					sec=Integer.parseInt(stext.getText());
    					comp=first+sec;
    					lblNewLabel_2.setText("Sum is :");
    					ctext.setText(comp+"");
     
     
    				}
    				else if(subtract.isSelected()){
     
    					first=Integer.parseInt(ftext.getText());
    					sec=Integer.parseInt(stext.getText());
    					comp=first-sec;
    					lblNewLabel_2.setText("Difference  is :");
    					ctext.setText(comp+"");
    				}
    				else if(divide.isSelected()){
     
    					first=Integer.parseInt(ftext.getText());
    					sec=Integer.parseInt(stext.getText());
    					comp=first/sec;
    					lblNewLabel_2.setText("Quotient  is :");
    					ctext.setText(comp+"");
    				}
    				else if(multiply.isSelected()){
     
    					first=Integer.parseInt(ftext.getText());
    					sec=Integer.parseInt(stext.getText());
    					comp=first*sec;
    					lblNewLabel_2.setText("Product  is :");
    					ctext.setText(comp+"");
    				}
    				// If no operation was selected
    				else {
     
    					JOptionPane.showMessageDialog(null, "You must select an operator!");
     
    				}
     
     
    			}
    		});
     
    		compute.setBounds(58, 245, 89, 23);
    		getContentPane().add(compute);
     
    		JButton clear = new JButton("Clear");
    		clear.setBounds(167, 245, 89, 23);
    		getContentPane().add(clear);
    		clear.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent arg0) {
    				ftext.setText(null);
    				stext.setText(null);
    				ctext.setText(null);
    				add.setSelected(false);
    				multiply.setSelected(false);
    				subtract.setSelected(false);
    				divide.setSelected(false);
     
    			}
    		});
     
    		JButton exit = new JButton("Exit");
    		exit.setBounds(276, 245, 89, 23);
    		getContentPane().add(exit);
    		exit.addActionListener(new ActionListener(){
    			public void actionPerformed(ActionEvent arg0) {
    				System.exit(0);
    			}
    		});
     
     
     
    		add = new JCheckBox("Add");
    		add.setBounds(58, 196, 89, 23);
    		getContentPane().add(add);
     
    		subtract = new JCheckBox("Subtract");
    		subtract.setBounds(228, 222, 83, 23);
    		getContentPane().add(subtract);
     
    		divide = new JCheckBox("Divide");
    		divide.setBounds(228, 196, 83, 23);
    		getContentPane().add(divide);
     
    		multiply = new JCheckBox("Multiply");
    		multiply.setBounds(58, 222, 89, 23);
    		getContentPane().add(multiply);
     
    	}
     
     
    }
    Last edited by javados; September 28th, 2014 at 06:24 PM. Reason: wrong title


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: about countdown timer and jcombobox need help please

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.


    A DOUBLE CHECKED JCHECKBOX .
    What does "double checked" mean?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: HELP ABOUT [COUNTDOWN] OR [TIMER] using GUI.

    Are you asking about having a GUI display that changes with time?
    What have you tried?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: about countdown timer and jcombobox need help please

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

    Please don't start multiple threads on the same topic. Threads merged and moved.

  5. #5
    Junior Member
    Join Date
    Sep 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP ABOUT [COUNTDOWN] OR [TIMER] using GUI.

    sir. im sorry about that lol . this program i posted is different from countdown timer that im asking . my problem on this program is i dont know the correct code for that .
    double checked it means the 2  jcheckbox is true
    tnx.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: about countdown timer and jcombobox need help please

    jcheckbox is true
    The JCheckBox class or its super class has a method that can be called to see how it is set.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Sep 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: about countdown timer and jcombobox need help please

    no i mean like . this . i have 4jcheck box. and the program will identify if the 2 jcheckbox is checked

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: about countdown timer and jcombobox need help please

    identify if the 2 jcheckbox is checked
    Each check box has a method that will say if it is checked. Use that method for the 2 check boxes.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Sep 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: about countdown timer and jcombobox need help please

    no not only for 2 . i got 4 . so it wil l print out . that 1 checkbox only

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: about countdown timer and jcombobox need help please

    It doesn't matter how many checkboxes you have, each of them has the same method that can be used to see if it is checked.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Sep 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: about countdown timer and jcombobox need help please

    i didn't understand at all . can you explain it basically? because im new at java GUI.

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: about countdown timer and jcombobox need help please

    I don't understand what you are trying to do. Can you explain in more detail?
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Sep 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: about countdown timer and jcombobox need help please

    nvm sir . i figured it out . thanks for the effort .

Similar Threads

  1. Countdown timer which opens a popup window
    By thcggg in forum Other Programming Languages
    Replies: 0
    Last Post: April 7th, 2014, 07:19 PM
  2. Countdown timer
    By AANZ in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 1st, 2013, 07:46 AM
  3. Please help me with my Java Countdown Timer
    By remagarrote in forum AWT / Java Swing
    Replies: 3
    Last Post: March 8th, 2013, 10:09 AM
  4. Timer Countdown - Code Syntax
    By baddack in forum What's Wrong With My Code?
    Replies: 22
    Last Post: September 26th, 2012, 03:56 PM
  5. Timer class countdown
    By p0oint in forum Object Oriented Programming
    Replies: 5
    Last Post: August 26th, 2010, 03:31 AM