BAEL-5421

This commit is contained in:
opokharel 2022-06-25 12:36:55 -06:00
parent db1bf15694
commit 8991dbe2df
2 changed files with 16 additions and 12 deletions

View File

@ -7,20 +7,24 @@ import javax.swing.*;
public class MySampleGUIAppn extends JFrame{ public class MySampleGUIAppn extends JFrame{
public MySampleGUIAppn() { public MySampleGUIAppn() {
if (!GraphicsEnvironment.isHeadless()) {
setSize(300,300); setSize(300,300);
setTitle("MySampleGUIAppn"); setTitle("MySampleGUIAppn");
Button b = new Button("Click Me!"); Button b = new Button("Click Me!");
b.setBounds(30,100,80,30); b.setBounds(30,100,80,30);
add(b); add(b);
if (!GraphicsEnvironment.isHeadless()) {
setVisible(true); setVisible(true);
}
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
dispose(); dispose();
System.exit(0); System.exit(0);
} }
}); });
}
else {
System.exit(0);
}
} }
public static void main(String[] args) { public static void main(String[] args) {
MySampleGUIAppn app=new MySampleGUIAppn(); MySampleGUIAppn app=new MySampleGUIAppn();

View File

@ -8,7 +8,7 @@ class MySampleGUIAppnUnitTest {
@Test @Test
void testMain() throws IOException { void testMain() throws IOException {
System.setProperty("java.awt.headless", "true"); System.setProperty("java.awt.headless", "false");
MySampleGUIAppn instance = new MySampleGUIAppn(); MySampleGUIAppn instance = new MySampleGUIAppn();
String [] args = null; String [] args = null;
System.exit(0); System.exit(0);