7,116 Posted Topics

Member Avatar for shean1488

The normal pattern with a base clas and another that depnds on it (eg model & view) goes like this: [CODE]public static void Main(..) { Sudoku theGame = new Sudoku (); SudokuValidator v = new SudokuValidator(theGame);[/CODE] ... then in the constructor for SudokuValidator you take the instance of Suduku as …

Member Avatar for JamesCherrill
0
124
Member Avatar for freedomflyer

The API doc for HashSet shows it to be a subclass of Set, and the API doc for Set says "More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2)" So there's your answer. The implementation uses the equals(...) method of your objects to see if …

Member Avatar for JamesCherrill
0
350
Member Avatar for 47pirates

Create ObjectOutputStream / ObjectInputStream on the socket's streams and use writeObject / readObject to transfer an Image object

Member Avatar for JamesCherrill
0
199
Member Avatar for chamnab

AbstractTableModel is an abstract class, you can't create an instance of it, nor does it define methods for removing rows. Maybe you are thinking of DefaultTableModel - which implements AbstractTableModel and has methods for adding & removing rows. See the API doc for details

Member Avatar for mKorbel
0
743
Member Avatar for justindill

Before you ask DaniWeb you should ask the Java compiler. Try compiling your code - it's a [I]lot [/I]faster :) When you compile you'll get a load of error messages. Read them very carefully because most will tell you exactly what's wrong with your code. If you still don't understand …

Member Avatar for zeroliken
0
613
Member Avatar for rushikesh jadha

Assuming you haven't relied on static variables you can just dispose() your window(s) and create new ones by re-executing the existing startup code

Member Avatar for hfx642
0
239
Member Avatar for Tuz

[QUOTE=thines01;1759011]Only one module can contain main() and there can only be ONE main().[/QUOTE] Just for the record: any or every class in your program can have a [ICODE]public static void main(String[] args)[/ICODE] method. It's up to you which one you run when you start the program. Like many other people …

Member Avatar for JamesCherrill
0
147
Member Avatar for krejar

you read the menu choice int from the scanner, but this leaves the newline delimiter unread. Your next read is likely to return "" - ie everything before the next newline. Flush the newline after reading the int.

Member Avatar for DavidKroukamp
0
131
Member Avatar for rushikesh jadha

There are (as mKorbel said) a number of ways to do this, but in my personal opinion the easiest way is to subclass JPanel and override paintComponent to draw the image directly into the panel. Once you've done that all the rest of using the window (layout manager, adding conponents) …

Member Avatar for rushikesh jadha
0
185
Member Avatar for tungnk1993
Member Avatar for compEstudent

That's a very detailed specification that tells you pretty much everything you need to know. This shouldn't be too hard if you just start and then work incrementally through the spec implementing what it says. Start with the "process table" and a couple of queues (use the standard classes from …

Member Avatar for JamesCherrill
0
475
Member Avatar for aanders5

putClientProperty / getClientProperty methods inherited from JComponent allow you to associate anything you want with any JComponent.

Member Avatar for aanders5
0
191
Member Avatar for emclondon

I googled ThreadPoolExecutor and immediately found loads of tutorials and examples for the use of this class. If your Google is broken I can forward some of them to you :-/

Member Avatar for JamesCherrill
0
281
Member Avatar for syekimubeen

You can write a Date object by using the SimpleDateFormat class with a format specification that describes exactly how you want it formatted. See the Java API documentation for details. Inputting "any date format" is a much bigger problem - is there any limit or system to the range of …

Member Avatar for JamesCherrill
0
236
Member Avatar for Joey_Brown
Member Avatar for pink_sapphire

[CODE]String blink = new String(chunk); System.out.print(blink[/CODE]); Doesn't that mean that you have every line of console output in the String blinbk before it's written to the console?

Member Avatar for JamesCherrill
0
1K
Member Avatar for Zaad

Come on now Zaad! You have been here long enough to know that you should always include the line number when you post an error message! But presumably it's line 35/6 - is that URI valid? Does the file exist?

Member Avatar for Zaad
0
4K
Member Avatar for kalcio

First, you could check that the letters are being transferred correctly from your Runtime exec, and if so, how they have been encoded. Try printing the string with its UniCode numerical values, eg [CODE]String s = (the string you get from exec) for (int i=0; i<s.length();i++) System.out.println(s.charAt(i) + " = …

Member Avatar for kalcio
0
341
Member Avatar for mallikaalokam

All you need to perform the assignment before the test is an extra set of (). ie [ICODE]while ( (ch=br.read()) != '%')[/ICODE] However, you still have a problem because [ICODE]br.read()[/ICODE] returns an int not a char. You can't assign an int (32 bit) to a char (16 bit), although you …

Member Avatar for stultuske
0
135
Member Avatar for miramiey

SasseMan is right. The only code in your paint method should be actual painting code - roughly speaking that's just the lines that use the Graphics object g, as in super(g) or g.draw... All the stuff about layout manager or adding components (choice, button, radio group, etc) belong in your …

Member Avatar for JamesCherrill
0
224
Member Avatar for Connavar3

Ditto. Maybe you're creating something for each connection or transaction and failing to null all the references to it/them (eg adding them to a List that's not cleared).

Member Avatar for Connavar3
0
415
Member Avatar for Hattoff

The problem is most likely in the code where you call the individual animation methods. Can you post that code as well? What thread do you run those calls on? If it's in an actionPerformed or anything like that you have blocked the Swing Event Dispatch Thread (EDT) - Google …

Member Avatar for JamesCherrill
0
240
Member Avatar for adil_bashir

1. Post your code in code code tags so we can read it easily 2. If you have an error tell us what it is! - Exact complete error message(s) including the line number(s)

Member Avatar for DavidKroukamp
0
237
Member Avatar for TIM_M_91

true abd false are boolean values and are not a valid values for a String variable. What exactly do you mean when you refer to a String as true or false?

Member Avatar for TIM_M_91
0
240
Member Avatar for servet

The regex is [ICODE][.:|][/ICODE] (ie any of the three chars in the []) EXCEPT that . and | are special chars in regex and need to be escaped with a \ to indicate that you want to use them literally, ie [ICODE][\.:\|][/ICODE] Next problem is that \ is a special …

Member Avatar for JamesCherrill
0
126
Member Avatar for lena1990

Set the column width to be wide enough, then place the whole table in a JScrollPane so it scrolls horizontally. See this: [url]http://stackoverflow.com/questions/2452694/jtable-horizontal-scrollbar-in-java[/url]

Member Avatar for mKorbel
0
76
Member Avatar for Valiantangel

Do you just want to display the result rounded down to 2 dec places, or do you need to perform the calculation and round down that result to2 dec places before doing anything else (eg storing or printing it)

Member Avatar for hfx642
0
105
Member Avatar for BlackStar0703

[QUOTE=BlackStar0703;1756153]... does that not mean that in more sophisticated programs there would be hundreds of classes, making it pretty unorganised?[/QUOTE] Yes there will be hundreds of classes, but no. that's not necessarily unorganised, especially compared to the alternative of having all that code but not organised into classes. OO isn't …

Member Avatar for BlackStar0703
0
517
Member Avatar for jackbauer24

I can't read the text in the attachments, but anyway... XML is the generalised markup language - HTML is one form/subset of XML. There's all the info you could possibly want on the web, at every level from complete noob to ultimate expert, so I'm not going to try to …

Member Avatar for jackbauer24
0
137
Member Avatar for lalaZai

^ yes. And why setISBN? A book's ISBN never changes. Declare it final and require it as a parameter in the constructor(s). Finally DaniWeb Member Rules include: "Do not ask anyone (member or moderator) for help by email or PM" [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] post your questions in the forum so others can …

Member Avatar for stultuske
0
115
Member Avatar for techyworld

Just get some squared paper and draw the triangle you want on it, then look and see what the coordinates of the corners are, and feed those into lines 7.8.9 of your code.

Member Avatar for zeroliken
0
1K
Member Avatar for phy2sma

Layout managers are pretty fickle about using or ignoring your component's sizes. You could try setMinimumSize for your panel as well as setSize.

Member Avatar for JamesCherrill
0
232
Member Avatar for ringo_tech

If you start the player playing in its own thread, as correctly advised by cOrRuPtG3n3t!x, then I see no reason why you can't just call ap.stop() directly from the Swing thread (eg in a button's action listener) - no need for flag variables etc. (If you can't call stop() from …

Member Avatar for ringo_tech
0
1K
Member Avatar for konman795

The code that zeroliken quoted is your problem. Each time you loop with a new value of i you overwrite all the values from the previous pass of the loop. The correct way to do the sieve algorithm is to start with the isPrime array set to all true, then …

Member Avatar for JamesCherrill
0
775
Member Avatar for gowans07

Start here: [url]http://www.daniweb.com/software-development/java/threads/99132[/url]

Member Avatar for DavidKroukamp
0
98
Member Avatar for Sanna.1

Duplicate of existing thread [url]http://www.daniweb.com/software-development/java/threads/411255[/url]

Member Avatar for Ezzaral
0
125
Member Avatar for KazenoZ

.class files are the compiled "executables" that can be executed by any Java Virtual Machion (like a .exe can be executed by an i86 machine). You package all the .class files for your application, along with any other resources it needs, into a "jar" - basically a zip file with …

Member Avatar for Zhoot
0
246
Member Avatar for LdaXy

The problem is when you run convert for the first time it initialises its variables, including [ICODE]public static float seconds = conv.sec;//THIS COLLECTS THE DATA FROM SEC[/ICODE] but because that var is static the initialisation is done once only, and any subsequent changes to conv.sec are not copied over. In …

Member Avatar for JamesCherrill
0
138
Member Avatar for javaprog200

I think Norm's onto something there. This is from the JComboBox API doc: [QUOTE]public void addItemListener(ItemListener aListener) Adds an ItemListener. aListener will receive one or two ItemEvents when the selected item changes.[/QUOTE] A quick print inside the itemStateChanged method will confirm or refute this.

Member Avatar for javaprog200
0
248
Member Avatar for kalcio
Member Avatar for mohamed moamen
Member Avatar for dave_t

You're going to have to read and re-write all the file starting at the "abc" line and moving everything down by the length of the line. Not a pretty process. If the file's small enough to fit into memory you can simplify the code by reading it all into an …

Member Avatar for DavidKroukamp
0
1K
Member Avatar for dennysimon

Have you tried using a > to redirect the output messages from the compiler to a file where you can browse them all at your leisure?

Member Avatar for dennysimon
0
168
Member Avatar for Sanna.1

or, more simply: [CODE] private boolean getBoolean(){ return expression1 && expresssion2 && expression3 ; }[/CODE]

Member Avatar for JamesCherrill
0
294
Member Avatar for rupes0610

[QUOTE=Zhoot;1754235]One way is to sum all the numbers of the row/column/section. If the sum is 45, it's probably correct.[/QUOTE] Unfortunately that's nowhere near sensitive enough - eg the sum of nine fives is also 45. But it does inspire an idea for an improved version... how about summing the [I]squares …

Member Avatar for hfx642
0
312
Member Avatar for missc

It doesn't help that there is no single universal definition of OOP, but I would say that if you just have static methods and don't declare any classes (other than the one the main method is in) and never use the "new" keyword, then your code has nothing "Object Oriented" …

Member Avatar for stultuske
0
201
Member Avatar for ThaiAmL

Those error messages don't match the code (look at the line numbers). Please re-post one or both so we have consistent info to look at.

Member Avatar for ThaiAmL
0
218
Member Avatar for Nana88

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in doing your homework for you. DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting …

Member Avatar for stultuske
-4
155
Member Avatar for mallikaalokam

Those error messages contain valuable information that you aren't sharing with us. What are the exact error messages and which line(s) do they refer to?

Member Avatar for DavidKroukamp
0
145
Member Avatar for Kalle21

If the user input 5 you print the 5, then subtract 1, then print the result (4), then subtract another 1 and print 3 etc... until you get down to 0 You;ll have to write the code yourself - but here's an outline of what you need: [CODE]ask the user …

Member Avatar for stultuske
0
104

The End.