-
Marked Solved Status for coding the summation func in calculator (EventHandling)
hi everyone :) I have a problem here >>which I can't add 2 numbers >> and I don't know what is the solution for that !!>>it always gives me an … -
Replied To a Post in coding the summation func in calculator (EventHandling)
That's a nice refactoring,... for Java 7 ;) Now for current Java you can take it a lot further and simplfy the code massively. I'm referring to the event handler(s). … -
Replied To a Post in Scrolling a JPanel with JScrollPane
Unless all your tiles are moving/changing all the time, maybe you can just re-paint those tiles that have changed since the last call to paintComponent - if you remove the … -
Replied To a Post in Compare
... and line 40 you are comparing a phone number with a name - obviously a typo. -
Replied To a Post in Changing one JSpinner changes other as well
I'm confused. If you want them to change together use one model. If you wnt them to change independently use two models. What's the problem? -
Replied To a Post in Repaint wont call paint
Swing's event queue is inaccessible to you. Just call repaint() and trust it. For updating positions use a java.util.Timer to call your update method at regular intervals, eg 33 miliiseconds. … -
Replied To a Post in data structure
Oh wow, if you can't query the size of the queue that makes it harder. Maybe you could keep your own counter of the number of elements in the queue? … -
Replied To a Post in Repaint wont call paint
Your calls to invalidate. repaint etc tell Swing that the GUI needs to be repainted. That adds an item to Swing's event queue. A separate thread - Swing's event dispatch … -
Replied To a Post in infix to postfix syntax for inputting to a deque
The problem is not with the tokens. ~s.o.s~ gave you the hint 21 hours ago, but you ignored it. You create a variable called `postFix`, but you don't give it … -
Replied To a Post in Repaint wont call paint
You have an infinite loop in a MAX_PRIORITY thread (line 215), so it's not surprising that nothing else gets done. What exactly are you trying to achieve? -
Replied To a Post in Changing one JSpinner changes other as well
If you want two independent spinners then why are you worrying about giving each its own model? -
Replied To a Post in Java Program crashes at around 30min. libosxapp.dylib plugin crash
I see 20 threads there - is that expected? If it's a problem with your code (as opposed to a bug in the lib itself) the it probably relates to … -
Replied To a Post in data structure
How to pop from a queue that just supports enqueue/dequeue: Hint: You can extract any arbitrary member of a queue,eg nth member, by cycling the queue, ie dequeing and immediately … -
Replied To a Post in infix to postfix syntax for inputting to a deque
You misread the question. I didn't ask what was in the DeQueue, I asked about the variable called `postFix`. If youy are still confused, try printing postFix at line 33 -
Replied To a Post in infix to postfix syntax for inputting to a deque
No, it's not the token that's null. What is the value of the reference variable `postfix` on line 23 in the code you posted? -
Replied To a Post in list -> file -> list -> error
Applications need a "master" or "controller" class that start up, manages and controls evrything else. It also acts a central point of reference that is accessible to the whole application … -
Replied To a Post in Custom Binary Format
If your intent is to invest some time to learn about binary files in Java then I'm 100% happy with your plan. J -
Replied To a Post in Custom Binary Format
I think the problem here is that Doogledude is concerned that there will be a performance issue around saving and restoring his game state, and is trying to fix it … -
Replied To a Post in Custom Binary Format
"data written using DataOuputStream can only be read using DataInputStream i.e. it is portable across Java versions but not portable across languages/runtimes" Were you thinking of ObjectOutputStreams? DataOutputStream just writes … -
Replied To a Post in java micro controller bluetooth programming
Personally I've never used the Java Bluetooth libraries, so I can't help you, sorry, but I'm sure you can find whatever tutorials and samples exist on the web... Hopefully someone … -
Replied To a Post in Custom Binary Format
int = 32 bits short = 16 bits byte = 8 bits byte[n] = 8*n bits etc But check out the API - writeByte, writeShort, writeInt all take an int … -
Replied To a Post in Custom Binary Format
I question the need for your own special file format ("much faster" probably means you will save a few microSeconds), but anyway... You can use a DataOutputStream to write java … -
Replied To a Post in Doing Poker (5 cards with four players)
Hi Leonard, welcome to DaniWeb Sure, people here will happily help you. Now you need to be more specific about what questions you want answered. If you have errors you … -
Replied To a Post in java micro controller bluetooth programming
Is there any particular reason to do this in Java? Do you already have Java expertise? Maybe you could do it more easily in a scripting language. -
Replied To a Post in Google Protocol Buffer with java
If you want people to share with you that's a two-way process. You should start by sharing what you have done. Or maybe you just want someone to do your … -
Replied To a Post in list -> file -> list -> error
Definitely not! You just need one connection mamager for the whole application. You could create your manger instance when initialising the engine and share it from there- I guess everything … -
Replied To a Post in list -> file -> list -> error
Fair enough, but personally I would never use an interface to create a global shared variable. In this case maybe it would be cleaner to have a ConnectionManager class that … -
Gave Reputation to mike_2000_17 in OOP development problem
I think that it makes some sense to consider a Vector as a subclass of (derived from, special kind of) Matrix. For example, Matlab creates vectors as matrices (as Nx1), … -
Replied To a Post in list -> file -> list -> error
Yes, if you declare a variable in an interface it is assumed to be a constant (ie `static final`). Using it to hold a reference to an object with non-constant … -
Replied To a Post in list -> file -> list -> error
Excellent! But why not just connectionList = (Collection<? extends MyConnection>) ois.readObject(); -
Replied To a Post in convert binary to octal
Take 3 characters at a time (from the right hand end) and convert them to one octal digit. (You could use if tests, a switch, or index an array). -
Replied To a Post in list -> file -> list -> error
... and 3. Since you have a try-with-resources, your FileOutputStream is guaranteed to be closed when you exit the block, either normally or abnormally - which is more than your … -
Replied To a Post in OOP development problem
It worries me that much of this discussion is about the difficulty or efficiency of inheriting either way. And although Liskov is 100% relevant, it's a heavyweight way of expressing … -
Replied To a Post in list -> file -> list -> error
Yes, and similarly for reading it back in. ps: It's easier for us to read your code if you stick to Java naming conventions - connectionList, not Connectionlist (looks like … -
Replied To a Post in list -> file -> list -> error
No need to change that! A `List` *is* a `Collection`. (interface List extends Collection, All Known Implementing Classes: AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolvedList, Stack, Vector) I was … -
Replied To a Post in Intersection of Keys between two HashMaps
Maybe just loop through the keys of one of the Maps, deleting all the entries that don't have a corresponding key in the second Map? -
Replied To a Post in Print all elements in ArrayList
Loop through the list printing each Pet in turn. -
Replied To a Post in list -> file -> list -> error
Yes - that's definitely a problem. Your load will have to use a loop to read all the instances. Alternatively (easier) is ConnectionList is an ordinary Java Collection, you cam … -
Replied To a Post in list -> file -> list -> error
What do you intend with `thisConnection` and `newConnection`? They don't seem to make a lot of sense. Anyway, you can only serialise a class that implements Serialisable (so check its … -
Replied To a Post in How do I create a SQL database & table in Java?
Your post's title says "in Java", but the requirement is "in VB script". Either way, when you have worked out what language you are using, you will find many comprehensive … -
Replied To a Post in Help with java project - SIMON game
"under utility" tells us nothing, especially when the text `utility` does not appear anywhere in the original program. You need to post the complete exact error message (not just your … -
Replied To a Post in sending and receiving data over socket
Opening and closing multiple streams on a single Socket can cause data loss problems (buffers discarded etc). Opening multiple streams and not closing them is even worse. You could try … -
Replied To a Post in Help with java project - SIMON game
Because you did something wrong. -
Replied To a Post in Resizing all textures by screen width??
I was suggesting java.util.Timer to update the model, not the GUI. In general, the model may be CPU intensive (eg checking collisions between arbitrary shaped sprites) so I avoided javax.swing.Timer … -
Replied To a Post in Resizing all textures by screen width??
I don't understand Are you disagreeing with my choice of java.util.timer, or my use of repaint? -
Replied To a Post in Resizing all textures by screen width??
The Timer method for running an update every 30 mSec (33 fps) looks like scheduleAtFixedRate(this::updateSimulation, 0, 30, MILLISECONDS) // NB Java 8 where `updateSimulation` is a method that updates the … -
Replied To a Post in Resizing all textures by screen width??
Normal practice for Java animation is to use a `java.util.Timer scheduleAtFixedRate` to update the state of the model, then invalidate the GUI state to force a re-draw. That way the … -
Replied To a Post in Resizing all textures by screen width??
Maybe you could render all your graphics at some fixed resolution (eg HDTV) and use a `scale(double sx, double sy)` to scale all the contants to whatever the actual screen … -
Replied To a Post in Corrupt file through UDP
Instead of just sending fixed length buffers, send a byte count followed by the buffer. For most packets the count will == the buffer size, but for the last packet … -
Replied To a Post in Create File with other files Contained in that file
Yup XMLEncode and XMLDecode will convert anything bean-like to XML dead easily. Also works for beans-within-beans, so you can encode/decode an entire List, or arbitrary top-level container object in just …
The End.