Merge pull request #12413 from opokharel/master

[BAEL-5421] by @opokharel
This commit is contained in:
davidmartinezbarua 2022-07-08 15:03:49 -03:00 committed by GitHub
commit 2823129540
2 changed files with 46 additions and 0 deletions

View File

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

View File

@ -0,0 +1,15 @@
package com.baeldung.jar;
import java.io.IOException;
import org.junit.jupiter.api.Test;
class MySampleGUIAppnUnitTest {
@Test
void testMain() throws IOException {
System.setProperty("java.awt.headless", "true");
String [] args = null;
System.exit(0);
MySampleGUIAppn.main(args);
}
}