Skip to content

Tag: java

Jtree not shown on adding a node!

I have a static jtree in a scrollpane. And now iam trying to add child to jtree, it got added successfully. Now, the added node is not visible in the jtree. Try 1: I have tried with model.reload() Try 2: I have tried with tree.setModel() too… Even then newly added child is not visible. but Its getting a…

How to open warning/information/error dialog in Swing?

How to open warning/information/error dialog in Swing? I need standard error dialog with “Ok” button and “red cross” image. I.e. analog of org.eclipse.jface.dialogs.MessageDialog.openError() Answer See How to Make Dialogs. You can use: And you can also change the symbol to an error mes…

JSchException: Algorithm negotiation fail

I am trying to connect to remote sftp server over ssh with JSch (0.1.44-1) but during session.connect(); I am getting this exception: Logs from JSch: I am able to log in to remote server with linux sftp command. I was trying to find any kind of clue in the internet but I failed. Debug output from linux sftp c…

How much time does it take to execute a loop?

Is there any way to know how many seconds does it take a loop to execute in java? For example: It does not have to be accurate 100%, but its just to have an idea of how long it could take. The algorithm inside is some kind of key generator that writes to a .txt file. I expect it to

How to check write permissions of a directory in java?

I would like a code snippet that checks whether a directory has read/write permissions and do something if it does, and does something else if it doesnt. I tried an example shown here: The problem is the exception is always triggered, so it always ends up printing “Bad” regardless of whether the d…

Auto code completion on Eclipse

I want Eclipse to automatically suggest to me all possible options, while I’m writing some variable/class name or keyword, like in Flash Develop or Visual Studio. Is it possible? If not, with which Java IDE can I get this? I’m specifically asking about a way to automatically get the same thing I g…

Tracking “hidden” exceptions

I am inspecting the output of a program of mine where from time to time I see a message like “java.lang.NullPointerException” and nothing else. Because this doesn’t come from my code, I am pretty sure, there is some 3rd party library, where some jerk has done something like: catch ( ex ) { p…

Stuck implementing Wikipedia’s A* (“A star”) algorithm

I’m implementing the A* search algorithm from this pseudo on wikipedia’s article: I’m stuck on the line where I’m asked to retrive the node in openSet with the lowest f value. When has openSet been filled? With what? Should it just have start on the first run? I also don’t undest…