Как отменить браузер, чтобы открыть конкретный сайт? - PullRequest
0 голосов
/ 19 декабря 2018

Я хотел сделать самодельный браузер .. Но у меня большая проблема с моим Java-кодом.Если строка (ссылка) - «adiste.de», я хочу, чтобы JOptionPane сообщал: «Вы не можете перейти на этот сайт».Но если ссылка все еще "adiste.de", он уходит в сторону, хотя может и не быть!Это от строки 108 до 127 (часть с mntmNewItem_1).

    Browser browser = new Browser(this, SWT.NONE);
    browser.setUrl("google.de");

    Menu menu = new Menu(this, SWT.BAR);
    setMenuBar(menu);

    MenuItem mntmNewItem_1 = new MenuItem(menu, SWT.NONE);
    mntmNewItem_1.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String[] gesperrt = new String[] {"adiste.de"};
            String link = JOptionPane.showInputDialog("Website öffnen");
            if(link != gesperrt[0]) {
            if(link == null) {
                link = "google.de";
                browser.setUrl(link);
            }
            if(!(link == null)) {
                browser.setUrl(link);
            }
            } else {
                JOptionPane.showMessageDialog(null, "Du darfst nicht auf         diese Website!");
            }
        }
    });
    mntmNewItem_1.setText("Website \u00F6ffnen");
}

/**
 * Create contents of the shell.
 */
protected void createContents() {

}

@Override
protected void checkSubclass() {
    // Disable the check that prevents subclassing of SWT components
}
}
...