Can we create GUI for standalone application using html and javascript?

前端 未结 3 1453
心在旅途
心在旅途 2020-12-06 21:42

I have a Java program which until now used to get the input from command line and then proceed accordingly.

Now, I want to have a basic GUI for this. It will need a

3条回答
  •  渐次进展
    2020-12-06 22:48

    I want to have a basic GUI for this. It will need a few buttons which will trigger the events.

    This 'basic GUI' goes slightly beyond the spec. to add an output area.

    Simple Event GUI

    enter image description here

    import java.awt.*;
    import javax.swing.*;
    
    class SimpleEventGUI {
    
        SimpleEventGUI() {
            JPanel gui = new JPanel(new BorderLayout());
            JToolBar toolBar = new JToolBar();
            for (int ii=1; ii<6; ii++) {
                toolBar.add(new JButton("Event " + ii));
                if (ii%2==0) {
                    toolBar.addSeparator();
                }
            }
            gui.add(toolBar, BorderLayout.NORTH);
            gui.add( new JScrollPane(new JTextArea(5,30)), BorderLayout.CENTER );
    
            JOptionPane.showMessageDialog(null, gui);
        }
    
        public static void main(String[] args) {
    
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    new SimpleEventGUI();
                }
            });
        }
    }
    

提交回复
热议问题