Merge pull request #12413 from opokharel/master
[BAEL-5421] by @opokharel
This commit is contained in:
commit
2823129540
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue