Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JApplet: Popup

Empfohlene Antworten

Veröffentlicht

Hi Leute,

ich will in meinem Applet (welches das Filesystem meines Rechners anzeigt) ein Popup öffnen, welches dann ein Kontextmenü anzeigt.

Hab es schon mit handeslüblichen Popups ausprobiert, sowie mit dem GlassPane.


package xx.xx.xx.fileBrowser.gui;


import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.util.Vector;


import javax.swing.*;

import javax.swing.tree.*;


import corp.bmw.emeadecentral.fileBrowser.app.Browser;



public class BrowserApplet3 extends JApplet implements MouseListener, ActionListener{


    private void popup(MouseEvent e) {

        actions = new PopupMenu();

        mi1 = new MenuItem("Löschen");

        mi2 = new MenuItem("Umbenennen");

        mi3 = new MenuItem("Kopieren");

        mi4 = new MenuItem("Einfügen");

        mi1.addActionListener(this);

        mi2.addActionListener(this);

        mi3.addActionListener(this);

        mi4.addActionListener(this);

        actions.add(mi1);

        actions.add(mi2);

        actions.add(mi3);

        actions.add(mi4);

        //actions.show(this, e.getX()+10, e.getY()+10);

        actions.enable();

        this.getGlassPane().add(actions);

    }


    public void mouseClicked(MouseEvent e) {

        int click = e.getClickCount();

        int button = e.getButton();

        String s = null;


        //Öffne Verzeichniss...

        if ((button == 1) && (click == 2)) {

            s = tree.getSelectionPath().getLastPathComponent().toString();

            //s = "d:/downloads";

            System.out.println("String: "+s);

            File f = new File(s);

            System.out.println("File "+f);

            if(f.isDirectory()) {

                this.directory = f;

                System.out.println(this.directory);

                build();

            }

            //...oder führe Datei aus

            else {

                try {

                    Browser.doRun(f);

                } catch (IOException e1) {

                    e1.printStackTrace();

                }

            }

        }

        //öffne Kontextmenue

        if((button == 3) && (click == 1)) {

            /*popup = (Container) getGlassPane();

            System.out.println("*** Popup!!!! ***");

            popup(e);

            popup.add(actions);

            popup.setEnabled(true);

            popup.setVisible(true);*/

            popup(e);

        }


    }

Bin für jede idee zu haben. PS: Applets können von haus aus nicht auf das Filesystem zugreiffen. Um das zu ermöglichen, müsst ihr in der "java.policy" das hinzufügen:


grant {

	permission xx.xx.xx.fileBrowser.gui.BrowserApplet3;

	permission xx.xx.xx.fileBrowser.app.Browser;

};


Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.