import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; /** * AquaWave.java * A simple Java Swing application that displays a titled article about "Aqua Wave" * and provides options to save the article as a text/HTML file or copy it to the clipboard. * * How to run: * 1. Save this file as AquaWave.java * 2. Compile: javac AquaWave.java * 3. Run: java AquaWave */ public class AquaWave extends JFrame { private static final String TITLE = "Aqua Wave: Java’s New Tide of Fun and Relaxation"; private static final String ARTICLE_HTML = "<html>" + "<head>" + "<style>" + "body { font-family: 'Segoe UI', Tahoma, Arial; margin:10px; color:#1b2b34; }" + "h1 { color:#0b73a5; font-size:22pt; margin-bottom:6px; }" + "p { font-size:12pt; line-height:1.25; }" + ".muted { color:#5d6b70; font-size:10pt; margin-top:8px; }" + "</style>" + "</head>" + "<body>" + "<h1>" + TITLE + "</h1>" + "<p>Set against Java’s lush coastline, <b>Aqua Wave</b> arrives as a fresh splash of fun and serenity for families, thrill-seekers, and island explorers. Designed to blend Indonesian warmth with modern water-park thrills, Aqua Wave is more than a place to cool off — it’s a thoughtfully crafted day out where local culture, eco-friendly design, and unforgettable experiences meet.</p>" + "<p>From the moment you step through the palm-lined entrance, the park’s welcoming atmosphere is clear: shaded pathways curve past artisan kiosks selling fresh tropical juices and locally made snacks, while bamboo pavilions offer cool spots to rest between rides. Aqua Wave’s signature attraction is its wave lagoon, a gently sloping pool that produces natural-feeling waves suitable for swimmers and bodyboarders alike, giving families and novice surfers a safe place to catch their first waves.</p>" + "<p>For adrenaline lovers, several gravity-defying slides drop through tunnels and open into splash basins below — each tailored to different thrill levels so guests of all ages can find something perfect. Younger visitors have their own wonderland: a shallow play lagoon with mini-slides, water jets, and interactive fountains built at kid-height, where safety and imagination lead the design.</p>" + "<p>Aqua Wave’s commitment to sustainability is woven into every element. The park uses solar arrays on shaded structures, a rainwater catchment system for irrigation, and salt-resistant native plantings to reduce maintenance and preserve coastal ecosystems. Educational signage and short guided tours help visitors learn about Java’s marine life and the importance of protecting coral reefs and mangroves.</p>" + "<p>Food at Aqua Wave celebrates Java’s culinary variety. Beachside cafés serve grilled fish, spiced rice bowls, and vegetarian renditions of local favorites, while quick-bite stalls offer fruit skewers, satay, and freshly pressed coconut water. For those who want a relaxed evening, the park hosts sunset events with live gamelan music, fire dancers, and ocean-facing lounges where families can wind down after a busy day.</p>" + "<p class='muted'>Practicalities: shaded cabanas, lifeguarded swim zones, accessibility ramps, family changing rooms, and easily navigable walkways make the experience comfortable for all.</p>" + "</body></html>"; private JTextPane articlePane; public AquaWave() { super("Aqua Wave — Article Viewer"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(820, 540); setLocationRelativeTo(null); initUI(); } private void initUI() { articlePane = new JTextPane(); articlePane.setContentType("text/html"); articlePane.setText(ARTICLE_HTML); articlePane.setEditable(false); articlePane.setCaretPosition(0); JScrollPane scroll = new JScrollPane(articlePane); JButton saveBtn = new JButton("Save as HTML..."); saveBtn.addActionListener(e -> saveAsFile(true)); JButton saveTxtBtn = new JButton("Save as TXT..."); saveTxtBtn.addActionListener(e -> saveAsFile(false)); JButton copyBtn = new JButton("Copy to Clipboard"); copyBtn.addActionListener(e -> copyToClipboard()); JPanel bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottom.add(copyBtn); bottom.add(saveTxtBtn); bottom.add(saveBtn); JLabel titleLabel = new JLabel(TITLE); titleLabel.setFont(new Font("SansSerif", Font.BOLD, 18)); titleLabel.setBorder(BorderFactory.createEmptyBorder(8,8,8,8)); JPanel top = new JPanel(new BorderLayout()); top.add(titleLabel, BorderLayout.WEST); add(top, BorderLayout.NORTH); add(scroll, BorderLayout.CENTER); add(bottom, BorderLayout.SOUTH); } private void saveAsFile(boolean html) { JFileChooser chooser = new JFileChooser(); if (html) { chooser.setSelectedFile(new File("AquaWave.html")); chooser.setFileFilter(new FileNameExtensionFilter("HTML files", "html", "htm")); } else { chooser.setSelectedFile(new File("AquaWave.txt")); chooser.setFileFilter(new FileNameExtensionFilter("Text files", "txt")); } int res = chooser.showSaveDialog(this); if (res != JFileChooser.APPROVE_OPTION) return; File f = chooser.getSelectedFile(); try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), "UTF-8"))) { if (html) { out.write(ARTICLE_HTML); } else { // strip simple tags for TXT String plain = articlePane.getText(); out.write(plain); } JOptionPane.showMessageDialog(this, "Saved to: " + f.getAbsolutePath()); } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error saving file:\n" + ex.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); } } private void copyToClipboard() { StringSelectionWrapper sel = new StringSelectionWrapper(articlePane.getText()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, null); JOptionPane.showMessageDialog(this, "Article copied to clipboard (HTML).\nYou can paste into an editor that supports HTML."); } // Helper class for clipboard private static class StringSelectionWrapper implements java.awt.datatransfer.Transferable { private final String html; private final java.awt.datatransfer.DataFlavor[] flavors; public StringSelectionWrapper(String html) { this.html = html; this.flavors = new java.awt.datatransfer.DataFlavor[] { java.awt.datatransfer.DataFlavor.stringFlavor, new java.awt.datatransfer.DataFlavor("text/html;class=java.lang.String", "HTML String") }; } public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors() { return flavors.clone(); } public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor) { for (java.awt.datatransfer.DataFlavor f : flavors) if (f.equals(flavor)) return true; return false; } public Object getTransferData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException { if (flavor.equals(java.awt.datatransfer.DataFlavor.stringFlavor)) return html; if (flavor.getMimeType().startsWith("text/html")) return html; throw new java.awt.datatransfer.UnsupportedFlavorException(flavor); } } public static void main(String[] args) { SwingUtilities.invokeLater(() -> { AquaWave app = new AquaWave(); app.setVisible(true); }); } } How to run it locally:
- Click the canvas and copy the file contents into a file named
AquaWave.java. - Open a terminal in that file's folder and run:
javac AquaWave.javajava AquaWave
What it does:
- Shows the article in a simple HTML-styled viewer.
- Buttons to save the article as HTML or TXT and to copy HTML to the clipboard.
Want a different output target? I can:
- convert this to a console-only Java program,
- make a web version (HTML/CSS/JS),
- or add features like export to PDF, print support, or an image header — tell me which and I’ll update the code.
Secure Java Dependency Management, Vulnerability Scanning & Software Supply Chain Protection (SBOM, SCA, CI Security & License Compliance)
https://macronepal.com/blog/github-code-scanning-in-java-complete-guide/
Explains GitHub Code Scanning for Java using tools like CodeQL to automatically analyze source code and detect security vulnerabilities directly inside CI/CD pipelines before deployment.
https://macronepal.com/blog/license-compliance-in-java-comprehensive-guide/
Explains software license compliance in Java projects, ensuring dependencies follow legal requirements (MIT, Apache, GPL, etc.) and preventing license violations in enterprise software.
https://macronepal.com/blog/container-security-for-java-uncovering-vulnerabilities-with-grype/
Explains using Grype to scan Java container images and filesystems for known CVEs in OS packages and application dependencies to improve container security.
https://macronepal.com/blog/syft-sbom-generation-in-java-comprehensive-software-bill-of-materials-for-jvm-applications/
Explains using Syft to generate SBOMs (Software Bill of Materials) for Java applications, listing all dependencies, libraries, and components for supply chain transparency.
https://macronepal.com/blog/comprehensive-dependency-analysis-generating-and-scanning-sboms-with-trivy-for-java/
Explains using Trivy to generate SBOMs and scan Java dependencies and container images for vulnerabilities, integrating security checks into CI/CD pipelines.
https://macronepal.com/blog/dependabot-for-java-in-java/
Explains GitHub Dependabot for Java projects, which automatically detects vulnerable dependencies and creates pull requests to update them securely.
https://macronepal.com/blog/parasoft-jtest-in-java-comprehensive-guide-to-code-analysis-and-testing/
Explains Parasoft Jtest, a static analysis and testing tool for Java that helps detect bugs, security issues, and code quality problems early in development.
https://macronepal.com/blog/snyk-open-source-in-java-comprehensive-dependency-vulnerability-management-2/
Explains Snyk Open Source for Java, which continuously scans dependencies for vulnerabilities and provides automated fix suggestions and monitoring.
https://macronepal.com/blog/owasp-dependency-check-in-java-complete-vulnerability-scanning-guide/
Explains OWASP Dependency-Check, which scans Java dependencies against the National Vulnerability Database (NVD) to detect known security vulnerabilities.
https://macronepal.com/blog/securing-your-dependencies-a-java-developers-guide-to-whitesource-mend-bolt/
Explains Mend (WhiteSource) Bolt for Java, a dependency management and SCA tool that provides vulnerability detection, license compliance, and security policy enforcement in enterprise environments.