-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaptureScreenshots.java
More file actions
66 lines (54 loc) · 2.2 KB
/
Copy pathCaptureScreenshots.java
File metadata and controls
66 lines (54 loc) · 2.2 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.io.File;
/**
* Utility to capture screenshots of the GUI screens for README documentation.
* Run this AFTER compiling all source files.
* Usage: java CaptureScreenshots
*/
public class CaptureScreenshots {
public static void main(String[] args) throws Exception {
File screenshotsDir = new File("screenshots");
screenshotsDir.mkdirs();
SwingUtilities.invokeAndWait(() -> {
try {
FileHandler.initializeDirectories();
// --- Login Screen ---
captureScreen("Login", screenshotsDir);
System.out.println("[OK] Captured Login screen");
} catch (Exception e) {
e.printStackTrace();
}
});
System.out.println("\nScreenshots saved to: screenshots/");
System.out.println("Upload these to your GitHub repo under screenshots/ folder.");
System.exit(0);
}
private static void captureScreen(String screenName, File outDir) throws Exception {
JFrame frame = new JFrame("SecurePass Manager - " + screenName);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(900, 600);
frame.setLocationRelativeTo(null);
CardLayout cardLayout = new CardLayout();
JPanel mainPanel = new JPanel(cardLayout);
SecurePassManager dummyApp = new SecurePassManager() {
{ /* prevent full init */ }
};
if (screenName.equals("Login")) {
mainPanel.add(new LoginScreen(dummyApp).getPanel(), "Login");
} else if (screenName.equals("Signup")) {
mainPanel.add(new SignupScreen(dummyApp).getPanel(), "Signup");
}
frame.add(mainPanel);
frame.setVisible(true);
Thread.sleep(500); // let it render
BufferedImage img = new BufferedImage(
frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_RGB);
frame.paint(img.getGraphics());
File out = new File(outDir, screenName.toLowerCase() + "_screen.png");
ImageIO.write(img, "png", out);
frame.dispose();
}
}