7,116 Posted Topics

Member Avatar for AhmedGhazey

Hi AhmedGhazey. It's good that you are giving so much help in this forum, and your code sets a very good example for its structure and clarity. Just one thing to watch out for - we try to help people learn enough to solve their own problems, especially if it's …

Member Avatar for AhmedGhazey
0
839
Member Avatar for niranga

I think you will have to wrap the Vector (or extend the Vector class) in your own class that implements an addListener(...) method and overrides add() etc to broadcast the change event forwarding the change to the the Vector. This is basically what javax.swing.DefaultListModel does to support JList objects - …

Member Avatar for niranga
0
996
Member Avatar for winecoding

[QUOTE=AhmedGhazey;1575872]one important note this parameters mustn't accept any type of cast . i.e. if you have the following method definitions int x (int p); int x (double p); if you called x(5); which one will be called ?? you guess this will give you compilation error . [/QUOTE] [CODE]public class …

Member Avatar for JamesCherrill
0
147
Member Avatar for arvindikchari
Member Avatar for mastr924

If you want to know whether it's button1, button2 etc, you can simply say if (e,getSource() == button1) ...

Member Avatar for Leeibra
0
615
Member Avatar for pxndx

[I]at olmosProyecto.GestionDeHorarios.cargarCurso(GestionDeHorarios.java:44)[/I] That line from the error message tells you which line of your source code (line 44 in GestionDeHorarios.java) threw the error, so you can see what token it was looking for on that line, which should help you identify the error. ps Not all lines in the data …

Member Avatar for pxndx
0
236
Member Avatar for manaila

[url]http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/[/url]

Member Avatar for JamesCherrill
0
109
Member Avatar for AnkitKumar

Take a look at this: [url]http://download.oracle.com/javase/1,5.0/docs/guide/language/enums.html[/url] scroll down about half way and look at the Planet example - that shows how to use a constructor in an enum.

Member Avatar for JamesCherrill
-1
67
Member Avatar for Dean_Grobler

I agree. More than once I've implemented a simple finite-state-style thing to pick a few relevant values from an XML file, rather than get into the complexity and overhead of SAX or DOM. This [url]http://www.javaworld.com/javaworld/javatips/jw-javatip128.html?page=1[/url] may be interesting to you (Just like buses. You wait an hour for one, the …

Member Avatar for Ezzaral
0
155
Member Avatar for IcantC

Use a JTextPane instead of a JTextArea. Same functionality plus formatted text. API JavaDoc is in the usual places.

Member Avatar for IcantC
0
727
Member Avatar for ankit.pandey3
Member Avatar for ankit.pandey3
0
232
Member Avatar for Armanious

[QUOTE=Armanious;1573675]Well, I solved it by using just System.arraycopy(), and I assume it's faster since it's performed by the VM (if not, please tell me so I can optimize it[/QUOTE] arrayCopy is a native method, so I think it's safe to assume its faster than anything anyone can do in Java …

Member Avatar for jon.kiparsky
0
1K
Member Avatar for localp
Member Avatar for Zurompeta

@siviwe You do realise that this was marked as "solved" in 2008, don't you? It's 2011 in this part of the world...

Member Avatar for siviwe
0
307
Member Avatar for harinath_2007
Member Avatar for Annuate

Firstly, I agree with Jon (I think he's a bit too hard on field setters, but I support his reasoning behind that). Now think about maintenance/enhancement. Writing a program is easy. Updating someone else's program when requirements change is hard. Suppose you do your Vector2 class and develop loads of …

Member Avatar for jwenting
0
236
Member Avatar for Dorar

I didn't study all the code, but I get a strong smell of a Swing EDT thread problem here - trying to execute user interactions while still inside a Swing event handler? Sorry, no time to go any further into this now, J

Member Avatar for NormR1
0
173
Member Avatar for sirlink99

if ("waveSlider1".equals(source)){ You are trying to compare a String object with a JSlider Object - always false. Assuming waveSlider1 is a variable containing the first JSlider you need to compare the variable, not a String containing the variable's name if (source == waveSlider1) {

Member Avatar for sirlink99
0
126
Member Avatar for sirlink99

[CODE]public void graphicsComponent (Graphics g){[/CODE] looks odd to me, are you sure you don't mean [CODE]public void paintComponent (Graphics g){[/CODE]

Member Avatar for NormR1
0
342
Member Avatar for sandyho

Indent your code properly, then look at when [I]System.out.println("Your total is:");[/I] will be executed.

Member Avatar for mKorbel
0
314
Member Avatar for winecoding

Briefly - make sure any non-standard dependencies (libraries) you may use have been placed somewhere (anywhere) in the classpath, then package the whole of your project's classes and resources into a jar (Eclipse: File -> Export -> Runnable jar file) which you can then run by [I]java -jar myJarFile.jar[/I], or …

Member Avatar for jon.kiparsky
0
264
Member Avatar for n3red

Stick it anywhere in the classpath for command-line use. In Eclipse go into Project -> Properties -> Java Build Path -> Libraries and add it there.

Member Avatar for JamesCherrill
0
77
Member Avatar for JSS540

Agree with Norm. Best practice is to write a small public method in the GUI class that just takes the String as parameter and does whatever it needs to display it. That way other classes can call the method without needing any knowledge of the internals of the GUI class.

Member Avatar for JamesCherrill
0
1K
Member Avatar for C:\>

You can do this kind of thing using the indexOf and substring methods of the String class. So myUrlAsString.indexOf("secret_code=") gives the start point of that string, add 12 to get the index of the first char after it, which is where your target text is located. Use the same approach …

Member Avatar for C:\>
0
135
Member Avatar for tirambad

AFAIK SIP is concerned with establishing and controlling a session, but not with the actual streams of voice and video that are sent in the session. That would normally be the responsibility of the Real-time Transport Protocol (RTP/RTCP). Maybe you are interested in researching innovative ways to achieve a breakthrough …

Member Avatar for JamesCherrill
0
130
Member Avatar for solomon_13000

Try printing the exception - it's message will help. ps: subSet gives a "live" view, not a copy

Member Avatar for JamesCherrill
0
123
Member Avatar for WolfShield

null pointer exception means you have tried to use a variable that has not been initialised. Reading down the messages we see it happened in the add method for Container, and that was called from line 18 of jpad.java That line reads add(mainTextArea, BorderLayout.CENTER); and there's the problem. You have …

Member Avatar for WolfShield
0
148
Member Avatar for WolfShield

Also If you take the time to read the API doc for JList you will find an explanation with examples of how to use a ListCellRenderer to format JList entries any way you want.

Member Avatar for WolfShield
0
137
Member Avatar for lynnajoe

What gets executed if hours worked are >0 but < 40? You keep nesting if within if within if until by the end (eg line 63) there's only a small chance of the code being executed. The presence of six consecutive } at the end, although perfectly legal, is also …

Member Avatar for JamesCherrill
0
131
Member Avatar for bibiki
Member Avatar for lovelyrose26

I'm not a Scanner expert, but I think... after you get the weight with a nextDouble() the following carriage-return is still there (it's not part of the double). Then you do a nextLine() which gives you all the chars up to the next CR - which is a zero-length String …

Member Avatar for NormR1
0
91
Member Avatar for Kprosser1029

You have a loop where you get each file name in turn, but you do nothing with them. You know how to append text to your result area, so... ps: When you post your code, post it properly indented in CODE tags.

Member Avatar for JamesCherrill
0
101
Member Avatar for dywlkr365

[QUOTE]You need external Api for this... [/QUOTE] No you don't. Its part of JDK 6. Here's a decent introduction from Oracle themselves: [url]http://download.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html[/url] A common approach is to make a MessageDigest of the password (eg using MD5) and store that in the database. When the user next enters his password …

Member Avatar for jwenting
0
221
Member Avatar for Japus

Reflection is useful when you have to make calls dynamically at runtime to classes/methods that are unavailable at compile time, and for implementing annotations etc, but they are not normally used for "ordinary" code. A major reason is that, unlike normal calls, they cannot be checked at compile time thus …

Member Avatar for jwenting
0
627
Member Avatar for kwins

1. Exactly what is the real text of the error message, including line numbers? 2. Why do you have three JFrames (one created in main, one created in the constructor, and one instance of Absolute which is itself a JFrame)?

Member Avatar for NormR1
0
216
Member Avatar for Buffalo101

This depends on what kind of fields your class has. Assuming they are just ordinary data types - ints, Strings etc - then you, it's not hard to have a method that concatenates all the values into a single String with easy field delimiters (eg tabs), and a corresponding constructor …

Member Avatar for Buffalo101
0
166
Member Avatar for harinath_2007

That link tells you how to make a Window full-screen. If you know how to play a video in a Window then all you need to do is make the window full screen.

Member Avatar for JamesCherrill
0
624
Member Avatar for sagngh8

This has been cross posted on at least 6 different sites, complete with the mis-spelling in the title. Nobody who codes [CODE]} catch(Exception ex) { }[/CODE] deserves an answer anyway.

Member Avatar for turt2live
-1
436
Member Avatar for solomon_13000

The Integers are different Objects, even if their values happen to be the same EXCEPT that Java pre-creates a single set of Integers for values -1287 to +127 (approx - or maybe its 0-255, but you get the idea) so Integers in this range will always be the same Object …

Member Avatar for jon.kiparsky
0
157
Member Avatar for kwins

Don't expect us to guess what error you have. Exactly what error are you unable to fix? Give full details.

Member Avatar for jon.kiparsky
0
238
Member Avatar for bibiki

You can allow the user to type in an expression in JavaScript then use/call that as code dynamically at runtime using Java's recent support for scripting languages.

Member Avatar for bibiki
0
117
Member Avatar for AnkitKumar

It is very object oriented, but has some non-OO features for reasons of performance, notably the primitive data types (int, boolean, char, float etc) which are not Objects

Member Avatar for jwenting
1
326
Member Avatar for 24x24

General strategy: Don't try to use paintComponent for viruses or ships, they do not extend anything with that method. Just have a public paintMe(Graphics g) method for each. Have the game panel with its overridden paintComponent method, and within that method call paintMe(g) for all the viruses and ships so …

Member Avatar for 24x24
0
388
Member Avatar for AhmedGhazey

Actually there's quite a difference between [QUOTE]i want a free tool to draw structure chart [/QUOTE] and [QUOTE]i asked if any one know a good one suggest it thanks [/QUOTE] If you had tried the second version from the beginning you might have got a better response.

Member Avatar for AhmedGhazey
0
106
Member Avatar for saurabh2007

The JavaDoc for NoSuchElementException is incredibly unhelpful [QUOTE]Thrown by the nextElement method of an Enumeration to indicate that there are no more elements in the enumeration. [/QUOTE] Obviously wrong, since you have no enums. A look at the code for java.util.Scanner.throwFor tells us the real story: [CODE] // If we …

Member Avatar for NormR1
0
516
Member Avatar for pi_lord12

Have a look at BitSet. It holds long strings of bits, fully packed at 64 bits per 8 bytes, and can be written/read to/from files as a single Object using Object input/output streams.

Member Avatar for pi_lord12
0
221
Member Avatar for s.w.a

th=spoofpkt/totalpkt; because th is an int, and assuming spoofpkt < totalpkt, th will always be zero (integer division is always rounded down to an integer value). You could make th a float to hold fractional values.

Member Avatar for s.w.a
0
199
Member Avatar for winecoding

1. readObject can throw Exceptions (see the JavaDoc for details) so you have to use try/catch to handle them. 2. In Java 1.5 collections like Vector were enhanced to allow specification of what kind of Objects they contain (previously they just contained Objects, which had to be cast at runtime …

Member Avatar for JamesCherrill
0
145
Member Avatar for tboz203

Big Decimal still won't give an exact value for rational numbers such as 1/3, so your idea may still be useful if you store numbers as exact fractions.

Member Avatar for JamesCherrill
0
191
Member Avatar for bulger2503

I'm pretty certain you have to read and re-write the data from the insertion point to EOF. How big is the file? There's no problem with (say) 100Mb reading the whole thing into memory, modfying it, the re-writing it. If your data is more structured than the example the there …

Member Avatar for JamesCherrill
0
108

The End.