7,116 Posted Topics

Member Avatar for Sadun89

http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html#renderer

Member Avatar for Sadun89
0
149
Member Avatar for Transcendent

The Integer class has methods for converting ints to Strings in binary, octal, hex, or any arbitrary base. Ditto for converting any of those formats back to int. Check out the API docs for details.

Member Avatar for JamesCherrill
0
122
Member Avatar for MSheraz
Member Avatar for Torf

It's time to go back to the requirenments statement. You have a linked list (but why do I suspect that you just copied that from somewhere without really understanding it???), which you can use for the list of Books for each Author, but now you need the Book and Author …

Member Avatar for NormR1
0
112
Member Avatar for blackmagic01021

WriteOnPanel is (correctly) an instance netrhod, so in your "other" class you need a reference to the instance of LabelStatus that you want to use when you call that method. Somewhere in your code you will create a new LabelStatus object, and you need to pass that into your "other" …

Member Avatar for blackmagic01021
0
1K
Member Avatar for frank33

I suspect that every threaded implementation could be replaced by a sufficiently cunning non-threaded version, so the question is "when are threads useful?" rather than "when are they necessary?". For your people running about it may make sense to have one thread for each person in that the code is …

Member Avatar for frank33
0
134
Member Avatar for corvenzo

> a private class? maybe for inner classes, but I definitely wouldn't recommend it otherwise :) The all-important JLS section 8.1.1 says > The access modifiers protected and private (§6.6) pertain only to member classes within a directly enclosing class or enum declaration (§8.5). For example you may have a …

Member Avatar for ash.28.88
0
480
Member Avatar for Afropuff01
Member Avatar for JamesCherrill
0
135
Member Avatar for Stjerne

Make each panel a new class that extends JPanel. Put all the code associated with that panel into that class. From your main window class just create instances of your classes and add them to the main GUI.

Member Avatar for NormR1
0
208
Member Avatar for kalcio

Different types of data need different compression algorithms for the best results (eg sound -> mpeg, picture -> jpeg). But zip is a good all-round lossless algorithm that is fully supported by the Java API libraries. http://java.sun.com/developer/technicalArticles/Programming/compression/

Member Avatar for JamesCherrill
0
136
Member Avatar for JamesCherrill

Maybe it's just me having a "senior moment", but we seem to have lost the facility where you could hover the mouse over a topic's title on the forum listing page and see the first line or two of the post. I used this all the time to get a …

Member Avatar for Dani
2
191
Member Avatar for sathish1990

The trick to moving contents up an array is that you have to start at the end of the array and loop downwards back to the starting point. If you start at the insertiuon point and loop upwards you just keep duplicaing the value that was at the starting point. …

Member Avatar for JamesCherrill
0
168
Member Avatar for bsabowala

String s1 = "Hello!"; String s2 = "Hi!"; // s1 might '==' s2, but !s1.equals(s2). No, in that example s1 cannot == s2. The == tests for s1 referring to exactly the same object as s2, whereas equals tests for two Strings containing the same sequence of letters. If s1 …

Member Avatar for JamesCherrill
0
190
Member Avatar for Mr.BunyRabit

This is probably easier than you think, but first, some clarification: Do you mean that the user logs in to your Java application or logs in to the mysql database, or both, in which case how are the two logins related?

Member Avatar for gourav1
0
283
Member Avatar for CodeMonkeyJunk
Member Avatar for CodeMonkeyJunk
0
417
Member Avatar for Mr.BunyRabit
Member Avatar for Mr.BunyRabit
0
102
Member Avatar for ringo_tech

Maybe you get the error because you try to create a second server socket the second time you click connect, but the port is still bound to the original server socket. Your code closes the (client) socket but not the server socket. Try creating just one server socket when the …

Member Avatar for ringo_tech
0
179
Member Avatar for DoubleGee

Your second and third if tests should look like the first one `if(evt.getSource().equals(theAppropriateJBUtton)` then inside those if blocks you can test `bgColor` or `disabledText` as appropriate

Member Avatar for 117
0
203
Member Avatar for jarograv

`string1 == string2` tests for those being exactly the same object (both have the saem memory address), which they're not in your case. The equals method for Strings tests if two Strings contain eactly the same sequence of letters - which is what you need. You'll find the documentation for …

Member Avatar for jarograv
0
120
Member Avatar for jackbauer24

You overrode `paint` so you lost all the stuff that normally happens when a JFrame paints itself. Just start your method with a `super.paint(g)` to get all that stuff painted before you add your own drawing.

Member Avatar for JamesCherrill
0
301
Member Avatar for mehnihma

You need to loop through the argument array and search for each element in turn.

Member Avatar for mehnihma
0
68
Member Avatar for srinidelite

In a loop, take each letter from the first word one at a time and see if it is present in the second word. If it is, add it to the list of common letters.

Member Avatar for JamesCherrill
0
82
Member Avatar for huskarit

Do you mean RGB (red-green-blue)? Anyway the default colours depend on the operating system and/or the Java look and feel that is in operation at any moment.

Member Avatar for JamesCherrill
0
50
Member Avatar for DavidKroukamp

Because all you need isn HTML link to run it in your browser? ps: Swing works in applets as well...

Member Avatar for DavidKroukamp
0
193
Member Avatar for ibthevivin

`while (sent.charAt(count) != sent.charAt(sent.length()))` This is presumably to limit the loop to the length of the string, but will fail if the last letter is repeated somewhere else in the sring, eg for "abcb" the loop will terminate on the second letter ('b') because it matches the last letter (also …

Member Avatar for SirMG
0
186
Member Avatar for jamesr12

[url]http://en.wikipedia.org/wiki/String_interning[/url] I've never heard of a reason why you would force allocation of a new String object with [ICODE]new String("daniweb"[/ICODE] as opposed to allowing the compiler to intern it, and right now I can't think of a single reason why you would want to do that...

Member Avatar for jamesr12
0
146
Member Avatar for Valiantangel

pets is an array of Pets, so `pets[ 3 ].getAction(`) requires the getAction method to be defined for the class Pet, but it's not, it's only defined for GoldFish. I know that you know that ` pets[3]` contains a GoldFish, but that's not something the compiler can figure out.

Member Avatar for JamesCherrill
0
116
Member Avatar for Valiantangel

> void perform(){System.out.printIn(this.action); Yet another problem with code formatting - which hides the fact that you have typed printIn instead of println. Confused? I'm not suprised. Your version has an upper-case `I` for India where it should have a lower-case `l` for Lima.

Member Avatar for JamesCherrill
0
157
Member Avatar for Srin

In the mouse click handler just create a [I]new AndGate()[/I] or whatever and [I]add [/I]it to the "canvas" (an ordinary [I]JPanel [/I]would do) at the mouse click coordinates (use absolute positioning and a null layout manager for the "canvas"). ps drag'n'drop really isn't that hard - certainly less hard than …

Member Avatar for NormR1
0
549
Member Avatar for huskarit

Have a look athe dispose() method for your closing window - it closes the window and releases its resources,

Member Avatar for DavidKroukamp
0
564
Member Avatar for jarograv

It really doesn't make a lot of sense to try to split this into two [I]classes [/I]like that, but two (or more) [I]methods [/I]would certainly help make the code easier to understand. Eg: You could create your two arrays in the main method, then pass them as parameters to an …

Member Avatar for jarograv
0
1K
Member Avatar for DavidKroukamp

Your diagnosis sounds probable to me. Rather than using invokeLater in the constructor, why not move that up to startGame() so all the startup code runs on the same (swing) thread?

Member Avatar for JamesCherrill
1
247
Member Avatar for nyfan68

That looks OK, but as stultuske pointed out, it's horrible practice to ignore your IOExceptions - much better to catch them and print an understandable error message yourself. You could also use [ICODE]line.contains(keyword)[/ICODE] rather than [ICODE]line.indexOf(keyword) != -1[/ICODE] because it's simpler and clearer

Member Avatar for stultuske
0
393
Member Avatar for london-G

I assume you have variables for its position and velocity that you update at regular intervals (Swing Timer) - in which case just add a fixed amount to the (downwards) vertical velocity component on each update. This will result in the downwards speed increasing steadily - just like g.

Member Avatar for london-G
0
87
Member Avatar for jet101

To close one frame and open another you just make the first one invisible (or dispose()) it, then make the second visible (or create new instance of it). If however you just want to pop up a (modal) dialog you would use one of the methods in the JOptionPane class

Member Avatar for jet101
0
217
Member Avatar for FDRSOURCE

[CODE]public Camera() { ... init(); } public void init() { ... inv = new Camera();[/CODE] When you create a new instance of Camera it calls the constructor, which calls init, which creates a new instance, which calls its constructor, which calls init ...

Member Avatar for JamesCherrill
0
182
Member Avatar for krejar

It looks to me like you have correctly met the requirements of your exercise here. How it's going to work, and how it relates to the classes in the Java API - these are probably not relevant questions. But... Having an empty method in a superclass like that is pretty …

Member Avatar for JamesCherrill
0
122
Member Avatar for jade_91

I wouldn't worry too much about an array, because all you do with that it turn it into a List on line 13. For a clean solution you could write a separate method that reads the file one line at a time and adds each line to an ArrayList. then …

Member Avatar for NormR1
0
262
Member Avatar for rob211

Is it a requirement that you use two hashmaps? Could you, for example, create class Result with instance variables name, points, time?

Member Avatar for JamesCherrill
0
104
Member Avatar for london-G

Your loop calls move() to update positions etc, but Swing has no reason to update the screen. Call repaint() on your main window to request a screen refresh (which will use your latest values). Your paint method seems to be doing its own double buffering? If so, no need, because …

Member Avatar for london-G
1
136
Member Avatar for rob211

Hi kolibrizas Your help, advice, and assistance are very welcome here. But please don't just post solutions to people's homework for them to copy & paste. All they learn from that is how to cheat. Give them guidance that allows them to learn how to do it for themselves. Thanks.

Member Avatar for rob211
0
181
Member Avatar for xyxtss

If you don't want anyone to be able to change the mark just don't have a setMark method. If you want to be able to do it yourself, but not allow anyone else, make the method private.

Member Avatar for stultuske
0
136
Member Avatar for coroll

You declared MyClass inside MyOwnBM, and you didn't declare it static, so it's just like any other instance member - you can't refer to it without an instance of the MyOwnBM class. See [url]http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html[/url] Unless MyClass needs direct access to instance variables from MyOwnBM, just declare it static, or declare …

Member Avatar for JamesCherrill
0
491
Member Avatar for Na'Vi

Why do you have primaryPanel at all? CryptoMainMenu is a panel, so just do the layout and add the button directly on that.

Member Avatar for Na'Vi
0
123
Member Avatar for coroll

remove, not Remove - Java is case-sensitive. HashTable takes only objects for key and value - your code relies on auto- boxing/unboxing to convert between char and Character, int and Integer. Your int cast on line 6 is probably interfering with the auto-unboxing

Member Avatar for JamesCherrill
0
157
Member Avatar for gagirl1105

1. Declare and initialise your ArrayList as as ArrayList of Games to avoid casting and possible errors [ICODE]ArrayList<Game> theDB = new ArrayList<Game>();[/ICODE] 2. htScore is already an int, so there's no need to use [ICODE]Integer.parseInt[/ICODE] - that's just for where the data is in a String. [ICODE] homesum += theDB.get(i).getHtScore();[/ICODE] …

Member Avatar for gagirl1105
0
115
Member Avatar for Valiantangel

int[] myParrot = {1,2,3}; // simpler You can use Random to generate random numbers. I donlt kniw what you mean by "a given set of numbers"

Member Avatar for NormR1
0
257
Member Avatar for dhija22

A class can have any number of constructors, but they must all have different parameter lists.

Member Avatar for JamesCherrill
0
73
Member Avatar for Syrne

I can't explain the logic, but the public method is the one that gets called initially (that's why it's public), and the private method is the "helper" (being private it can only be called from within the class). There's no reason why a recursive method can't be void. Recursive just …

Member Avatar for Syrne
0
385
Member Avatar for mags11

Small observation: The spec explicitly requires a two argument constructor (year and make). It assigns 0 to speed, but does not have speed as a parameter.

Member Avatar for stultuske
0
12K

The End.