Java Code Examples for com.codename1.ui.Button#addActionListener()

The following examples show how to use com.codename1.ui.Button#addActionListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PasswordManagerTestCase2741.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form f = new Form("Form 1", BoxLayout.y());
    TextField tf1 = new TextField();
    tf1.setConstraint(TextField.PASSWORD);
    f.add(tf1);
    Button b = new Button("Login");
    b.addActionListener(e->{
        Form f2 = new Form("F2", BoxLayout.y());
        TextField t2 = new TextField();
        ComboBox cb = new ComboBox("Red", "Green", "Blue");
        f2.addAll(t2, cb);
        Button b2 = new Button("Submit");
        f2.add(b2);
        f2.show();
        
    });
    f.add(b);
    f.show();
}
 
Example 2
Source File: LeadComponentScrollingTest3079.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    
    int len = 100;
    for (int i=0; i<len; i++) {
        Container cnt = new Container(new FlowLayout());
        $(cnt).selectAllStyles().setBgTransparency(0xff).setBgColor(0xffffff);
        SwipeableContainer sc = new SwipeableContainer(BoxLayout.encloseX(new Button("This is a button")),BoxLayout.encloseX(new Button("This is another button")), cnt);
        Button b = new Button("Button "+i);
        b.addActionListener(evt->{
            System.out.println("button pressed");
        });
        cnt.add(b);
        cnt.setLeadComponent(b);
        hi.add(sc);
    }
    hi.setScrollableY(true);
    
    hi.add(new Label("Hi World"));
    hi.show();
}
 
Example 3
Source File: PhotoShare.java    From codenameone-demos with GNU General Public License v2.0 6 votes vote down vote up
Container createToolbar(long imageId) {
    Container toolbar = new Container(new GridLayout(1, 4));
    toolbar.setUIID("Toolbar");
    // notice that the characters in the name of the buttons map to icons in the icon font!
    Button likeButton = new Button("d");
    Button flagButton = new Button("c");
    Button detailsButton = new Button("a");
    final ShareButton shareButton = new ShareButton();
    shareButton.setIcon(null);
    shareButton.setText("b");

    bindShareButtonSelectionListener(shareButton);

    likeButton.setUIID("ToolbarLabel");
    flagButton.setUIID("ToolbarLabel");
    detailsButton.setUIID("ToolbarLabel");
    shareButton.setUIID("ToolbarLabel");
    toolbar.addComponent(likeButton);
    toolbar.addComponent(shareButton);
    toolbar.addComponent(detailsButton);
    toolbar.addComponent(flagButton);

    likeButton.addActionListener(createLikeAction(imageId));
    detailsButton.addActionListener(createDetailsButtonActionListener(imageId));
    return toolbar;
}
 
Example 4
Source File: WKWebViewTest.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    hi = new Form("Hi World", BoxLayout.y());

    Button a = new Button("Show old webview");
    a.addActionListener((e) -> {
    	Display.getInstance().setProperty("BrowserComponent.useWKWebView", "false");
    	showWebView();
    });
    
    
    Button b = new Button("Show WKwebview");
    b.addActionListener((e) -> {
    	Display.getInstance().setProperty("BrowserComponent.useWKWebView", "true");
    	showWebView();
    });
    
    hi.add(a).add(b);
    
    hi.show();
}
 
Example 5
Source File: ScaleImageLabelTest.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    ScaleImageLabel label = new ScaleImageLabel();
    
    hi.add(new Label("Hi World"));
    Button btn = new Button("Update Label");
    btn.addActionListener(evt->{
        pressCount++;
        String message = "Pressed " + pressCount + " times";
        try {
            loadTextImage(label, label.getIcon(), message, label.getWidth(), label.getHeight());
        } catch (Exception ex) {
            Log.e(ex);
        }
    });
    hi.add(FlowLayout.encloseIn(label)).add(btn);
        
    hi.show();
}
 
Example 6
Source File: ClearableTextField.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Wraps the given text field with a UI that will allow us to clear it
 * @param tf the text field
 * @param iconSize size in millimeters for the clear icon, -1 for default size
 * @return a Container that should be added to the UI instead of the actual text field
 */
public static ClearableTextField wrap(final TextArea tf, float iconSize) {
    ClearableTextField cf = new ClearableTextField();
    Button b = new Button("", tf.getUIID());
    if(iconSize > 0) {
        FontImage.setMaterialIcon(b, FontImage.MATERIAL_CLEAR, iconSize);
    } else {
        FontImage.setMaterialIcon(b, FontImage.MATERIAL_CLEAR);
    }
    removeCmpBackground(tf);
    removeCmpBackground(b);
    cf.setUIID(tf.getUIID());
    cf.add(BorderLayout.CENTER, tf);
    cf.add(BorderLayout.EAST, b);
    b.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            tf.stopEditing();
            tf.setText("");
            tf.startEditingAsync();
        }
    });
    return cf;        
}
 
Example 7
Source File: SocketSample.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Socket Sample", BoxLayout.y());
    Button server = new Button("Server Sockets");
    Button client = new Button("Client Socket");
    server.addActionListener(evt->{
        new ServerForm().show();
    });
    
    client.addActionListener(evt->{
        new ClientForm().show();
    });
    
    hi.add(new Label("Select mode")).add(server).add(client);
    hi.show();
}
 
Example 8
Source File: CameraKitPickerTest7.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void showAnotherForm(){
    Form form = new Form(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_SCALE));
    form.setScrollable(false);
    Container container = new Container(BoxLayout.y());
    container.add(new Label("Test", "heading5"));
    container.add(new Label("", "newLine"));
    container.add(new Label("", "newLine"));

    final Picker fromDate = new Picker();
    fromDate.setType(Display.PICKER_TYPE_DATE);
    container.add(new Label("From Date", "heading7"));
    container.add(fromDate);
    container.add(new Label("", "newLine"));

    final Picker toDate = new Picker();
    toDate.setType(Display.PICKER_TYPE_DATE);
    container.add(new Label("To Date", "heading7"));
    container.add(toDate);

    Button nextBtn = new Button("Proceed");
    nextBtn.setUIID("loginBtn");
    nextBtn.addActionListener((ev) -> {
        DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
        String fromDateStr = dateFormat.format(fromDate.getDate());
        String toDateStr = dateFormat.format(toDate.getDate());
        
    });
    container.add(new Label("", "newLine"));
    container.add(new Label("", "newLine"));
    container.add(nextBtn);
    form.add(BorderLayout.CENTER, container);
    
    form.show();
}
 
Example 9
Source File: FullScreenWithBrowserComponentSample.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
BrowserForm() {
    super(new BorderLayout());
    add(BorderLayout.CENTER, bc);
    Button b = new Button("Toggle Fullscreen");
    b.addActionListener(e->{
        if (Display.getInstance().isInFullScreenMode()) {
            Display.getInstance().exitFullScreen();
        } else {
            Display.getInstance().requestFullScreen();
        }
    });
    add(BorderLayout.SOUTH, b);
}
 
Example 10
Source File: JavascriptScrollingTest.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
protected void buildTitle() {
	// fix the title so we can add the date chooser to it
	Button btnTest = new Button("Click Me");
	btnTest.addActionListener(l->onTest());
	Label lblTitle = new Label("Speach");
	lblTitle.getAllStyles().setAlignment(CENTER);

	Container cntTitle = new Container(new BorderLayout());
	cntTitle.add(BorderLayout.WEST, btnTest);
	cntTitle.add(BorderLayout.CENTER, lblTitle);

	getToolbar().setTitleCentered(false);
	getToolbar().setTitleComponent(cntTitle);
}
 
Example 11
Source File: LoadingTextAnimationSample.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    Button b = new Button("Show Details");
    b.addActionListener(e->{
        showForm();
    });
    hi.add(b);
    hi.show();
}
 
Example 12
Source File: VerticalAlignTTFFontTest2798.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start() {
    if (current != null) {
        current.show();
        return;
    }
    
    
    Form hi = new Form();
    
    hi.setToolbar(new Toolbar());
    
    hi.setTitle("Test Fonts");
    
    List<FontWrapper> fonts = new ArrayList<>();
    
    int fontSize = Display.getInstance().convertToPixels(3);
    fonts.add(new FontWrapper("Suisse Intl", Font.createTrueTypeFont("Suisse Int'l", "Suisse Int'l.ttf").derive(fontSize, Font.STYLE_PLAIN)));
    fonts.add(new FontWrapper("OpenSans-Regular", Font.createTrueTypeFont("OpenSans-Regular", "OpenSans-Regular.ttf").derive(fontSize, Font.STYLE_PLAIN)));
    fonts.add(new FontWrapper("OpenSans-Light", Font.createTrueTypeFont("OpenSans-Light", "OpenSans-Light.ttf").derive(fontSize, Font.STYLE_PLAIN)));
    fonts.add(new FontWrapper("OpenSans-Semibold", Font.createTrueTypeFont("OpenSans-Semibold", "OpenSans-Semibold.ttf").derive(fontSize, Font.STYLE_PLAIN)));
    fonts.add(new FontWrapper("ArialBD", Font.createTrueTypeFont("arialbd", "arialbd.ttf").derive(fontSize, Font.STYLE_PLAIN)));
    fonts.add(new FontWrapper("System Font Medium", Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM)));
    fonts.add(new FontWrapper("System Font Large", Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE)));
    fonts.add(new FontWrapper("native:MainRegular", Font.createTrueTypeFont(Font.NATIVE_MAIN_REGULAR, Font.NATIVE_MAIN_REGULAR).derive(fontSize, Font.STYLE_PLAIN)));
    for (FontWrapper font : fonts) {
        Button b = new Button(font.name);
        b.addActionListener(e->{
            new ShaiForm(font.name, font.font).show();
        });
        hi.add(b);
    }
    
    hi.show();
}
 
Example 13
Source File: TestNativePlayerMode2972.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form f = new Form("NativePlayerMode Test");
    f.setLayout(BoxLayout.y());
    
    Button playButton = new Button("Play Video");
    playButton.addActionListener(e->{
        String videoPath;
        if (isSimulator()) {
            videoPath = "http://www.codenameone.com/files/hello-codenameone.mp4";
        } else {
            videoPath = "https://www.codenameone.com/files/hello-codenameone.mp4";
        }
        try {
            Media video = MediaManager.createMedia(videoPath, true);
            video.setNativePlayerMode(true); // this works nicely on iOS 12, I didn't test other iOS versions yet
            video.prepare();
            video.setFullScreen(true);
            video.play();
        } catch (Exception ex) {
            Log.e(ex);
        }
    });
    f.add(playButton);
    f.show();
    
    
}
 
Example 14
Source File: Contacts.java    From codenameone-demos with GNU General Public License v2.0 5 votes vote down vote up
public Container createDemo() {
    final Container contactsDemo = new Container(new BorderLayout());
    final Image defaultIcon = getResources().getImage("stock_new-meeting.png");
    
    ContactsModel m = new ContactsModel(Display.getInstance().getAllContacts(true));
    m.setPlaceHolderImage(defaultIcon);
    final List contactsList = new List(m);
    GridLayout grd = new GridLayout(3, 3);
    grd.setAutoFit(true);
    final ContainerList grid = new ContainerList(m);
    grid.setLayout(grd);
    contactsDemo.addComponent(BorderLayout.CENTER, contactsList);
    
    contactsList.setRenderer(createListRenderer());
    grid.setRenderer(createGridRenderer());
    
    final Button asGrid = new Button("As Grid");
    asGrid.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            if(contactsList.getParent() != null) {
                contactsDemo.replace(contactsList, grid, CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, true, 300));
                asGrid.setText("As List");
            } else {
                contactsDemo.replace(grid, contactsList, CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 300));
                asGrid.setText("As Grid");
            }
        }
    });
    
    ComponentGroup gp = new ComponentGroup();
    gp.addComponent(asGrid);
    contactsDemo.addComponent(BorderLayout.SOUTH, gp);
    return contactsDemo;
}
 
Example 15
Source File: CircleProgressSample.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    Button b = new Button("Show Details");
    b.addActionListener(e->{
        showForm();
    });
    hi.add(b);
    hi.show();
}
 
Example 16
Source File: DeviceCalendarSample.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Calendar", BoxLayout.y());
    DeviceCalendar dc = DeviceCalendar.getInstance();
    if(dc == null) {
        hi.add("Device Calendar is null");
        hi.show();
        return;
    }
    if(!dc.hasPermissions()) {
        hi.add("No Calendar Access Permission");
        hi.show();
        return;
    }
    Collection<String> cals = dc.getCalendars();
    if(cals == null || cals.isEmpty()) {
        hi.add("No Calendars found on the device");
        hi.show();
        return;
    }
    
    int week = 7 * 24 * 60 * 60000;
    Date lastWeek = new Date(System.currentTimeMillis() - week);
    Date nextWeek = new Date(System.currentTimeMillis() - week);
    
    for(String s : cals) {
        Button b = new Button(s);
        b.addActionListener(e -> {
            String calId = dc.openCalendar(s, false);
            Collection<EventInfo> events = dc.getEvents(calId, lastWeek, nextWeek);
            Form f = new Form("Events", BoxLayout.y());
            for(EventInfo ei : events) {
                f.add(new Label(
                    L10NManager.getInstance().formatDateTimeShort(ei.getStartTime()) + 
                        ei.getTitle()));
            }
            f.getToolbar().setBackCommand("", ee -> hi.showBack());
            f.show();
        });
        hi.add(b);
    }
    hi.show();
}
 
Example 17
Source File: SignatureComponent.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new signature component.
 */
public SignatureComponent() {
    setLayout(new BorderLayout());
    xFont = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);
    lead = new Button() {

        @Override
        protected void paintBackground(Graphics g) {
            super.paintBackground(g);
            g.setColor(0x666666);
            Style s = getStyle();
            g.drawRect(
                    getX()+s.getPaddingLeftNoRTL(), 
                    getY()+s.getPaddingTop(),
                    getWidth()-s.getPaddingRightNoRTL()-s.getPaddingLeftNoRTL(),
                    getHeight()-s.getPaddingBottom() - s.getPaddingTop()
            );
            
            g.setFont(xFont);
            g.drawString("X", getX() + getStyle().getPaddingLeftNoRTL() + Display.getInstance().convertToPixels(3, true), getY() + getHeight() / 2);
        }

        
    };
    lead.setText(localize("SignatureComponent.LeadText","Press to sign"));
    lead.setUIID("SignatureButton");
    lead.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            final Dialog dialog = new Dialog(localize("SignatureComponent.DialogTitle", "Sign Here"));
            final SignatureDialogBody sigBody = new SignatureDialogBody() {
                @Override
                protected void onCancel() {
                    super.onCancel();
                    dialog.dispose();
                }
            };

            sigBody.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sigDoneEvent) {
                    dialog.dispose();
                    setSignatureImage(sigBody.getValue());
                    fireActionEvent();

                }
            });

            dialog.setLayout(new BorderLayout());
            dialog.addComponent(BorderLayout.CENTER, sigBody);
            dialog.setScrollable(false);
            dialog.setFocusable(false);
            dialog.show();
        }
    });
    addComponent(BorderLayout.CENTER, lead);
}
 
Example 18
Source File: SimpleDateFormatTest.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    final Form hi = new Form("Hi World", BoxLayout.y());
    TextField dateStringIn = new TextField();
    TextField dateFormat = new TextField();
    Label shortMonth = new Label();
    Label longMonth = new Label();
    Label shortDate = new Label();
    Label longDate = new Label();
    Container result = new Container(BoxLayout.y());
    Button parse = new Button("Parse Date");
    Container resultWrapper = new Container(BoxLayout.y());
    
    parse.addActionListener(evt->{
        try {
            SimpleDateFormat inputFormat = new SimpleDateFormat(dateFormat.getText());
            Date dt = inputFormat.parse(dateStringIn.getText());
            
            SimpleDateFormat shortMonthFormat = new SimpleDateFormat("MMM");
            shortMonth.setText(shortMonthFormat.format(dt));
            
            SimpleDateFormat longMonthFormat = new SimpleDateFormat("MMMM");
            longMonth.setText(longMonthFormat.format(dt));
            
            longDate.setText(L10NManager.getInstance().formatDateLongStyle(dt));
            shortDate.setText(L10NManager.getInstance().formatDateShortStyle(dt));
            resultWrapper.removeAll();
            resultWrapper.add(result);
            hi.revalidateWithAnimationSafety();
        } catch (ParseException ex) {
            Log.e(ex);
            ToastBar.showErrorMessage("Parse failed: "+ex.getMessage());
        }
    });
    result.addAll(
            new Label("Short month name:"),
            shortMonth,
            new Label("Long month name:"),
            longMonth,
            new Label("Short Date:"),
            shortDate,
            new Label("Long Date:"),
            longDate
    );

    hi.addAll(
            new Label("Date:"),
            dateStringIn,
            new Label("Date Format:"),
            dateFormat,
            parse,
            resultWrapper
    );
    
    
    
    
    
    hi.show();
}
 
Example 19
Source File: InfiniteProgressWithMessage.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    Button showProgress = new Button("Show InfiniteProgress");
    showProgress.addActionListener(e->{
        callSerially(()->{
            Dialog dlg = new Dialog();
            dlg.setDialogUIID("Container");
            dlg.setTintColor(0x0);
            dlg.setLayout(new BorderLayout());
            SpanLabel message = new SpanLabel("This is a progress message we wish to show");
            $("*", message).setFgColor(0xffffff);
            dlg.add(BorderLayout.CENTER, BoxLayout.encloseYCenter(FlowLayout.encloseCenter(new InfiniteProgress()), FlowLayout.encloseCenter(message)));

            dlg.setTransitionInAnimator(CommonTransitions.createEmpty());
            dlg.setTransitionOutAnimator(CommonTransitions.createEmpty());
            dlg.showPacked(BorderLayout.CENTER, false);

            //dlg.revalidateWithAnimationSafety();
            invokeAndBlock(()->{
                Util.sleep(5000);
            });
            dlg.dispose();
            
        });
    });
    
    Button showToastProgress = new Button("Show Toast Progress");
    showToastProgress.addActionListener(e->{
        callSerially(()->{
            Status status = ToastBar.getInstance().createStatus();
            status.setMessage("This is a progress message we wish to show");
            status.setShowProgressIndicator(true);
            status.show();
            invokeAndBlock(()->{
                Util.sleep(5000);
            });
            status.clear();
                    
        });
    });
    hi.addAll(showProgress, showToastProgress);
    hi.show();
}
 
Example 20
Source File: BrowserComponentPostMessageSample.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", new BorderLayout());
    BrowserComponent bc = new BrowserComponent();
    
    /* A test page to demonstrate posting messages cross-domain.  The source of this page is:
    <?php
    // This header is really just meant to break the X-Frame-Options sameorigin header
    // that is sent by default by Amazon Lightsail.  
    // In order ot display a page in an iFrame, you may need to fuss with 
    // the X-Frame-Options header.
    // More at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
    header('X-Frame-Options: allow-from http://localhost:58494');

    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <script
      src="https://code.jquery.com/jquery-3.4.1.min.js"
      integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
      crossorigin="anonymous"></script>

    <script>
    window.addEventListener("message", function(event) {
        var div = jQuery('<div></div>');
        jQuery(div).text(event.data);
        jQuery('body').append(div);
    }, false);

    function postToCN1(msg) {
        if (window.cn1PostMessage) {
            window.cn1PostMessage(msg);
        } else {
            window.parent.postMessage(msg, '*');
        }
    }
    </script>
    </head>
    <body>
    <h1>Listening to Messages...</h1>
    <p><input id='msg' type="text" value="Message To CN1"/></p>
    <p><button onclick="jQuery('body').append(jQuery('<span>foo</span>')); postToCN1(jQuery('#msg').val(), '*')">Send</p>
    </body>
    </html>
    
    */
    bc.setURL("https://weblite.ca/cn1tests/post_message_test.php");
    
    // Register a listener to receive messages sent from the BrowserComponent's webpage.
    // A simple javascript function to send a message to this handler from within your page
    // is:
    // function postToCN1(msg) {
    //    if (window.cn1PostMessage) {
    //        // Case 1: We are running in a native app in a WebView.
    //        window.cn1PostMessage(msg);
    //    } else {
    //        // Case 2: We are running in a Javascript app in an iframe
    //        window.parent.postMessage(msg, '*');
    //    }
    // }

    
    bc.addWebEventListener(BrowserComponent.onMessage, e->{
        CN.callSerially(()->{
            Log.p("Message: "+e.getSource());
            Dialog.show("Here", (String)e.getSource(), "OK", null);
        });
    });
    
    
    TextField message = new TextField("A sample message");
    Button b = new Button("Send Message");
    b.addActionListener(e->{
        
        // Send a message to the webpage.
        // This can be received in the webpage using the 'message' event.
        // E.g.
        /*
        window.addEventListener("message", function(event) {
            var div = jQuery('<div></div>');
            jQuery(div).text(event.data);
            jQuery('body').append(div);
        }, false);
        */
        bc.postMessage(message.getText(), "https://weblite.ca");
            // IMPORTANT: 2nd argument should be either '*' to target any origin
            // or the origin of the web page in the BrowserComponent.
            
        // See https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage for more information.
    });
    hi.add(CENTER, bc);
    hi.add(BorderLayout.SOUTH, BoxLayout.encloseY(message, b));
    hi.show();
}