You use a ListSelectionListener (normally)
http://download.oracle.com/javase/tutorial/uiswing/components/list.html
You use a ListSelectionListener (normally)
http://download.oracle.com/javase/tutorial/uiswing/components/list.html
Use a JList and not a JTextArea
http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html
http://download.oracle.com/javase/tutorial/uiswing/components/icon.html
http://download.oracle.com/javase/tutorial/uiswing/components/label.html
http://download.oracle.com/javase/tutorial/ui/features/components.html
http://download.oracle.com/javase/tutorial/ui/features/index.html
http://download.oracle.com/javase/tutorial/ui/index.html
http://download.oracle.com/javase/tutorial/
Just let it put the version variable in and don't worry.
Just remember, however, that if the interface of the class changes (i.e. new public/protected methods, etc) to change that number or you will have problems if the class is actually serialised as part of the app.
Okay? Good for you. I hope you're doing alright with that.
What is a spreadsheet except a glorified 2-dimensional array. Sorry, but I can help no further.
Closing this multiply resurrected zombie now.
By arranging them properly (GridBagLayout with proper constraint settings and properly designed components will let you do nearly anything) and letting the layout manager do it.
The default layout option for JPanels (which you use in your class) is FlowLayout with a default flow of left to right, so, as Ezzaral says, use a different layout.
How Ajax will be used in java ?
Since I'm not sure if this question is a question or just a spam intro I'll leave the question and just remove the spam link.
Don't use = (or !=) to compare Strings. use "str.equals(str)" (or !str.equals(str)).
Edit: IOW, leave the while condition checking the "null" status (thereby catching the EOS).
And, as the first line of the loop check the String's value with the equals method and break the loop when that value matches a specific "kill" value.
Because you won't get "null" until the server closes its end of the connection. Which you don't want, I would assume. I would assume you want to continue using the same connection, right? So the server is going to have to send some extra String, or something, to signify that its finished, and the client will have to check for this String and break out of the loop once it gets it (without showing that String to the user, of course. Or, you could simply use the last line of the menu as the "key" to break out of the loop, if it has a fixed, set text.
:sigh: No. Closing this zombie now.
JEditorPane is the main component you'll be needing though.
(and the decompile advice is just a bit of sarcasm)
In truth, however, this is one of those cases where the old adage "if you need to ask, you probably shouldn't be doing it" applies though. As, when you have to ask this question, it means that you will be in way over your head in that project.
I'm sorry, but those are features. They are only advantages when applicable.
#1 is not applicable if the system being designed is only going to run on a single platform (regardless of which).
#2 is only applicable if it is needed. A simple site with a few pages of only minorly interactive content won't
#3 so are many others, and, I can repeat the #2 statement
#4 a complete repeat of the #3 advice.
Once again, I'm sorry, I don't mean to be harsh, but not all features of a language are necessarily an advantage in all situations. In fact, each of those features is a distinct disadvantage when my counter points are applied.
Discover the requirements, then analyse your choices, don't attempt to use a pat list of "features" as "advantages" and blind yourself to the realities. And, when offereing it as advice than qualify the statements.
One thing you should know about "static final" variables (at least "public static final", but probably also for "static final" and "protected static final", although I haven't tried those), and that is that their values get compiled directly into the classes using them. I.E.
compile both of these classes
package test;
public class bogus1 {
public static final int a = 1;
}
--------------------------
package test;
public class bogus2 {
public static void main(String[] args) {
System.out.println(bogus1.a);
}
}
Then execute bogus2 and it will print "1", obviously.
Now change bogus1.a to 2 and compile only bogus1 (note do not do this in an IDE as that will automatically compile both classes, per default)
Now execute bogus2 and it will still print "1".
Just a small note of warning.
And still the wrong tool for the job, but I think I'm finished talking to the walls now.
And you are still in the wrong. This entire "setup" is so far out of whack it's not even funny anymore. Oh well, whatever works. You can also jam a knife into your eye in order to scratch the back of your head, but is it worth it?
Literal Strings are "interned" and exist only once regardless of how many times they are used in a program. new String(...) creates a String that is not interned and is completely independent to anything else (and doing it with a literal string in the constructor means that two string get constructed, the interned literal string and the object created by the call to new).
Edit: Nevermind.
$ matches end of String so how can you have the H after the end of String. And, of course, you want to match to the read String ("str") not to some bogus string "filename". What was that suppossed to achieve?
Also, why not startsWith and endsWith as already suggested (in a few of your other threads on this)?
if (str.startsWith("ATOM") && !str.endsWith("H")) {
will give all lines that start with ATOM and do not end with H. Is that not what you wanted?
P.S. Actually posting the code you try (as you finally did) rather than simply whining that it doesn't work, or doggedly pursuing your original path (which you'd already been told won't work), allows us to finally help you fix, and allows you to finally advance.
Java is not even close to "a slow death", as you call it. The largest problem with .Net is that it runs only on Windows and most server architectures (which is where most commercial activity takes place) are not Windows.
I know, I know, .Net, in theory, can run anywhere, but for that a VM is needed and the only platform, besides Windows, where a .Net VM exists is Linux, and that in a very restricted form. The license costs for producing a VM are oppressive, and a Java VM already exists for most OSes (not to mention portable devices), so not many OS producers are really willing to create one, and no company that produces their own is willing to "give it away". So, go .Net and stay on Windows, or go Java and go everywhere (well, a lot of places, anyway), or go other languages and produce varying versions for the varying OSes.
If you are going to worry about having a "complete" skill set before you ever start looking for work, forget it. Generally however, web technologies (HTML, XML, CSS, SOAP, HTTP, SSL/TSL, probably in that order) and general DB (mainly simply SQL) are always pluses.
Edit: P.S. by problem with .Net, I mean the main problem .Net has with trying to "kill", or at least marginalise, Java, not necessarily a problem with the language itself. However, since it is advertised as "multi-platform", it is, at least, a "misleading" feature, as it …
s/\/.*$//
getComponents and instanceof
It may seem helpful to a beginner, but it's not. IDE's are for people who already know what they're doing in order to increase their effeciency. You need to understand the tools and the processes behind everything and an IDE shields that from you.
replace all single slants with double slants before (or while) calling "aregex".
str.replace("\\", "\\\\")
note: replace, not replaceFirst or replaceAll.
Create a class that extends FilenameFilter (not FileFilter) (and it can even, easily, be an anonymous inner class) and use the setFilenameFilter method of FileDialog. Let's see your attempt at that (BTW a quick look at the API docs should have pointed this out, FileDialog only has about 10 methods). Simply have the "accept" method return true for filenames ending with "mp3" as a simple explanation. Try it, and post your attempt if you can't get it to work.
I do, however, need to ask why you wish to use the awt FileDialog rather than the Swing JFileChooser. I hope you're not mixing awt and swing elements.
Well, post what you have so far, we are not simply going to do it for you.
Yes, I have stated multiple times, that the components will take the minimum (or preferredSize amount of space) space needed to display itself. It might help if you actually showed some more of your code as this works just fine
import java.awt.Color;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class GridBagTest extends JFrame {
public static final long serialVersionUID = 0L;
JPanel redPanel, bluePanel, greenPanel;
GridBagConstraints gbc;
Container container;
public static void main (String args[]) {
GridBagTest gbe = new GridBagTest();
try { Thread.sleep(2000); } catch (InterruptedException ie) {}
gbe.setVisible(false);
gbe.dispose();
}
public GridBagTest() {
setSize (400, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
container = getContentPane();
redPanel = new JPanel ();
greenPanel = new JPanel ();
bluePanel = new JPanel ();
redPanel.setBackground(Color.RED);
greenPanel.setBackground(Color.GREEN);
bluePanel.setBackground(Color.BLUE);
GridBagLayout gbl = new GridBagLayout();
container.setLayout(gbl);
gbc = new GridBagConstraints ();
AddPanel (redPanel, 0, 1);
AddPanel (greenPanel, 1, 8);
AddPanel (bluePanel, 9, 1);
gbl.columnWeights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };
setVisible (true);
}
public void AddPanel (JPanel panel, int gridx, int gridwidth) {
gbc.gridx = gridx;
gbc.gridy = 0;
gbc.gridwidth = gridwidth;
gbc.gridheight = 1;
gbc.weightx = 0.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
add(panel, gbc);
}
}
And seems to do exactly what you're asking.
This post is completely unrelated to the rest of the thread. Start your own thread and do not resurrect zombies to post unrelated material.
Because you wrongly overrode equals. Add the "@Override" annotation above every method that is suppossed to override something and you would notice that. The "equals" method needs to take "Object" as the parameter, not "WatchedPath".
Edit: And, obviously, you should then check that are actually getting a "WatchedPath, and not something else, and, regardless, you should also check that it is not null.
Edit Again: As well as checking that "dir" is not null, before calling equals and/or hashCode, and/or CompareTo on it, of course. And, for the compareTo to be used properly, don't forget to implement Comparable.
call pack on the frame in which the component resides
or
call doLayout (and/or validate) on the component to which the component was added and then repaint
Edit: Although, in the second scenario, the layout of the frame itself (if the size of "subcomponent" has changed) will also, still need to be updated, so maybe simply call pack on the Frame or doLayout on the contentPane of the frame.
Regardless of the amount of input parameters use PreparedStatement. What if getParameter on USER return ';delete * from FMC_EMPLOYMENT;--
? Or, more innocently, either one contains a simple "single quote" (')? PreparedStatement will prevent this sort of thing. It is not perfect in preventing SQL injection attacks, but it definately helps.
As far as the errors, then "req" is not defined in this scope.
And you forgot a quote (") at the end of the statement, before the closing paren. (And you forgot a plus (+) between the get parameter and that closing string.)
You need to look at your code more carefully.
Because, since you are simply painting to the graphics in an external method, rather than overriding the paintComponent method in JPanel will cause the standard "painting" of the panel to erase it. Either extend JPanel and override the paintComponent method, or have that method create an image (use BufferedImage and you can do that exactly as you are doing this now) and set that as the contents of the JPanel.
if this is the convention i would love to follow =)
thanks very much!
Also, if you distribute your app as a jarfile, and place the mysql jarfile alongside it, you can include a reference to that jar in your jars manifest and the command is just "java -jar <yourjarfile>" (assuming the mainclass attribute is set correctly). See http://java.sun.com/docs/books/tutorial/deployment/jar/index.html for further info.
Edit: And that command, not coincidentally, is usually what is recorded in the file associations for jarfiles.
No it doesn't, that's just you're editor's highlighting. If you don't want to see that then use < scalar(@array)
rather than <= $#array
In your main method you want to define "moonwieght" so you need to do
moonweight = someMethodCall(earthweight)
and "someMethodCall" needs to return earthweight divided by 6. And someMethodCall, of course, needs to de declared to take an argument.
Give it a try and post your new code (complete).
Uhm, if it's "web-hosting", chances are you only have "web" space. I.E. you can place pages, and probably jsps, servlets, phps, asps, etc there, as well as at least a small "download" area, but anything else is a system application and those lie outside the realm of "web-hosting". Ask your provider about any possible "equivalent" services that they may (and probably do) already provide (which also includes DB services, of course), or are willing to install and make available.
Now, as stated above, if you have a "dedicated" server, virtual or not, then do what you wish, that is much more than simple "web-hosting", so I can only assume that this is not what you have.
With a text editor and a jdk.
I want to design utorrent client for my semester project in java, can anyone tell me where should i start and what are the necessary steps for this, also if any useful website and information. Thank you.
Here, try this link. Much better than Salems. That bunghole!
Keyword "JNI"
Write a method.
"Components" don't have any kind of "positioning" features. You place components into layout that is part of a container, and that layout takes care of the positioning. Also, the border is "removable" on all swing elements, see the "sertBorder" method and the "EmptyBorder" class.
For full positioning control use GridBagLayout (you have x/y coordinates there, but probably not how you're thinking of them), but that is the hardest layout manager to use correctly.
If you feel you really must control all features of the layout then google for "Java Swing Null Layout". Be forewarned, however, that the slightest differences from machine to machine (I.E. resolution, OS, system font settings, etc, etc, etc) will probably "break" your GUI using Null Layout.
Why do only want the last two digits? In any case, to return those as an int simply do modulus 100. Do you know what hascode is meant for? Even if you do only return the last two digits they will still never match the original String. What, exactly, are you trying to acheive? What is your goal with this entire thing?
What is wrong with this thread?
What is this int[] that you want? If it is the RGB values for the entire image, then simply use the getRGB method I posted in your other thread and don't worry about creating a "Raster" object at all. If it the RGB values for a single pixel row of the image, you can still use that method I posted in your other thread, you just need to slightly change the arguments.
Edit: And I am locking this thread now, continue in your other thread.
Why use getBytes? Why don't you use toCharArray? In any case, the easiest way (although not necessarily the most effecient) is to do new String(byte[]).toCharArray()
.
Okay? I have no idea why anyone would want to "vote down" that post, but ......
To each his/her own, I guess. What about it was disagreed with would interest me though.
An IDE is an Integrated Development Environment. It is, at it's most basic level, a jumped up editor with compiler capability.
Java Beans, at their most basic, are simple Java Classes where all members are private with getter and setter methods.
You can only change private members with a lot of effort, and none of them are recommended. Like I said, do not confuse access modifiers with real world security. That is the last time I am going to say it. Go through that posted tutorial and read the The Java Language Specification for more detail. I'm sorry, but I'm done here.