I have a class that reads the state of what string is in a JTextFeild (displayBox is the class in this case). The method sould read the state put it into an ArrayList (lastState in this case) and the be able to put it back into the JText feild when a method is called (returnState in this case)
displayBox is a object of class Jtextfeild d...
any way easier to do this??
i'm trying to import a file which is four lines:
name
phone
mobile
address
I'm using:
public void importContacts() {
try {
BufferedReader infoReader = new BufferedReader(new FileReader(
"../files/example.txt"));
int i = 0;
String loadContacts;
while ((...
Kushal Paudyal asked how deep you can nest inner classes in Java. The consensus is that while the language itself imposes no limit, the underlying OS and file system may.
Have you ever found a case where two or more levels of nested inner classes are helpful?
Update (11/28): If you consider enum classes, a second level of nesting can...
I am currently creating a java application in which I have a 2d array which I want to get some data into.
I am creating the 2d array as such
String[][] addressData;
and then when I am trying to put data in I am using reference the exact position in the 2d array I want to enter the data into e.g
addressData[0][0] = "String Data";
...
Hi. I'm researching ways to create a web radio station of sorts. It will have streaming MP3 audio from TV programs for users to listen to. They should have the option of just listening to the stream or pick the shows they'd like to hear and add them to their playlist.
It needs to be usable by folks on mobile devices, so Flash is out fo...
I am trying to run an automated suite every day at the same time, so I want to create a task to open eclipse and execute the main script every day. Is there a way to do this from the command line?
...
In Python, the defaultdict class provides a convenient way to create a mapping from key -> [list of values], in the following example,
from collections import defaultdict
d = defaultdict(list)
d[1].append(2)
d[1].append(3)
# d is now {1: [2, 3]}
Is there an equivalent to this in Java?
Why I chose Tendayi Mawushe's solution
This solu...
I'm trying to keep track of a set of files, which may have the same name and metadata. I'd like to use a hash to differentiate and use it as a unique ID, but I'm not sure which one to use? The files are relatively small (in the 100 kb range) and I'd like to be able to hash that in less than 10 seconds. Which hash (that comes built in ...
I have a JPA annotated class which contains a collection like so:
@Entity
public class Employee {
@Id
private int id;
@Basic
private String name;
@OneToMany
@JoinTable(name = "ORG", joinColumns = @JoinColumn(name="MINION"),
inverseJoinColumns = @JoinColumn(name="EMP"))
private List<Employee> minions = ...
In Struts2, how do you share your common html across all pages?
In Asp.net, you've got Master pages, and in Rails there are Layouts. The idea is that your common html (eg the header, menu, and styles) are all easy to maintain because they are in one place, but for the life of me i can't find the equivalent feature in Struts2.
Is it cal...
I am writing a class (Foo) which, when instantiated, can be called from multiple threads.
Most methods of the Foo class can safely be called by multiple threads in parallel. One method of this class (logout()), requires that all other threads are done.
Before logout is called, the reference to foo is deleted from a thread-safe collect...
I am attempting to download a jpg using HttpURLConnection and am encountering a very peculiar bug.
Here's the url:
http://www.vh1.com/sitewide/promoimages/shows/m/my%5Fantonio/video/supertrailer/seg%5F1/320x240.jpg
if you open it in a browser you will see the image.
However, when I use HttpURLConnection I don't get the image...
What I...
Hi I have created a Jtable and can get it to show on my frame yet not on the JPanel I have ontop of my JFrame. I can't seem to change
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.util.ArrayList;
import java.util.Comparator;
import javax.swing.*;
import javax.s...
I'm working in Hadoop, and I need to provide a comparator to sort objects as raw network order byte arrays. This is easy for me to do with integers -- I just compare each byte in order. I also need to do this for floats. I think, but I can't find a reference, that the IEEE 754 format for floats used by Java can be sorted by just comparin...
I would like to remove the scrollbar arrow buttons from a scrollbar in a JScrollPane. How would I do this?
...
I have a java object that implements Runnable. here is the code.
public class Obj implements Runnable {
boolean shouldRun;
private int stuff
public Obj() {
this.setshouldRun(true);
stuff = 0;
}
public synchronized void setshouldRun(boolean shouldRun) {
this.shouldRun = shouldRun;
}
public ...
I am trying to implement Prim's minimum spanning tree algorithm with JGraphT. How does it look?
One issue I ran into was JGraphT's handling of everything like it's directed. So sometimes it is necessary to make some awkward calls to reverse g.getEdgeSource(e) and g.getEdgeTarget(e) if they didn't happen to be right.
I tried to implemen...
I am attempting to use a Java AWT FileDialog, but I want to replace the default Java Dialog icon with something else. In short, the code looks something like this:
Frame frame = new Frame();
Image image = ImageIO.read(new URL("file:/path/to/myfile.jpg"));
FileDialog fileDialog = new FileDialog(frame, "Save As", FileDialog.SAVE);
fileD...
I'm trying to integrate sitemesh into my struts2 app, but i'm finding that it's not making any difference and isn't showing any errors (or anything sitemesh related at all) in the logs.
I've started by following all the documentation on the sitemesh site, had no luck, so now i'm trying to copy what's been done in the sitemesh-example do...
I have two objects:
public class ParentObject {
// some basic bean info
}
public class ChildObject extends ParentObject {
// more bean info
}
Each of these tables corresponds to a differnet table in a database. I am using Hibernate to query the ChildObject, which will in turn populate the parent objects values.
I have defined my m...