I know that it is very simple question, but I can't find a solution.
I have a main swing dialog and other swing dialog. Main dialog has a button.
How can I make that after clicking a button the other dialog opens?
Hello
I wonder if you could automatically generate header header class functions automatically for a given package (make a batch processing) ..?
Thank you.
Hi Guys,
Is it possible to extract the node name using apache digester?
So, if the xml looks like
<furniture>
<sofa>
.....
</sofa>
<coffeeTable>
.....
</coffeeTable>
</furniture>
is it possible to extract the node name "sofa", "coffeeTable"?
I know it is possible using xpath but is it possible using digester?
Cheers
If I create a scheduled task by calling ScheduledExecutorService.schedule(), it never quits after execution, is it a JDK bug, or I just miss something?
note: doSomething() is empty method below.
public static void doSomething() {
}
public static void main(String[] args) {
ScheduledFuture scheduleFuture =
Executors.newSingleThreadScheduledExecutor().schedule(new Callable() {
public Void call() {
try {
doSomething();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}, 1, TimeUnit.SECONDS);
}
I have 4 tables -- store, catalog_galleries, catalog_images, and catalog_financials.
When I traverse the relationship from store --> catalog_galleries --> catalog_images in other words: store.getCatalogGallery().getCatalogImages() I get duplicate records. Does anyone know what could be the cause of this? Any suggestions on where to look?
The store table has a OneToOne relationship with catalog_galleries which in turn has a OneToMany relationship with catalog_images and an eager fetch type. The store table also has a OneToMany relationship with catalog_financials.
I have a control which is listened for both mouseDown and mouseDoubleClick events. However when mouseDoubleClick occure, I don't need mouseDown event to be handled. (Now both events fired when doubleClick happens)
How can I stop handling mouseDown event when mouseDoubleClick occured?
boolean r = false ; int s = 0 ;
while (r == false) ;
{
s = getInt() ;
if (!(s>=0 && s<=2)) System.out.println ("try again not a valid response") ;
else r = true ;
}
The text never displays itself even when a 3 or a 123 is entered and the loop never terminates. Whats wrong here?
I'm going to preface this question with this statement: I know that I can easily handle this problem by reading the amount of lines in a file and making an array that size. I am not allowed to do this. Anyway, here is my question. I need to double my array's size whenever my program encounters an ArrayIndexOutOfBoundsException and then copy all the previous read in information into the larger array. Here is my code
public static void main(String[] args) throws IOException {
Scanner inScan, fScan = null;
int [] A = new int[5];
inScan = new Scanner(System.in);
System.out.print("Please enter the file to read from: ");
while(true) {
try{
String fName = inScan.nextLine();
fScan = new Scanner(new File(fName));
break;
}
catch (FileNotFoundException ex)
{
System.out.println("Your file is invalid -- please re-enter");
}
}
String nextItem;
int nextInt = 0;
int i = 0;
while (fScan.hasNextLine())
{
try
{
nextItem = fScan.nextLine();
nextInt = Integer.parseInt(nextItem);
A[i] = nextInt;
i++;
}
catch (NumberFormatException e)
{
System.out.println("Found an invalid int -- ignored");
}
catch (ArrayIndexOutOfBoundsException e)
{
//double the size of array A until
//copy all previous read in information to the larger array
}
}
System.out.println("Here are your " + i + " items:");
for (int j = 0; j < i; j++)
{
System.out.println(A[j] + " ");
}
}
}
Hey.
I was coding here the other day, writing a couple of if statements with ints that are always either zero or one (~bools), and I asked myself:
Should I use if (int == 1) or if (int != 0) ?
Is there any difference at all?
Please, don't answer with stuff regarding the int may being more/less than 1/0, that's not what I want to know.
I have a LinkedList of Components, each of which I would like to add into two different JTabbedPanes. For some reason, Swing is only letting me put each component into one or the other. The code I'm using is the following:
/* The two tab panes */
JTabbedPane leftTabs = new JTabbedPane();
JTabbedPane rightTabs = new JTabbedPane();
for (int i=0; i<tabPanes.size(); i++) {
rightTabs.add(tabPanes.get(i));
leftTabs.add(tabPanes.get(i));
}
Whichever add call I put last is the one that works; if I add to leftTabs last, then rightTabs ends up empty, and vice-versa.
Any ideas on how to get this working? Thanks!
i need to implement a project with visual intimacy between persons,can anyone recommends an algorithm for person's intimacy in phone contact?
intimacy attenuate over time(the intimacy attenuates automatically if you havnt click/dial it for a long time).
Assume in my address book:
Person Intimacy(0-100%)
A 40%
B 80%
C 10%
A's intimacy needs raise after i call A ,like this
Person Intimacy(0-100%)
A 42%
B 80%
C 10%
nothing happens after follow 5 days, A,B,C's intimacy need decline,like this
Person Intimacy(0-100%)
A 37%
B 78%
C 8%
thanks for everyone's answer
I would like to parse this Gstring with groovy :
Format type : CodeClass, Name, Accession, Count.
def txt = """ <Lane_Attributes>
ID,1
FovCount,600
FovCounted,598
...
</Lane_Attributes> """
And get a map like :
Map = [ID:1, FovCount:600, FovCounted:598]
How can I :
- extract text between tag and ?,
- and convert to a map ?
if i have a following code
try{
//some code
}catch(Exception e){
//some code
}finally{
}
what happens to the finally block in the following cases
if any checked exceptions happen.
if System.exit() is called.
if any unchecked exceptions happen.
if any errors happen.
I don't know why this condition is never satisfied:
I'm comparing two ArrayList values, and it is always false.
if ( (Integer) results.get(rank) == (Integer) experts.get(j))
I'm debugging and I have exactly the same 2 values: 3043 and 3043
However it doesn't work.
thanks
Public Class A
{
public A()
{
system.out.println("con call");
}
static
{
system.out.println("static call");
}
{
system.out.println("ins call");
}
Public static void main(string[] args)
{
new A();
new A();
}
Can any one please share their experience on
"When do we make a call to use between Synchronised statement and Synchronised Block"
Any Performance Issues?