Darklordshivam's Profile
Reputation: 0
Apprentice
- Group:
- Members
- Active Posts:
- 34 (0.06 per day)
- Joined:
- 02-October 11
- Profile Views:
- 664
- Last Active:
Dec 13 2011 04:17 AM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Program Always executes the else statement.Help !
Posted 13 Nov 2011
-
In Topic: Program Always executes the else statement.Help !
Posted 13 Nov 2011
GregBrannon, on 13 November 2011 - 09:27 AM, said:Debuggers are great IF you know how to use them. If you're interested in being good at a debugging tool, I suggest using a logger, like log4j. It's not hard to set up and use and the concept is as easy as adding print statements to your code to figure out what's going on.
If your current project's schedule prevents you learning something else right now, add the println statement I suggested to figure out why your thrice-checked if statements aren't evaluating true as you believe they should.
Ok I added the print statement,
When I clicked the premium button,It says "Invalid Login" Maybe because I didnt login and/or therefore the username / password were wrong be default,Then it displayed my print statement along with these:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Login.actionPerformed(Login.java:118)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6267)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.window.dispatchEventImpl(window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) -
In Topic: Program Always executes the else statement.Help !
Posted 13 Nov 2011
smohd, on 13 November 2011 - 09:30 AM, said:equals() is case sensitive also, so make sure you type exactly Shivam with S in capital, also dont put spaces between. you can try to trim() the input also like:String user = NameField.getText().trim(();
Another thing to take care, your code for checking is username and password is correct will execute for all events that listen to this actionPerformed() except cancel, so I am not sure why it is out of any if condition to check which sources generates the event.
No,that is not supposed to be an issue,my "S" is capital without any spaces,Ive tried copying pasting too ! -
In Topic: Program Always executes the else statement.Help !
Posted 13 Nov 2011
GregBrannon, on 13 November 2011 - 09:11 AM, said:If your 'else' is always executing, your 'if' condition is always evaluating to false. Review your if conditions and determine why they're always false. Write println statements before the 'if' statements to evaluate the if condition variables.
You didn't give us enough info to help you with that, but it's probably better that you do it yourself.
My if condition is supposed to be true,Ive crossed checked it thrice.I tried using the debugger but when it reaches the statement where it checks if the button is pressed,it directly exits the whole bunch of statements -
In Topic: Small GUI Problem
Posted 18 Oct 2011
macosxnerd101, on 18 October 2011 - 09:03 AM, said:This is the basics of what you want to do. You can still add JButtons to this JPanel, and what not. The only difference is that you override paint().
public class MyPanel extends JPanel{ public void paint(Graphics g){ super.paint(g); //now use g to draw your Image } }
lol my whole program would mess up if I used graphics g because Im not aware of using it
I know JFrame,JPanel and JOptionPane thats it
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Click here to e-mail me
|
|


Find Topics
Find Posts
View Reputation Given



|
Comments
Darklordshivam has no profile comments yet. Why not say hello?