jdialog in non gui program

M

Mark

I've written a program that converts list of products from our suppliers at work into a format some of our other programs understand. The program is completely non-graphical aside from when a product category is encountered that we don't have a matching code for, in which case I display a JDialog with a JTextField for someone to enter in a code.

At the moment the whole process is run from EventQueue.invokeLater in main which works ok on my computer when it's run from within NetBeans and from the command prompt. If I run the program from the server (running XPSP2 and jre 6 update 11) then when it comes to displaying the JDialog, only the outside frame is drawn - where the controls should be I see the window behind.

I removed EventQueue.invokeLater from main and switched to calling JDialog.setVisible inside invokeLater which had no effect.

The import code is completely procedural - there are no listeners (apart from for a button click in the dialog class), and the dialog should and does block until a code is entered.

Is there a way I should write the program so the dialog displays properly? Or is there a reason it would work ok on my computer and not others?

Thanks
 
M

Mark

Andrew said:
Could you expand on that part about the 'server'?
Is this a web app.?

No, desktop (although the only gui part is the dialog).
Probably, but without seeing an SSCCE*, it is
difficult to determine what exactly is going
wrong.

I'll try and keep it short. The relevant part is in findOptionA.

In Main.java:

public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {

try {
Importer importer = new Importer((String)Config.getInstance().getProperty("wincatal.import_path"));
importer.process();
} catch (Exception e) {
e.printStackTrace();
}

}
});
}

In Importer.java:

public void process() throws ConfigurationException {
File importPath = new File(directory);
Import curImport = null;

try {
curImport = new AnywareImport();
curImport.setExporter(new Exporter(exportPath));
curImport.processFile(file);
} catch (Exception e) {
e.printStackTrace();
}
}

In AnywareImport.java:

public void processFile(File file) throws FileNotFoundException, IOException {
...
processFile(line);
...
}

public void processLine(String[] line) throws IOException {
Product product = findProduct(line[0].trim());
OptionA oa = findOptionA(line[5].trim());
...
}

In Import.java:

protected OptionA findOptionA(String desc) {
if (desc != null && !desc.isEmpty()) {
Query q = Importer.getEntityManager().createQuery("SELECT o FROM OptionA o " +
"where o.supplier.code = :supplier and o.description = :description");
q.setParameter("supplier", supplier.getCode());
q.setParameter("description", desc.trim());

if (q.getResultList().size() == 1) {

OptionA oa = (OptionA)q.getSingleResult();
oa.setSent(Short.valueOf("1"));

persist(oa);

return oa;

} else {

OptionDialog od = new OptionDialog(null, true, desc);
od.setVisible(true); <--- this is where it stops working

OptionA oa = new OptionA();
oa.setCode(od.code);
oa.setDescription(desc);
oa.setSupplier(supplier);
oa.setSent(Short.valueOf("1"));

persist(oa);

return oa;

}
}

return null;
}

I hope that's enough and makes sense.

Thanks
 
J

jlp

Mark a écrit :
Andrew said:
Could you expand on that part about the 'server'?
Is this a web app.?

No, desktop (although the only gui part is the dialog).
Probably, but without seeing an SSCCE*, it is
difficult to determine what exactly is going
wrong.

I'll try and keep it short. The relevant part is in findOptionA.

In Main.java:

public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {

try {
Importer importer = new Importer((String)Config.getInstance().getProperty("wincatal.import_path"));
importer.process();
} catch (Exception e) {
e.printStackTrace();
}

}
});
}

In Importer.java:

public void process() throws ConfigurationException {
File importPath = new File(directory);
Import curImport = null;

try {
curImport = new AnywareImport();
curImport.setExporter(new Exporter(exportPath));
curImport.processFile(file);
} catch (Exception e) {
e.printStackTrace();
}
}

In AnywareImport.java:

public void processFile(File file) throws FileNotFoundException, IOException {
...
processFile(line);
...
}

public void processLine(String[] line) throws IOException {
Product product = findProduct(line[0].trim());
OptionA oa = findOptionA(line[5].trim());
...
}

In Import.java:

protected OptionA findOptionA(String desc) {
if (desc != null && !desc.isEmpty()) {
Query q = Importer.getEntityManager().createQuery("SELECT o FROM OptionA o " +
"where o.supplier.code = :supplier and o.description = :description");
q.setParameter("supplier", supplier.getCode());
q.setParameter("description", desc.trim());

if (q.getResultList().size() == 1) {

OptionA oa = (OptionA)q.getSingleResult();
oa.setSent(Short.valueOf("1"));

persist(oa);

return oa;

} else {

OptionDialog od = new OptionDialog(null, true, desc);
od.setVisible(true); <--- this is where it stops working

OptionA oa = new OptionA();
oa.setCode(od.code);
oa.setDescription(desc);
oa.setSupplier(supplier);
oa.setSent(Short.valueOf("1"));

persist(oa);

return oa;

}
}

return null;
}

I hope that's enough and makes sense.

Thanks
Try to add : -Dsun.java2d.d3d=false
in the commnad line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top