You may need to change the interval indexes in fireIntervalAdded() to reflect the new interval.
Your construction is fine. You could even just use JList lstImage = new JList(myArray);
without the intermediate variable 'model'.
You may need to change the interval indexes in fireIntervalAdded() to reflect the new interval.
Your construction is fine. You could even just use JList lstImage = new JList(myArray);
without the intermediate variable 'model'.
Well, that selection call should work. Are you certain the TreePath includes all nodes up to and including the one you want to select?
If your class implements the ListModel interface (which it does if you extend AbstractListModel), why not use the constructor JList(ListModel dataModel)?
Edit: Nevermind, you posted the code while I was composing this.
> If need to type the contained ArrayLists but those can contain any type you can use
> <ArrayList<ArrayList<?>>
That way he would neither be able to instantiate nor insert elements into the given list.
Ah, thanks for pointing that out. Since I've never used the 'unknown' type in that manner, I didn't realize the limitation. Good to know.
>Well, given the number of new threads posted daily,
>most don't seem to have any difficulty figuring it out.
The site design has changed significantly at least once since this thread was started in 2005.
Perhaps, though my response was to the individual who dug this post out of history to claim that it was difficult to figure out how to post a new thread.
You would be much better server by creating a class to hold those attributes then, rather than lumping them into an ArrayList and having to discern the various properties by index.
people who whine about people whining about smoking.
No kidding. Those are the worst.
Well, given the number of new threads posted daily, most don't seem to have any difficulty figuring it out.
Have you looked at the Eclipse documentation at all yet?
Stacks are useful for such things as well.
Obviously the point of your homework is for YOU to come up with a solution. Handing you the solution defeats the purpose. Post your code and describe what troubles you are having if you would like assistance.
The number of elements in the ArrayList has nothing to do with the type of those elements. You only need to specify the type.
If need to type the contained ArrayLists but those can contain any type you can use <ArrayList<ArrayList<?>>
, but if you are using mixed-type collections you might want to stop and make sure you know why. There are cases in which they are useful, but in general you intend to use the objects in a collection in some consistent manner (else why did you group them together at all?) and perhaps you should really find a common type for them to share. Often that type is a base class type or an interface which all of your elements share so tey can be operated upon in a uniform manner.
You must be using a JDK prior to 1.5, because 1.5 and 1.6 will allow you to pass that Double in place of a double parameter (autoboxing).
You can use Double.parseDouble(String) to convert direct from a String to a double primitive value without the need to first create a Double.
Aside from that, do not use "==" to compare Strings in your calculate function. Use the equals() method.
You are just creating a lot of extra unnecessary code by declaring an inner class for each button listener and then just calling back into a function that performs the action. You can simplify the whole thing by having a single listener, either as an inner class or by implementing ActionListener() directly withing the class, and handling the various functions by source like so
if (e.getSource()==button3){
// do button3 stuff
}
A better organization would be to have one listener class for the number buttons and one for the operator buttons, since the behavior for each of those groups of buttons only differs by the value of the button that was pressed.
Finally, use variable names that actually mean something. Button3 doesn't describe what it's for at all. "btnEquals" or "btnPerformEquals" would be a lot clearer and having meaningful variable names will help you keep better track of what your code is supposed to be doing.
It's a shame it wasn't 100% uncommitted. The whole Michigan and Florida Democratic primary situation is just plain stupid.
People who whine about smoking.
Take a look at the following re: equals() and hashcode()
http://www.ibm.com/developerworks/java/library/j-jtp05273.html
Correct, you want to set liste = new ArrayList(). Until you set the liste reference to point to a new ArrayList, you'll be operating on the same one as before.
You may want to update to 1.6.0_04 and see if that solves the JVM crash. I assume you are running the latest JACOB build.
You need ArrayList<Long>. Long is the wrapper class for the primitive long. Autoboxing will convert your long values to Long for you when you add them to the ArrayList.
can you make a program for it? pls....badly needed,, im still not familiar with java.. can you help me?
And obviously the whole point of the assignment is for you to get familiar with Java - so make an effort.
I'd say use prisoners in giant gerbil wheels then. We certainly have enough of those and it's not like they have better things to do. Let them walk on wheels all day generating electricity.
(Edit: Clarification: I refer to convicted criminal prisoners - not people taken prisoner for labor.)
Relatively speaking, no, your code is not "quite large". Post it here if you have questions about it. Forum rules dictate that requests for help should remain in the forums so all may participate.
Use the -cp parameter to put that directory in your classpath C:\Sun\SDK\jdk\bin\java -cp E:\Chap1 source
It's possible to lead a cow upstairs, but not downstairs.
I pity the person who verifies that one. No one wants a whole bunch of cows upstairs :(
- People who demand an absence of religion in politics, and then inject religion by try to ban the religious beliefs and practices of others.
All religion should be banned. It's the cause of most of our conflicts throughout the world. It's just ridiculous and pathetic.
You receive a tar baby.
I put in an empty beer bottle with a mouse in it.
You get an astronomical electric bill.
I put in four cats and a spider monkey, duct-taped together by their feet.
With x++, the value of x is evaluated before the increment. With ++x, it is evaluated after.
So
int x=0;
System.out.println(x++); // prints 0, x now = 1
System.out.println(++x); // prints 2, x now = 2
I believe he meant to type "if you do not live here...", but I think your point is still valid anyway.
Well, to raise that little bugger to the age of 17 will cost the parents about $193,344.67. Of course there are tax savings to consider too.
I wasn't referring to the cost, but rather the agent of delivery (as in you rang up the hospital to have one delivered to your home) :P
Actually, they'll believe anything printed shoved in front of their noses and never bother to conduct even the slightest bit of independent research.
I believe you.
...
"SuPeRcAlIfRaGiLiStIcExPiAlIdOcIoUs" works well for me as a password.
Not exactly what I want to have to type in the morning to unlock my workstation ;)
Nationally, a vaginal delivery cost $7,737, with C-sections averaging about $11,000.
Well, that first one will certainly be quite a shock when you answer the doorbell :-O
Hi scru .
You called this retarded data so ,i thinking that you want to pretend that you are not a human (maybe) and you do not have a worm filling in your head .More you resist more you will be less functional . You must complete nature request(maybe).
If you find out some discover please let me know.
Nothing you have posted in this thread makes the least bit of sense.
NASTY!
True though!
Same. Especially since he's not likely to be a crybaby in public... :icon_twisted:
That really set my wife off a bit. She gets a bit steamed over women getting leverage in a professional situation by crying.
Tapeworm.
Ouch :sweat:
The TextSamplerDemo from Sun has some example code on adding styled text to a JTextPane. It's a bit different than working with JTextField because the text pane utilizes a styled document. Since there is a lot of clutter from other text component code in that demo, I'll paste the two relevant methods here
private JTextPane createTextPane() {
String[] initString =
{ "This is an editable JTextPane, ", //regular
"another ", //italic
"styled ", //bold
"text ", //small
"component, ", //large
"which supports embedded components..." + newline,//regular
" " + newline, //button
"...and embedded icons..." + newline, //regular
" ", //icon
newline + "JTextPane is a subclass of JEditorPane that " +
"uses a StyledEditorKit and StyledDocument, and provides " +
"cover methods for interacting with those objects."
};
String[] initStyles =
{ "regular", "italic", "bold", "small", "large",
"regular", "button", "regular", "icon",
"regular"
};
JTextPane textPane = new JTextPane();
StyledDocument doc = textPane.getStyledDocument();
addStylesToDocument(doc);
try {
for (int i=0; i < initString.length; i++) {
doc.insertString(doc.getLength(), initString[i],
doc.getStyle(initStyles[i]));
}
} catch (BadLocationException ble) {
System.err.println("Couldn't insert initial text into text pane.");
}
return textPane;
}
protected void addStylesToDocument(StyledDocument doc) {
//Initialize some styles.
Style def = StyleContext.getDefaultStyleContext().
getStyle(StyleContext.DEFAULT_STYLE);
Style regular = doc.addStyle("regular", def);
StyleConstants.setFontFamily(def, "SansSerif");
Style s = doc.addStyle("italic", regular);
StyleConstants.setItalic(s, true);
s = doc.addStyle("bold", regular);
StyleConstants.setBold(s, true);
s = doc.addStyle("small", regular);
StyleConstants.setFontSize(s, 10);
s = doc.addStyle("large", regular);
StyleConstants.setFontSize(s, 16);
s = doc.addStyle("icon", regular);
StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
ImageIcon pigIcon = createImageIcon("images/Pig.gif",
"a cute pig");
if (pigIcon != null) { …
Read the API link. There are a few examples right there in the class description.
Religion in politics.
He's a face that will say anything he thinks will get him into the White House. Fish out of water flop around less.
You aren't doing any element comparisons at all. Think about what operation would be needed to see if any element in the array was equal to another element.
people who hate people who hate rap.
rap/hip-hop = anoying
country + rap = crap
So
annoying = (crap - country) / hip-hop
and
crap = country + (annoying * hip-hop)
and
(country + (annoying * hip-hop)) / crap = unity
... interesting.
People who hate rap just because CNN says so
But those who hate rap just because it sucks don't annoy you?
You do not have to use HTML markup to created styled text in JTextPane. In addition to the tutorial link I posted above, perhaps these examples will help:
http://www.exampledepot.com/egs/javax.swing.text/style_HiliteWords2.html
As far as the JLabel, you're right, you don't place it in a JTextPane - but then that wasn't really the nature of the suggestion. The intent was that you could use a JLabel in place of JTextField or JTextPane in your container and use HTML markup to control the style and formatting of the displayed text.
I'm not quite following you. You mentioned placing them in a JTextField, but here you mention placing them on a canvas. Which is the case? One involves styled-text within an editing component, whereas painting them on a canvas evokes an expectation of custom 2D graphics rendering. Also, the comment about JLabels not being safe is a bit unclear.
Which no one knows when it will end....
It can't end until those waging it decide to end it, as the definition of terrorism is subjective and malleable, rooted in ideology. Any violent act with which they disagree can be deemed "terrorism" and thus targeted. Violent actions which they find agreeable are given the nod of acceptable insurrection against evil tyranny and allowed to continue either explicitly through aid or implicitly by a lack of action.
Are you kidding? You want a working, documented program that you had nothing to do with to present as your own work for your resume??