7,116 Posted Topics

Member Avatar for asian_al

To store your shapes you need a suitable array - although for simplicity an ArrayList is easier. As each shape is created you can add it to the ArrayList, then you can loop thru the ArrayList calling draw() on each element - Java will see what kind of shape it …

Member Avatar for JamesCherrill
0
184
Member Avatar for Kishorey

[QUOTE=Kishorey;858567]Is it possible to get the window size in Java [/QUOTE] the getSize() method, amazingly, will do it

Member Avatar for Kishorey
0
419
Member Avatar for ithelp

Java's not the best choice for this kind of thing. Here's a script that does what you want: [url]http://www.interclasse.com/scripts/killpopup.php[/url]

Member Avatar for JamesCherrill
0
222
Member Avatar for confusedin82

Why use an array; that's just making your life harder than it needs to be. Use an ArrayList, which does everything an array does, plus you can just add your data to it with the add(...) method, and you never need to worry about it being big enough.

Member Avatar for JamesCherrill
0
137
Member Avatar for esesili

The code for the button and its actionlistener are in the earlier post that shows all the code. I assume the later listing is just a subset. I must admit, I've spent quite a few minutes on this and can't see the fault... [edit] but a few minutes later... in …

Member Avatar for JamesCherrill
0
145
Member Avatar for slimmit

You need one more loop, to include your existing loops. This is the loop that will keep reading new sets until the file is empty. You can make it an infinite loop (while (true)...), and break or return out of it when the readline() hits E.O.F.

Member Avatar for slimmit
0
90
Member Avatar for JamesGuin

Start by defining the class that extends LinkList and can store the data that needs storing for each event. Write its constructor(s) and any methods you need to access (get(...)) the data. Then move on to reading in values to pass to the constructor(s). Finally think about how to sort …

Member Avatar for JamesCherrill
0
97
Member Avatar for ahoest
Member Avatar for Esben

I don't understand this question either. When you say "runs perfectly fine as long as ..." can you specify exactly what do you observe that is "wrong", and what it should be to be "right"?

Member Avatar for peter_budo
0
89
Member Avatar for Grn Xtrm

[QUOTE=BestJewSinceJC;847842] To know where the last item is, your program can either keep track of the size of the Vector, or you can use the Vector class's size() method. [/QUOTE] Definitely use size(), why do it yourself?

Member Avatar for Grn Xtrm
0
142
Member Avatar for frozon

[url]http://www.daniweb.com/forums/thread187065.html[/url] may be useful to you

Member Avatar for frozon
0
121
Member Avatar for JamesCherrill

Here's a question for those of you who have experience of fixing or enhancing other people's Java code, which I hope will also be really useful for those in the early stages of learning programming. Please contribute! If you've looked at other people's code, you will know that sinking feeling …

Member Avatar for JamesCherrill
0
105
Member Avatar for Lekeby

Perhaps you should start by deciding what the array will look like, then write its declaration, then you can think about how to transfer data from the file to it. You also need to do the same for the data in the file, if you haven't already done so.

Member Avatar for JamesCherrill
0
119
Member Avatar for BestJewSinceJC

Hi guys! Just saw this thread and had to join in! For me, the key issue about separation of GUI and model is about good architecture. Sure, you can hard-code calls to the GUI in the model, and hard-code calls to the model in the GUI, but if you do …

Member Avatar for Ezzaral
0
1K
Member Avatar for smsamrc

[QUOTE=LevelSix;846725]So, a superscript? [URL="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/font/TextAttribute.html"]http://java.sun.com/j2se/1.4.2/docs/api/java/awt/font/TextAttribute.html[/URL] May be of use.[/QUOTE] Do they work in the console? I suspect not. You could use the unicode symbols for ² or ³ (00B2 and 00B3), but that's all, I think. In JLabels and the like you can use HTML formatting, of course.

Member Avatar for smsamrc
0
758
Member Avatar for Mubo

Woah guys. Couple of incorrect postings here: 1. If you don't declare a constructor as public, its scope will be limited to the package in which it's declared. This may, or may not. be what you intend. If you want to call it from another package it MUST be declared …

Member Avatar for Mubo
0
84
Member Avatar for kbullard516

I know this is marked as solved, but I think that's wrong - it's not solved, just ignored! By placing the "throws" clauses like that the program has specified that, if there is any problem locating a file, it will terminate immediately without any error message. That can't be a …

Member Avatar for hkansal
0
140
Member Avatar for trombadorez

As the user enters numbers add them to a List ( [url]http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html[/url] ). Then in a loop generate a random integer between 0 and the size() of the list. Get(int index) the element at that index, print it, then remove(int index) that element. Loop until the List is empty.

Member Avatar for BestJewSinceJC
0
82
Member Avatar for aztos

Normally you would 3 setters and 3 getters. Is there any special reason why you want to do it that way?

Member Avatar for JamesCherrill
0
70
Member Avatar for neutralfox

Is it possible that you have called the default constructor rather than the one with the port number, and thus connectToServer isn't executed, so the variables are not initialised when you call sendBytes? ps you declare the class as implementing Runnable, but I see no run() method???

Member Avatar for ~s.o.s~
0
197
Member Avatar for number87

System.out.println (short for Print Line) puts a newline char at the end whatever it prints, so you get one array element on each line. System.out.print does the same as System.out.println but does not add the newline, so that's the one you need. You'll then need to do your own newline …

Member Avatar for JamesCherrill
0
249
Member Avatar for yamster

I'm not certain either, but if you mean use it like a desktop picture, try putting it in a JFrame and setting the JFrame with a combination of stuff like setUndecorated(true); setFocusableWindowState(false); toBack();

Member Avatar for JamesCherrill
0
101
Member Avatar for get2tk

Re procedures - they are a sequence of steps that implement something useful. (As opposed to non-procedural languages such as HTML that describe the required results but do not give step-by-step instructions on how to achieve them). Java is procedural, and all procedures are implemented in methods (*). So one …

Member Avatar for JamesCherrill
0
298
Member Avatar for nightGoddess

Java's SimpleDateFormat class does exactly that - do you need to implement it yourself?

Member Avatar for nightGoddess
0
118
Member Avatar for Nperic

You call a public static method from outside the class by using itsclass name and method name, eg XMLreader.readLatitude(...)

Member Avatar for Ezzaral
0
138
Member Avatar for neutralfox

In FTPServerReceiver you just have one input.read(), and it's not in a loop. Have you tried sending the buffer to System.out immediately after the read so you can see what's coming in? Where exactly is it failing? - try to scatter some System.out.println statements around so you can see how …

Member Avatar for neutralfox
0
89
Member Avatar for neutralfox

Not certain that I understand the Q, but you can only have 1 run() in a class, so if there are other things you want to start new threads for you need an additional small Runnable class to do it. You can use an anonymous inner class (Google it if …

Member Avatar for BestJewSinceJC
0
259
Member Avatar for neutralfox

IMHO design patterns are a great aid to good design. Why re-invent the wheel? Those patterns distil huge amounts of experience into templates that you can apply quite easily. However, I disagree that you "must" follow them, even less follow them blindly. You need to read, and understand them, then …

Member Avatar for neutralfox
0
97
Member Avatar for ramkumarm

I don't think there's a callback you can use, so the only way seems to be to set up a simple timer loop and call getMediaTime() at regular intervals, eg every 1 or 2 seconds, and then set the seek bar to the appropriate position. You should use the SwingTimer …

Member Avatar for JamesCherrill
0
94
Member Avatar for rayda

Here's why: when you create a subclass, and you write a subclass constructor, and in that constructor you do not have a call to the superclass constructor as the first statement, the Java compiler puts in a call to super() by default (in order to ensure that everything inherited from …

Member Avatar for JamesCherrill
0
120
Member Avatar for Grn Xtrm

Maybe changing your class name to something other than vector will help avoid clashes with java's Vector class?

Member Avatar for Grn Xtrm
0
536
Member Avatar for PhiberOptik

You can get an aray of pixels to do your scanning/looking for algorithms by using the PixelGrabber class (I've attached some code I wrote earlier that will give you a head start). To decode an RGB pixel int, this works: [CODE=java]int pixel = // whatever, eg getPixel(x, y); // int …

Member Avatar for PhiberOptik
0
109
Member Avatar for enuff4life

The first class tries to call a BagOfChips constructor with a parameter of type BagOfChips.Flavor, but you only have a constructor that takes a String.

Member Avatar for JamesCherrill
0
139
Member Avatar for k2k

I just had a quick scan of your code, so I may have missed things, but... In the actionlistener you overwrite the value of sTable that you set up in the constructor, so it seems pointless to have passed the value into the constructor in the first place. Is this …

Member Avatar for k2k
0
114
Member Avatar for neutralfox

Have a look at the Preferences class. It allows you to store & retrieve simple strings, ints, booleans etc in a very easy way, without having to bother about the details of where and how they are stored, basically: [CODE]Preferences prefs = Preferences.userRoot(); prefs.put(prefsItemName, prefsItemValue); ... prefs.get(prefsItemName, "");[/CODE]

Member Avatar for neilcoffey
0
646
Member Avatar for neutralfox

If you use ObjectOutputStream and ObjectInputStream you can send anything you want - Strings, complex Objects, whatever (as long as they are serialisable).

Member Avatar for neutralfox
0
174
Member Avatar for Prateek Parmar

No, it's not (unless there is other code in your app that needs to call a default constructor).

Member Avatar for verruckt24
0
92
Member Avatar for neutralfox

[iCODE]java.awt.Desktop.getDesktop().browse(new URI("http://www.your.url")); [/iCODE] (needs Java .6)

Member Avatar for neutralfox
0
105
Member Avatar for geek-girl

I have no idea why you want to do this! What's wrong with sorting a copy? Remember that the copy array, like the original, is simply an array of references (like pointers) to the Strings; you won't copy the actual Strings unless you go out of your way so to …

Member Avatar for BestJewSinceJC
0
165
Member Avatar for smsamrc

The OO purist solution is to create a tiny class to hold info about the term of the polynomial., as in [CODE]class Term { private int power, multiplier; public Term(int power, multiplier) { etcv}; // getters as usual // other useful stuff such as calculating the term for a given …

Member Avatar for smsamrc
0
2K
Member Avatar for osjak

Why create a new stack in these methods. Just iterate thru the stack and add the elements? [CODE=java]int sum = 0; for (int i: stack) { sum += i; }[/CODE]

Member Avatar for BestJewSinceJC
0
740
Member Avatar for abhi_elementx
Member Avatar for abhi_elementx

The exception is thrown when the index is >= size, so it looks like there is nothing in Company_Cont_Mstr_ComboBox when this code is executed. (Maybe? happens when first cb is populated = fires change event, before 2nd is populated? Test size of Company_Cont_Mstr_ComboBox before setting its index in the change …

Member Avatar for BestJewSinceJC
0
837
Member Avatar for abd640
Member Avatar for rockin_rebel

toUpperCase in the Char class is a static method, so the correct way to use it is: charArray[i] = Char.toUpperCase(charArray[i]); You seem to be getting into difficulties with String vs char. It may be bettert to convert your String to a char array, do the selective case changes in the …

Member Avatar for rockin_rebel
0
3K
Member Avatar for petike

It would be interesting to hear why you have rejected using paint() (or paintComponent()), because that's the "right" way to do it, and guarantees that you will handle things like windows being re-sized or covered/uncovered properly. Looking at your code as it stands, I expect that Swing will use paint() …

Member Avatar for Ezzaral
0
274
Member Avatar for maximilian2006

Java only supports rectangular shapes for the parent window(ie the one that sits in the desktop). You can simulate other shapes by making part of the window transparent, leaving just (say) a circle visible. It's not that easy, but this reference will get you started... [url]http://www.pushing-pixels.org/?p=260[/url]

Member Avatar for JamesCherrill
0
122
Member Avatar for abhi_elementx

The selection happens in the JTable, not in the underlying model, so you need to look at JTable methods like getSelectedRow() etc.

Member Avatar for abhi_elementx
0
110
Member Avatar for ddaudi8

com4j adds COM capabilities to Java in a simple way (well as simple as it';s going to get...). With it, you can use Excel's COM interface to do just about anything you want with a spreadsheet, from Java. It's free. See [url]https://com4j.dev.java.net/[/url] the download package includes a small Excel sample …

Member Avatar for JamesCherrill
0
125
Member Avatar for neutralfox

this represents the object whose method is currently executing. A Thread is a separate stream of execution (eg if you have a dual processor, you can execute two threads simultaneously). Your class implements the Runnable interface, which consists simply of a public void run() method. So new Thread(this) creates a …

Member Avatar for JamesCherrill
0
123

The End.