Top.Mail.Ru
December 5th, 2005 - Java developers — LiveJournal
? ?

Java developers

December 5th, 2005

09:19 am - chixor1 - Boolean Values?

Forgive me for being really silly with these questions, however I am having trouble determining whether I am inserting the correct information for an assignment im working on.

My task is to return "True" if my integer is Even and "false" if my integer is not.
Im using the remainder operator, do divide the integer entered by the user by 2.
then Im stating:

if ( result = 0 )
        answer = true;
  
   else answer = false;

Now in my head im thinking that "answer" should be declared as a boolean value, since it can only either be true, or false.
But im recieving an error stating that "cannot convert double to boolean".

Thanks in advance, of the fulle code is required I am more than happy to provide.

12:02 pm - chixor1 - using methods in a switch?

Im keeping you busy, Im sorry.

My next question is regarding creating a switch.
I have 2 methods, one for converting temps to celsius, and one for converting temps to fahrenheit.
I would like the user to select which temperature conversion they want to choose.

i.e For C to F enter "1" for F to C enter "2"

I wanted to use switch (choice)
                           {
                               case1:
                                        "method 1"
                               Break;
                               case2:
                                         "method 2"
                               Break;
                               }

Is there anything special I would need to do to allow me to use the methods within this switch?

05:30 pm - christtrekker - mod_jk vs mod_proxy_ajp

Now that Apache 2.2 is out with AJP support built in, should I use it or continue using mod_jk? What's the difference? What are the benefits either way?

Any info appreciated. I'm just working on setting up Apache+JOnAS now, and I'd like to launch with the most current version.

x-posted

07:32 pm - 0olong - Stopping a component from being cleared every frame

Hello,

I'm still struggling to convince my Swing-based applet not to paint over the background every frame. I've actually found a way of doing this, by overwriting the JPanel's update method so it only calls paintComponent, and that only calls super.paintComponent if I want it to... but this has the unfortunate side-effect that any Swing component the user interacts with is mysteriously drawn in the top-left corner as well as the correct place. What?!

See the effect in action (select 'trails' under 'history').

If nobody here's got any clever ideas to fix it (calling setDoubleBuffered(false) won't help, and nor will setOpaque(false or indeed true)), I'll give up on the idea of saving all the processing power and memory consumed by unnecessary double-buffering, and just draw to an off-screen image, but it'd be nice to avoid that...!

Cheers folks
Powered by LiveJournal.com