Posted By:
Paul_Wooten
Posted On:
Monday, September 15, 2008 11:11 PM
I've written two classes, one that extends JPanel, and the other which contains only the main method. If I add these two classes to a project in Eclipse, and then run the project as a Java Application, the JPanel is displayed. When I invoke java from bash, it behaves exactly the same as in the Eclipse IDE. However, when I invoke java using my ant build file, It never displays the JPanel. // class containing the main method package myPkg; import javax.swing.JFrame; import javax.swing.JPanel; public class myApp { public static void main(String[] args) { JFrame frame = new JFrame("My Frame!"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); myPanel panel = new m
More>>
I've written two classes, one that extends JPanel, and the other which contains only the main method. If I add these two classes to a project in Eclipse, and then run the project as a Java Application, the JPanel is displayed. When I invoke java from bash, it behaves exactly the same as in the Eclipse IDE. However, when I invoke java using my ant build file, It never displays the JPanel.
// class containing the main method
package myPkg;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class myApp {
public static void main(String[] args) {
JFrame frame = new JFrame("My Frame!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myPanel panel = new myPanel();
frame.getContentPane().add(panel);
frame.pack();
frame.show();
System.out.println("!");
}
}
// class containing my JPanel
package myPkg;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JPanel;
public class myPanel extends JPanel {
public myPanel() {
setPreferredSize(new Dimension(400, 400));
setBackground(Color.white);
setVisible(true);
}
public void paintComponent(Graphics page)
{
super.paintComponent(page);
}
}
The target in my build file that executes java is:
Please keep in mind, I'm relatively new to ant, and I don't have much linux experience, although I'm fairly well versed in Java. My Ant Version is 1.7.0, and I'm developing in Ubuntu 8.04.1
Thank you
<<Less