aboutsummaryrefslogtreecommitdiff
path: root/sem5/oop/m5/opg1/src/Main.java
blob: 97f992d0dec24bea8bd0fcb913dc34d6e33f6605 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import java.nio.file.Files;
import java.nio.file.Path;
import java.io.IOException;

class PaneThing {
	JFrame f;
	public PaneThing(String fname) throws IOException {
		String content = Files.readString(Path.of(fname));
		
		
		f = new JFrame();
		JOptionPane.showMessageDialog(f, content);
	}
}

public class Main {

	public static void main(String[] args) {
		
		String fname = "hej.txt";
		if (args.length > 0) {
			fname = args[0];
		}
		
		try {
			PaneThing pt = new PaneThing(fname);
		} catch (Exception e) {
			System.err.printf("error: %s%n", e);
			System.exit(1);
		}
	}

}