コード例 #1
0
ファイル: GuiUtility.java プロジェクト: dschachinger/colibri
  /**
   * This method starts the GUI.
   *
   * @throws CoapException Thrown, if the connection to obix via CoAP fails.
   */
  public void runGui() throws CoapException {
    this.lobby = obixChannel.getLobby(obixChannel.getLobbyUri());
    // Create and set up the window.
    mainFrame =
        new JFrame("ObixConnector at " + obixChannel.getBaseUri() + ": " + obixChannel.getPort());
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    mainFrame.setUndecorated(false);
    mainFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            close();
          }
        });

    Container contentPane = mainFrame.getContentPane();

    // Create and set up the content pane.
    this.addComponentToPane(contentPane);

    // Display the window.
    mainFrame.pack();
    executor.execute(updateThread);
    connector.addRunAndStopAble(updateThread);
    mainFrame.setVisible(true);
  }
コード例 #2
0
  /** Enters full screen mode and changes the display mode. */
  public void setFullScreen(DisplayMode displayMode, JFrame window) {

    window.setUndecorated(true);
    window.setResizable(false);
    cmdemo bgd = new cmdemo();
    JList mission = new JList(string);
    mission.setVisibleRowCount(4);
    JScrollPane pane = new JScrollPane(mission);
    pane.setBounds(400, 400, 225, 70);
    window.getContentPane().add(pane);

    muButton.setBounds(764 - 120, 625 - 10, 225, 49);
    textField1.setBounds(630 - 120, 328 - 10, 225, 25);
    window.getContentPane().add(muButton);
    window.getContentPane().add(textField1);
    // window.add(bgd);
    muButton.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
    muButton.setToolTipText("start");
    muButton.setBorder(null);
    muButton.setRolloverIcon(new javax.swing.ImageIcon("imgs/start1.jpg"));
    muButton.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent evt) {
            startActionPerformed(evt);
          }
        });

    aButton.setBounds(284 - 120, 625 - 10, 225, 49);
    window.getContentPane().add(aButton);
    window.add(bgd);
    aButton.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
    aButton.setToolTipText("back");
    aButton.setBorder(null);
    aButton.setRolloverIcon(new javax.swing.ImageIcon("imgs/back1.jpg"));

    aButton.addActionListener(
        new java.awt.event.ActionListener() {

          public void actionPerformed(java.awt.event.ActionEvent evt) {
            backActionPerformed(evt);
          }
        });

    device.setFullScreenWindow(window);
    if (displayMode != null && device.isDisplayChangeSupported()) {
      try {
        device.setDisplayMode(displayMode);
      } catch (IllegalArgumentException ex) {
        // ignore - illegal mode for this device
      }
    }
  }
コード例 #3
0
  public static void main(String s[]) {

    // Getting save directory
    String saveDir;
    if (s.length > 0) {
      saveDir = s[0];
    } else {
      saveDir =
          JOptionPane.showInputDialog(
              null,
              "Please enter directory where "
                  + "the images is/will be saved\n\n"
                  + "Also possible to specifiy as argument 1 when "
                  + "running this program.",
              "l:\\webcamtest");
    }

    String layout = "";
    if (s.length > 1) {
      layout = s[1];
    }

    // Move mouse to the point 5000,5000 px (out of the screen)
    Robot rob;
    try {
      rob = new Robot();
      rob.setAutoDelay(500); // 0,5 s
      rob.mouseMove(5000, 5000);
    } catch (AWTException e) {
      e.printStackTrace();
    }

    // Make the main window
    JFrame frame = new JFrame();
    frame.setAlwaysOnTop(true);
    frame.setTitle(
        "Webcam capture and imagefading - "
            + "Vitenfabrikken Jærmuseet - "
            + "made by Hallvard Nygård - "
            + "Vitenfabrikken.no / Jaermuseet.no");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setUndecorated(true);

    WebcamCaptureAndFadePanel panel = new WebcamCaptureAndFadePanel(saveDir, layout);
    frame.getContentPane().add(panel);
    frame.addKeyListener(panel);
    frame.pack();

    frame.setVisible(true);
  }
コード例 #4
0
ファイル: Clock.java プロジェクト: YuriDenison/Univercity
 public static void main(String[] args) {
   JFrame frame = new JFrame("Clock by Volkman");
   frame.setContentPane(new Clock().getForm());
   frame.pack();
   Toolkit tk = Toolkit.getDefaultToolkit();
   Dimension dim = tk.getScreenSize();
   AWTUtilities.setWindowOpacity(frame, (float) 0.25);
   frame.setLocation((int) dim.getWidth() - 400, 20);
   frame.removeNotify();
   frame.setUndecorated(true);
   frame.setVisible(true);
   frame.setAlwaysOnTop(true);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
コード例 #5
0
 public static void toFullScreen(
     JFrame window,
     GraphicsDevice gd,
     boolean tryAppleFullscreen,
     boolean tryExclusiveFullscreen) {
   if (appleEawtAvailable()
       && tryAppleFullscreen
       && appleOSVersion() >= 7
       && // lion and above
       javaVersion() >= 7) { // java 7 and above
     System.out.println("trying to apple fullscreen");
     enableAppleFullscreen(window);
     doAppleFullscreen(window);
   } else if (appleEawtAvailable()
       && // Snow Leopard and below OR apple java 6 and below TODO: test this on SL
       tryExclusiveFullscreen
       && gd.isFullScreenSupported()) {
     if (javaVersion() >= 7) setAutoRequestFocus(window, true);
     window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     window.setUndecorated(true);
     // window.setExtendedState(JFrame.MAXIMIZED_BOTH);
     gd.setFullScreenWindow(window);
     window.toFront();
     Rectangle r = gd.getDefaultConfiguration().getBounds();
     window.setBounds(r);
     // window.pack();
   } else { // Windows and Linux TODO: test this
     window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     window.setUndecorated(true);
     window.setSize(gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight());
     window.setLocation(0, 0);
     window.setExtendedState(JFrame.MAXIMIZED_BOTH);
     window.toFront();
   }
   window.pack();
   window.setVisible(true);
 }
コード例 #6
0
  public Fenetre() {

    frame = new JFrame();
    frame.setTitle("Gestion Sauvegarde Serveur");
    frame.setSize(700, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setIconImage(
        Toolkit.getDefaultToolkit().getImage(getClass().getResource("/go-home.png")));
    frame.setResizable(true);
    frame.setLocationRelativeTo(null);
    frame.setUndecorated(false);
    frame.setBackground(Color.white);
    frame.setContentPane(contentPane());
    frame.setVisible(true);
  }
コード例 #7
0
ファイル: Application.java プロジェクト: maarksco/nodebox
 /**
  * Register for special events available on the Mac, such as showing the about screen, showing the
  * preferences or double-clicking a file.
  *
  * @throws RuntimeException if the adapter methods could not be loaded.
  */
 private void registerForMacOSXEvents() throws RuntimeException {
   if (!Platform.onMac()) return;
   try {
     // Generate and register the OSXAdapter, passing it a hash of all the methods we wish to
     // use as delegates for various com.apple.eawt.ApplicationListener methods
     OSXAdapter.setQuitHandler(this, getClass().getDeclaredMethod("quit", (Class[]) null));
     OSXAdapter.setAboutHandler(this, getClass().getDeclaredMethod("showAbout", (Class[]) null));
     OSXAdapter.setPreferencesHandler(
         this, getClass().getDeclaredMethod("showPreferences", (Class[]) null));
     OSXAdapter.setFileHandler(this, getClass().getDeclaredMethod("readFromFile", String.class));
   } catch (Exception e) {
     throw new RuntimeException("Error while loading the OS X Adapter.", e);
   }
   // On the Mac, if all windows are closed the menu bar will be empty.
   // To solve this, we create an off-screen window with the same menu bar as visible windows.
   hiddenFrame = new JFrame();
   hiddenFrame.setJMenuBar(new NodeBoxMenuBar());
   hiddenFrame.setUndecorated(true);
   hiddenFrame.setSize(0, 0);
   hiddenFrame.setLocation(-100, -100);
   hiddenFrame.pack();
   hiddenFrame.setVisible(true);
 }
コード例 #8
0
ファイル: MacTray.java プロジェクト: ufoe/desktop
  @Override
  public void notify(String summary, String body, File imageFile) {

    frame = new JFrame();
    frame.setSize(300, 125);
    frame.setUndecorated(true);

    Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); // size of the screen
    Insets toolHeight =
        Toolkit.getDefaultToolkit()
            .getScreenInsets(frame.getGraphicsConfiguration()); // height of the task bar
    frame.setLocation(scrSize.width - frame.getWidth(), toolHeight.top + toolHeight.bottom);

    frame.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 1.0f;
    constraints.weighty = 1.0f;
    constraints.insets = new Insets(5, 5, 5, 5);
    constraints.fill = GridBagConstraints.BOTH;

    JLabel headingLabel = new JLabel(summary);
    if (imageFile != null) {
      Icon headingIcon = new ImageIcon(imageFile.getPath());
      headingLabel.setIcon(headingIcon); // --- use image icon you want to be as heading image.
    }
    headingLabel.setOpaque(false);
    frame.add(headingLabel, constraints);

    constraints.gridx++;
    constraints.weightx = 0f;
    constraints.weighty = 0f;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.NORTH;

    JButton cloesButton =
        new JButton(
            new AbstractAction("X") {
              @Override
              public void actionPerformed(final ActionEvent e) {
                frame.dispose();
              }
            });

    cloesButton.setMargin(new Insets(1, 4, 1, 4));
    cloesButton.setFocusable(false);

    frame.add(cloesButton, constraints);

    constraints.gridx = 0;
    constraints.gridy++;
    constraints.weightx = 1.0f;
    constraints.weighty = 1.0f;
    constraints.insets = new Insets(5, 5, 5, 5);
    constraints.fill = GridBagConstraints.BOTH;
    JLabel messageLabel = new JLabel("<HtMl>" + body);
    frame.add(messageLabel, constraints);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setVisible(true);
    frame.setAlwaysOnTop(true);

    new Thread() {
      @Override
      public void run() {
        try {
          Thread.sleep(3500); // time after which pop up will be disappeared.
          frame.dispose();
        } catch (InterruptedException e) {
          System.err.println(e.getMessage());
        }
      };
    }.start();
  }
コード例 #9
0
ファイル: TestPopupWindow.java プロジェクト: bbuildman/IGP
  /** Initialiser. */
  private void init() {

    invokePopupButton = new JToggleButton("Show popup");
    invokePopupButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // set popup window visibility
            if (!popupWindow.isVisible()) {
              // set location relative to button
              Point location = invokePopupButton.getLocation();
              SwingUtilities.convertPointToScreen(location, invokePopupButton.getParent());
              location.translate(
                  0,
                  invokePopupButton.getHeight()
                      + (invokePopupButton.getBorder() == null
                          ? 0
                          : invokePopupButton
                              .getBorder()
                              .getBorderInsets(invokePopupButton)
                              .bottom));
              popupWindow.setLocation(location);

              // show the popup if not visible
              invokePopupButton.setText("Hide popup");
              popupWindow.setVisible(true);
              popupWindow.requestFocus();
            } else {
              // hide it otherwise
              invokePopupButton.setText("Show popup");
              popupWindow.setVisible(false);
            }
          }
        });

    // add components to main panel
    this.setLayout(new BorderLayout());
    this.add(invokePopupButton, BorderLayout.CENTER);

    // use frame
    popupWindow = new JFrame();
    popupWindow.setUndecorated(true);

    popupWindow.addWindowFocusListener(
        new WindowFocusListener() {
          public void windowGainedFocus(WindowEvent e) {}

          public void windowLostFocus(WindowEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    if (popupWindow.isVisible()) invokePopupButton.doClick();
                  }
                });
          }
        });

    // add some components to window
    popupWindow.getContentPane().setLayout(new BorderLayout());
    ((JComponent) popupWindow.getContentPane()).setBorder(BorderFactory.createEtchedBorder());
    JTextField aTextField = new JTextField(10);
    popupWindow.getContentPane().add(new JLabel("Text:"), BorderLayout.WEST);
    popupWindow.getContentPane().add(aTextField);
    popupWindow.pack();
  }
コード例 #10
0
  public WebcamCaptureAndFadePanel(String saveDir, String layout) {

    System.out.println("Using " + saveDir + " as directory for the images.");
    saveDirectory = saveDir;

    getImages();
    images_used = new ArrayList<Integer>();
    images_lastadded = new ArrayList<Integer>();
    images_nevershown = new ArrayList<Integer>();

    Vector devices = (Vector) CaptureDeviceManager.getDeviceList(null).clone();
    Enumeration enumeration = devices.elements();
    System.out.println("- Available cameras -");
    ArrayList<String> names = new ArrayList<String>();
    while (enumeration.hasMoreElements()) {
      CaptureDeviceInfo cdi = (CaptureDeviceInfo) enumeration.nextElement();
      String name = cdi.getName();
      if (name.startsWith("vfw:")) {
        names.add(name);
        System.out.println(name);
      }
    }

    // String str1 = "vfw:Logitech USB Video Camera:0";
    // String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
    if (names.size() == 0) {
      JOptionPane.showMessageDialog(
          null,
          "Ingen kamera funnet. " + "Du må koble til et kamera for å kjøre programmet.",
          "Feil",
          JOptionPane.ERROR_MESSAGE);
      System.exit(0);
    } else if (names.size() > 1) {

      JOptionPane.showMessageDialog(
          null,
          "Fant mer enn 1 kamera. " + "Velger da:\n" + names.get(0),
          "Advarsel",
          JOptionPane.WARNING_MESSAGE);
    }

    String str2 = names.get(0);
    di = CaptureDeviceManager.getDevice(str2);
    ml = di.getLocator();

    try {
      player = Manager.createRealizedPlayer(ml);
      formatControl = (FormatControl) player.getControl("javax.media.control.FormatControl");

      /*
      Format[] formats = formatControl.getSupportedFormats();
      for (int i=0; i<formats.length; i++)
      	System.out.println(formats[i].toString());
      */

      player.start();
    } catch (javax.media.NoPlayerException e) {
      JOptionPane.showMessageDialog(
          null,
          "Klarer ikke å starte" + " programmet pga. feil med kamera. Sjekk at det er koblet til.",
          "IOException",
          JOptionPane.ERROR_MESSAGE);
      System.exit(0);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }

    /*
     * Layout
     *
     * Add
     * - comp
     * - imagepanels
     */

    if (layout.equals("1024v2")) {
      layout1024v2();
    } else if (layout.equals("1280")) {
      layout1280();
    } else {
      layout1024();
    }

    // Capture Window
    if (captureWindow) {
      cw = new JFrame("Capture from webcam");
      cw.setAlwaysOnTop(true);
      cw.setSize(sizeCaptureWindow_x, sizeCaptureWindow_y);
      cw.addKeyListener(new captureWindowKeyListner());
      cw.setUndecorated(true);

      // Add webcam
      if ((comp = player.getVisualComponent()) != null) {
        cw.add(comp);
      }

      // Add panel to window and set location of window
      cw.setLocation(cwLocation_x, cwLocation_y);
    }

    // Text window
    cwText = new rotatedText("");

    /*
     * Timer for update
     */
    Timer thread = new Timer();
    thread.schedule(new frameUpdateTask(), 0, (1000 / fps));
  }