Java rasa Visual Basic (Contoh coding sederhana; source: Ms CoPilot)

Gw lagi main2 utak atik Program sama browsing2 terkait nih Gan

Gw baru tau ada Program Java rasa Visual Basic

Disebut Java GUI


Berikut contoh file dr Microsoft CoPilot

Gw saranin COMPILE di NetBeans ya Agan2 sekalian

                Apache NetBeans 

Gw coba compile di Eclipse gagal manih gitu


Cekidot Gan!!

note: 

Utk builder ke Aplikasi .exe aka .jar masih belum berhasil

Juga dengan NetBeans setelah fail dgn Eclipse maksud ana

NEXT post terkait masalah belum berhasil gw convert ini ya Agan2x!!




SimpleGUIv1.java

import javax.swing.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;


public class SimpleGUIv1 {

    public static void main(String[] args) {

        // Create a frame

        JFrame frame = new JFrame("Simple GUI");

        frame.setSize(300, 200);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


        // Create a panel

        JPanel panel = new JPanel();

        frame.add(panel);

        placeComponents(panel);


        // Set the frame's visibility

        frame.setVisible(true);

    }


    private static void placeComponents(JPanel panel) {

        panel.setLayout(null);


        // Create a button

        JButton button = new JButton("Click Me!");

        button.setBounds(100, 80, 100, 25);

        panel.add(button);


        // Add action listener to the button

        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                JOptionPane.showMessageDialog(panel, "Hello, World!");

            }

        });

    }

}

No comments: