Liam Tiarnach

Ranch Hand
+ Follow
since Aug 06, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Liam Tiarnach

That's because you can only access printers that are currently install on your pc whether it be local or network. In regards to network printers, you would need rights and drivers in order to print to them.

[ January 22, 2008: Message edited by: Liam Tiarnach ]
[ January 22, 2008: Message edited by: Liam Tiarnach ]
9 years ago
Perhaps this example might be helpful...

[ December 06, 2007: Message edited by: Liam Tiarnach ]
10 years ago
I noted that you declared a BufferedReader for getting user input, but then you are using this

on the line you are trying to get the input from...

If the BufferedReader In is the input source then you will need to change your code to use it.

i.e.


[ October 20, 2007: Message edited by: Liam Tiarnach ]
[ October 20, 2007: Message edited by: Liam Tiarnach ]
10 years ago
Each time you are creating a new top level window (JFrame)

every time you call the "show()" method from you class SplitPane, to have it all display in same window, you have to get a reference to that window then add your "splitpane" to that window.

an example


for more detail information, check this linkJava Swing Tutorial
10 years ago
The problem you are encounter is a variable scope issue.

You declared local variables in your actionPerformed() method but are trying to access them in your paint() method which is why you are getting compiling problems.
10 years ago
I don't see any "generics" in your code...
The error state that you are using a raw non parameterized ArrayList...
If you want a generified ArrayList, then you have to include the generic parameters ( terminology anyone ? )...

now the ArrayList is set to take only Attraction types...

here is a link to Sun's Java Tutorial Generics Lesson...
http://java.sun.com/docs/books/tutorial/extra/generics/index.html

check it out so that you can learn what and how to use generics...

have fun...
12 years ago

Originally posted by Adam Blais:
I have declared the following:
The System.out.println sends everything to the console window perfectly, but my output file remains blank and it doesn't seem to want to write to the file. Any help?



Try...

check API for details...
12 years ago

Originally posted by kri shan:
I have inner class. How can i add System.out.println()..within inner class...This inner class does not contain main()



Check this link out...
http://java.sun.com/docs/books/tutorial/index.html
It has the answer to this and many more questions that you may have...
12 years ago
Here is an example using the equals() method...

as you can see, the simple overridden equal method only check to see if two DataHold objects have the same String value for data...

remember if two things are equal to each other, the the reverse must be true... In you equals method, you are taking attempting to compare a String with you Pair object, and the two are not equal because they are different types...
12 years ago
Okay, this jumped out at me...



When comparing String values, you should use String's .equals() method, because it compares String values (characters) and not the String's (object) references...

you can also use String's equalsIgnoreCase() method, if you don't want the comparison to be case sensitive...
12 years ago

Originally posted by Justin Porter:
... I found out from the API that the indexOf method of the arraylist calls the "equals()" method to figure out if it found the right object or not. So that's why I wrote my own equals method. But that equals method is not getting called (I found that out from testing). So how can I make the indexOf() method call my equals() method? Any help would be appreciated!



Okay, so as you have noted that indexOf() method uses the equals() method...
Below is the signature of your equals() method...

as you can see, your method takes a String as an arguement...
But, this is where the issue comes in, the ArrayList indexOf() method uses the equals method whose takes a Object as an argument...

so basically you have overloaded the equals() method instead of overriding it...
your class now has two equals methods... the one inherited from Object and the overloaded one that you created...

to fix this, you need to override the inherited method, in essence change your method parameters to take an Object as an arguement instead of a String...

Hope this helps...
12 years ago

Originally posted by Lenny Leon:
I'm just starting out learning Java and need a little help. I'm supposed to take this truth table and alter it so it displays 1's and 0's instead of true false. I'm assumed to do this I would just need to change the variable type and replace true and false with 1 and 0 but every way I try this does not work. I would just like for someone to point me in the right direction. I would like an explanation so I could understand instead of just an awnser. Thanks in advance



okay, so break down what !p means...
! = a boolean operator that inverts the value of a boolean...
So...

if p is true then !p ( NOT p ) is false, otherwise...
if p is false then !P ( NOT p ) is true... Hmmm... the opposite...

so if you use integers... then you could look at it like this...

if p is 1 then !p ( NOT p) then p is 0, else
if p is 0 then !p ( NOT p) then p is ???
... you can take it from here...

now you got some of the logic, making it work should be easier...
12 years ago

Originally posted by Saravanan Jothimani:
Hi,

Please give me a detailed difference between String and StringBuffer

Thanks in Advance

Saravanan



Hmmm... to much typing...

how about this link...

http://java.sun.com/docs/books/tutorial/java/data/strings.html

from the Sun's Java Tutorial...
12 years ago

Originally posted by Alisha Burke:
Hi Liam....

So how do i get the vote button to be just below the textfield/label (that was my main problem actually)....and using the code that you gave me how come the textfields becomes large when i maximize the window(is it suppose to be that way?)

thx



The reason is that p2 uses a GridLayout, so all components end up being the same size and also fills out each of thier cells in the grid...

As for a possible solution, you can move the button to be in the same panel as your text fields, and you can also use GridBagLayout with GridBagConstraint classes to have more control over your components in panel2... This is a very simple example, but it will give you the idea...


here is used one setting for GridBagConstraints for all components in Panel p2 which is the reason that I did not use the no-arguement constructor for GridBagConstraints...
If you desire, you can change the constraints for each individual component as necessary...

for more info on using GridBagLayout check out this link...
http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html

it will give more info on customizing constraints for individual components...

have fun...
12 years ago
Double.valueOf(args[i]).doubleValue();

can anybody explain me about this line
I want to know whether string valueOf is converted to doubleValue() or any other way.

Thanks in Advance

Saravanan[/QB]
If you read the API for java.lang.Double class, you will see that Double.valueOf(string) will return a new Double containing that double value parsed from the String, the the .doubleValue() method is called on the new Double to return it's value as a primative double...
in essence that line is the same as...


hope this helps...
12 years ago