7,116 Posted Topics
Re: Just reading the not-commented stuff I see around line 165 you create a JPanel, create a JScrollPane using that panel, add the JScrollPane to you (main?) frame. Problem is, I don't see you adding anything to the panel inside the scrollpane. If you want a window with everything in it … | |
Re: Google "Event Dispatch Thread" (EDT or "Swing" thread). All GUI updates are single threaded on the EDT, as are all GUI-initiated user interactions. So your jButton2ActionPerformed executes on the EDT. While it's executing all other GUI-related activities are queued (including your progress bar re-paints). There are a number of ways … | |
Re: Timer is an option. Timers can be one-shot OR repeating. You need a timer with a 60 second initial delay and no repeats. | |
Re: ME is the Micro Edition - specialised version for smartphones etc SE is the Standard Edition. It's all you need for ordinary desktop apps and applets and is (roughly) a superset of ME. EE is the Enterprise Edition - for large-scale corporate client/server/database apps - it's a superset of SE … | |
Re: If you look at the "All Known Implementing Classes:" for Interface Collection<E> you'll find a number of priority queue implementations. Which one you chose depends on your exact requirements. If you have to build it yourself, have a look at TreeSet using a Comparator that sorts the items in priority … | |
Re: If memory usage is a big issue in your app you should use an array of double primitives, not a Vector of Double Objects. doubles in an array occupy 64 bits each. | |
![]() | Re: [QUOTE]Am thinking I need some booleans in there or my comparing of array technique is a massive fail.[/QUOTE] Definitely not a massive fail - just call it a Beta version! I think you're right about needing some booleans. Once you have "used" a number in Random for a match you … |
Re: Probably because you override paint rather than paintComponent. paint also handles painting of children (eg lables ina child panel!), borders etc, and should not normally be overridden. paintComponent just handles the painting of the content area, and is the one you normally override. | |
Re: Did you try [CODE]DefaultCaret caret = (DefaultCaret)textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);[/CODE] ? | |
Re: javax.swing.Timer is what you need - documentation & samples in the usual places. Define a timer task (a "run()" method) that you want to run repeatedly. On click of the start button start a Timer that will run that task every 3000 msec. On click of the stop button stop … | |
Re: I'm confused. Do you need help getting the counts, or displaying them in a label, or adding a label to the bottom of your window, or creating a superclass??? | |
Re: "it give me some kind of problem" what problem EXACTLY? | |
Re: Start by studying this section of the Java tutorials and the following few pages: [url]http://download.oracle.com/javase/tutorial/uiswing/painting/index.html[/url] | |
Re: Have a look at the getText() and setText(String text) methods that JTextField inherits from JTextComponent. ps Watch out for your capitalisation - java is case-sensitive | |
Re: As a general rule you don't want to put code of that kind of complexity and context directly into an ActionListener. Best practice is to put it into a method in the appropriate class, then just call that method from a one-line ActionListener | |
Re: The file name that you type in the command line argument is available to you as a parameter in your main(....) method. Now you have the file name in a String, so you can use what you learned from mKorbel's links to create the file. | |
Re: Black box testing tests the system as a whole, based on its external specification, without any particular reference to how it is built internally - it treats the system as a "black box" with unknown contents White-box testing (better known as clear box or glass box testing) is based on … | |
Re: [QUOTE]We'll help you get started ... but only if you show that you're willing to put in effort as well.[/QUOTE] How far have you got researching this yourself? What sources of info have you used? | |
Re: Add some instance variables to your class (eg a list of shapes, colours, positions ...). Add some public methods to set those variables. Use the variables in paintComponent method to control what/where/how you paint | |
Re: From the info you have given the method could be defined in either place. If you define it in a different class then how you call it depends on whether it's static or not: If static, call it using the class name, no instance required If not static, you need … | |
Re: 1st error: you declare inFile in main, then you try to use it in a different method. variables declared in a method only exist within that method. If you want to share variables between methods you must declare them in the class, but outside any one method. Fix this, and … | |
Re: How is that delimited? Is there anything between the sH or the r2? Suppose the name is HamishMacDonald64 or Jean-ClaudeVanDamme75 ? | |
Re: Class structure looks dumb to me. 2Dice is not a "kind of " Die. It would make more sense to have a (non-subclassed) class called "HandfullOfDice" that took an int numberOfDie as a param on the constructor, had a list of Die objects as an instance variable, and had public … | |
Re: if (a) ... else if (b) ... else if (a && b) ... never executed because the else if won't be executed if (a==true) (see line 1) and (a && b) fails if (a==false) | |
Re: Was this a question, or just some insane light show? | |
Re: [QUOTE]everytime the controls enter into for loop the output is printed on the next line.[/QUOTE] You print using println(...), which always adds a newLine char at the end of whatever you print. If you use print(...) instead then the next printout will continue on the same line. | |
Re: Do you mean redirect System.out.print... to a file? If so: [CODE]PrintStream printStream = new PrintStream(new FileOutputStream(fileName, true, true); // true for append and autoflush) System.setOut(printStream); System.setErr(printStream);[/CODE] | |
Re: 10001010 1100111 isn't 8 bytes, no matter how you count them. I don't have time now to study your code with all those String manipulations, but the normal way to do bit-wize manipulations of the contents of an int is via boolean operations, eg [CODE]// get the first (high-order) byte … | |
Re: You have been on DaniWeb long enough to know that "It doesn't seem to work" isn't good enough. If you want someone to help, please give a proper description of your problem and the things you have already done to try to solve it. | |
Re: No. x=x*j; will be executed 2 times 1st pass x = 1 * 0 2nd pass x = 0 * 1 Answer is still 0 You don't need {} for the contents of a for loop if there is only 1 statement. If you have any doubt try executing this: … | |
Re: There seems to be no attempt to add any JLabel to anything - which is probably why it doesn't work. Don't confuse things by trying to add the JLabel to your special panel, just add it to the JFrame directly below the panel. However, cale is right in saying that … | |
Re: 25 posts and you still don't know about posting your code properly indented and in code tags. Your compiler error messages have the line numbers, but do you expect people to count the lines in your code to see which they are? We're willing to help, but we are not … | |
Re: 1. You are expected to use the Graphics object passed to you as a parameter 2. aBoolean == true is just like anInt + 0, ie horribly redundant 3. Override paintComponent, not paint 4. panel.paint(gr); never call paint directly. call repaint() and let Swing do the rest [CODE]public void paintComponent(Graphics … | |
Re: 1. Program listing and Exception messages do not match (line 48 is not in Vec.add) 2. Please stop creating new threads for the same problem | |
Re: It looks like you have installed the Java Runtime Environment (JRE) which allows you the run Java programs, but not the Java Development Kit (JDK) that allows you to create them. If you haven't already done so, download and install the latest JDK. ps java.exe runs java programs in a … | |
Re: Your code would be easier to read if you removed all the redundant comments. You can assume that anyone reading your code understands Java, so there's no point having a comment that just explains what the previous statement means - eg [CODE]System.out.println("Welcome to the Payroll Program"); //output Welcome to the … | |
Re: Looks like nobody here knows about edge assembly recombination. What is it? | |
Re: Have a look at [url]http://download.oracle.com/javase/tutorial/uiswing/components/table.html#renderer[/url] in particular the section "Using Other Editors" that starts quite near the bottom... | |
Re: Looking at the output one line at a time, starting from the top (ie as you would print it) the pattern we see is some node's left sub-tree (if any) the node itself the nodes right sub-tree (if any) then the sub-trees are the same (recursively), and each time you … | |
Re: This sounds like drop-down combo box, but I suspect it's not going to work too well with a JComboBox when you need to change the list contents with every character typed (problems getting responses, re-paint flickering, changes of focus...). So I would have a JTextField with a JList positioned underneath … | |
Re: [url]http://download.oracle.com/javase/tutorial/java/javaOO/methods.html[/url] [url]http://download.oracle.com/javase/tutorial/java/javaOO/arguments.html[/url] wonderful thing, Google. | |
Re: Of all the layout managers GridBagLayout is by far the most capable. There's a bit of a learning curve because there are so many options, but IMHO it's worth it. You can play with the easier ones for little homework apps, but if you are going to use Java seriously … | |
Re: [url]http://download.oracle.com/javase/tutorial/deployment/applet/security.html[/url] | |
Re: [QUOTE]i dont know what the problem..[/QUOTE] If you want someone to help fix this problem [B]you have to tell us what it is[/B]! EXACTLY what is wrong. Details please. | |
Re: IMHO you can't beat the official Sun/Oracle Java learning tutorials [url]http://download.oracle.com/javase/tutorial/uiswing/[/url] Don't worry about learning AWT as such; if you learn Swing then that will include those aspects of AWT that still apply, but you will avoid getting side-tracked by those aspects of AWT that have been superseded in Swing. | |
Re: What Applets Can and Cannot Do: [url]http://download.oracle.com/javase/tutorial/deployment/applet/security.html[/url] | |
Re: Have a look at HashMap to map words to lists of line numbers, and ArrayList to hold a list of line numbers. All the info is in the usual Java API docs. | |
Re: Any particular reason for doing this? - it's not easy, in fact I would rate it as a fairly advanced GUI exercise. ps I did this for an app about 8 years ago, and just dug out the code. It's under 200 lines, but I seem to remember having a … | |
Re: check out the getSource() method for ActionEvents | |
Re: All java parameters are call-by-value. (Remember that all variables that are not primitives are references to Objects, so it's the reference that's passed by value) So in your example on line 3 parameter is a reference variable that contains a copy of the reference that was used in calling the … |
The End.