-
Replied To a Post in Online Compiler in Java
If you Google "writing a compiler" you will find lots and lots of tutorial material that will tell you what you need. It shouldn't be difficult to extend it to … -
Replied To a Post in Coding
To be brutally honest, it seems like you're not ready to tackle a compicated GUI program yet. You'll get far better long-term results by going back and learning the basics … -
Replied To a Post in Coding
You will probably find it easier to use the next method `public void setSelectedIndex(int index)` where index is 0 for the first tab, 1 for the second etc -
Replied To a Post in Coding
Assuming you asre using a JTabbedPane (if not, you should be), you can learn how to respond to a button click here http://docs.oracle.com/javase/tutorial/uiswing/components/button.html and how to work with tabbed panes … -
Replied To a Post in Why we use Interface
Think about this example. The `Comparable` interface defines a method `compareTo` that compares two objects so they can be sorted etc. Many classes implement this interface - eg Integer, String … -
Replied To a Post in java SE 7u67
Was that 64 bit NetBeans? What's wrong with Java 8 (the current version)? -
Replied To a Post in Eclipse IDE
Yes, they are all the old versions. Just download the latest (Luna) and ignore all the others. -
Replied To a Post in set image as Background
You have used absolute coordinates to place your labels, which is OK if you will never run this on any device with a different screen resolution. In particular, run it … -
Replied To a Post in Java help needed
Small point: Java programming conventions prefer the use of "camel case" rather than underscores, so accountBal would be better advice than account_bal. -
Replied To a Post in set image as Background
Raj: How do you intend to keep the other components in front of the image JLabel? Which layout manager would you use to place components overlapping the image JLabel? -
Replied To a Post in I/O of txt file
Without seeing the relevant code there's absolutely nothing I can say. -
Replied To a Post in I/O of txt file
Don't worry about indexOf, replaceAll is the better option. If you use indexOf you will also have to a load of substrings to do the replacement. replaceAll is the easiest … -
Replied To a Post in I/O of txt file
You're looking for the abbreviations anywhere in the String, so cpmparteTo isn't useful for that. Have a look at the String class, `indexOf` and `replace` methods. -
Replied To a Post in I/O of txt file
Yes. But you don't need to process the whole message in one go, just read/process/write one line at a time. Its easier that way. -
Replied To a Post in I/O of txt file
If you think about it... You need to know what all the abbreviations are before you can start processing the text file. So the overall plan needs to be: read … -
Replied To a Post in Show a message while a method is running
> About "Public Static Variables" what are the issues involved with using them. [Here's](http://c2.com/cgi/wiki?GlobalVariablesAreBad) a pretty decent discussion of this topic. -
Replied To a Post in Show a message while a method is running
The static "global" variable is a perfectly valid solution... maybe not the best O.O practice, but OK in this context. It's certainly the easiest to code! As for other speedups, … -
Replied To a Post in Thousand threads write to one text file simultaneously
I did say there is a synchronising lock associated with each file. That's essential to avoid concurrent updates to one file. But it's not a global lock, and won't prevent … -
Replied To a Post in Show a message while a method is running
You can use one connection with multiple SQL commands and strings. Just connect once and use multiple createStatements. Access the connection just like any other Java variable - pass it … -
Replied To a Post in Selection Sort help
Yup, that's what you get when you print an array - it's the toString() method that arrays inherit from Object - the bracket says its an array, the I says … -
Replied To a Post in Selection Sort help
Yup, that's what you get when you print an array - it's the toString() method that arrays inherit from Object - the bracket says its an array, the I says … -
Replied To a Post in Selection Sort help
The code on lines 21-36 sorts the data (or it will, when you've fixed the bug), so it has to be after that. The main method ends on line 38, … -
Replied To a Post in Thousand threads write to one text file simultaneously
> The synchonize part is when you check if the file is locked. If it is locked, exit the synchronized and go to sleep. If the file is not lock, … -
Replied To a Post in Selection Sort help
If you want to display the output (the contents of the array at the end), and you know loops and print, then what exactly is your question? -
Replied To a Post in Show a message while a method is running
If you keep a master table with the right number of complete decks, you can simply get a shuffled deck by selecting all the records in the master in random … -
Replied To a Post in pseudo perfect number
There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in … -
Replied To a Post in Thousand threads write to one text file simultaneously
You simply need some arbitrary object xxx associated in some way with that file, then your file writing method needs a synchronised (xxx) { // update the file } so … -
Replied To a Post in Thousand threads write to one text file simultaneously
That changes everything. Thousands of clients to 60 files means massive contention for each file, and FIFO queueing is appropriate. But if it's a thousand files then there will be … -
Replied To a Post in set image as Background
JPanel is very standard stuff. Just add all your controls to the JPanel, then add the JPanel to your JFrame. Later on you will discover all kinds of reasons why … -
Replied To a Post in set image as Background
You create a subclass of JPanel and override its paintComponent method to draw your image when the panel is repainted. Then add your components to the panel to display then … -
Replied To a Post in Thousand threads write to one text file simultaneously
As I understand it 11/12 is a standard Java server socket, creating a thread to handle each client socket as it connects. This is all about the threading - with … -
Replied To a Post in Show a message while a method is running
First mistake is creating a new connection for each statement. Opening a connection is expensive. Just open a connection when starting the program and re-use that throughout. Secondly: I wasn't … -
Replied To a Post in Show a message while a method is running
Database processing over a network connection is exactly the kind of thing SwingWorker is good for, so that's OK. But 7 seconds for 104 tiny records? That sounds crazy! If … -
Replied To a Post in Show a message while a method is running
That's a very good point. A standard Fisher-Yates / Knuth Shuffle on a 52 element array runs in microseconds. -
Replied To a Post in Show a message while a method is running
OK, that's exactly the scenario I guessed in my first post. You cannot do it like that becuase of the way the EDT works. SwingWorker is definitely what you should … -
Replied To a Post in Copy from text file to Object type arrayList in Java
Nice example. You can push the Stream usage a bit further, depending on the overall requirements, along the lines of: Files.lines(Paths.get("studentTest.txt")) .map(line -> line.split(":")) .filter(parse -> parse.length == 2) .map … -
Replied To a Post in Java run windows system command and get result
1. With the wait before getting the input stream the process hangs with a 210k file on my machine (win7 64, Java 8). No surprise there. 2. No, there really … -
Replied To a Post in Show a message while a method is running
Are you trying to do this? actionPerformed ... show "busy" message do some stuff remove "busy" message if so... Everything to do with Swing (eg painting the screen, running actionPerformed … -
Replied To a Post in Java run windows system command and get result
OK, sorry to hear about the 1.6 requirement - I gues your client/boss knows that it's out of support and has security problems that will never be fixed? I ran … -
Replied To a Post in Thousand threads write to one text file simultaneously
> the server has about 60 texts files later... > I have almost 1000 files which is it? -
Replied To a Post in Thousand threads write to one text file simultaneously
Create a LinkedBlockingQueue for each file. When a client sends data, just add it to the appropriate queue. For each queue, create a thread that loops taking the top item … -
Replied To a Post in get position of the maximum number in a singly linked linked list
You already have a method to find the largest value. All you need is exactly that same logic, plus keep a count of the position as you loop. Each time … -
Replied To a Post in Java run windows system command and get result
... and a small ps - a tidied-up version of your getStringFromInputStream private static String getStringFromInputStream(InputStream is) { StringBuilder sb = new StringBuilder(); try (BufferedReader br = new BufferedReader(new InputStreamReader(is, … -
Replied To a Post in Java run windows system command and get result
Just for reference... I ran this code (with try/catch, imports etc), using your `getStringFromInputStream` method unchnaged, against a 210k text file with perfect results... Runtime r = Runtime.getRuntime(); Process pr … -
Replied To a Post in Java run windows system command and get result
Yes, it certainly looks like a OS limit on the sysout buffer. Can you post your latest code because what you are trying to do is a perfectly normal thing … -
Replied To a Post in Java run windows system command and get result
Java Stream buffer size may affect the efficiency of your execution, but it won't change whether it works or not. Maybe the problem is that you waitFor the process to … -
Replied To a Post in Java run windows system command and get result
That code should be able to read the process output up to the limit of a single String. Maybe it's the logger that's the problem? Try just printing the string … -
Replied To a Post in Java run windows system command and get result
What code are you using to process the output stream from your process? -
Replied To a Post in Thousand threads write to one text file simultaneously
The obvious choice is a LinkedBlockingQueue. As the API doc says: > BlockingQueue implementations are thread-safe. All queuing methods achieve their effects atomically using internal locks or other forms of … -
Replied To a Post in Help Me Please
DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules …
The End.