Vollbildmodus mit weiteren Dialogen

Vogi

Aktives Mitglied
Hallo,

ich habe ein Spiel geschrieben, dass im Vollbildmodus dargestellt werden soll. Das Problem ist aber, dass das Spiel per Dialog Eingaben vom Benutzer abfragen soll. Wenn ich aber einen Dialog aufrufe, erscheint der nie, da er wohl vom Vollbildmodus blockiert wird. Kann man dies irgendwie umgehen?
 

Nicer

Bekanntes Mitglied
Die Taskleiste Blockt ein Popup Fenster ? checke nicht ganz wie das klappen soll :bahnhof:

Um das klarzustellen :
Die Taskleiste ist die Leiste mit dem "Start" button von Windows am unteren Bildschirmrand.
 

Vogi

Aktives Mitglied
ich meine, wenn ich die Fesntergröße auf 1600*900 einstelle, dann sieht man nicht das ganze Fenster, da unten die Taskleiste im Weg ist
 

Vogi

Aktives Mitglied
gibt es keine Möglichkeit, das ganze im Vollbildmodus zu realisieren ? Denn Spiele sind ja normalerweise oft im Vollbildmodus.
Und falls das mit dem Vollbildmodus nicht geht, wie kann ich dann ermitteln, wie groß mein Fenster sein kann, wenn man alles vom Fenster sehen soll?
 

StrikeTom

Bekanntes Mitglied
Meinst du sowas?
Java:
Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setPrefferedSize(screensize);
Und soweit ich weiß, überdeckt ein JWindow die taskleiste
 
Zuletzt bearbeitet:

Vogi

Aktives Mitglied
wenn ein JWindow das überdeckt dann wäre das problem gelöst, ich hatte das ganze mit einem JFrame und da hatte es nicht funktioniert, aber ich kann auch auf JWindow umsteige, ist eigentlich soger besser
 

Ebenius

Top Contributor
Ob die Taskleiste vor oder hinter den Fenstern liegt, kann jeder Windowsbenutzer selbst einstellen. Wenn Du den gesamten Bildschirm benutzen willst, bleibt Dir nichts anderes übrig als den Fullscreen-Exclusive-Modus zu benutzen. Wenn Du trotzdem Popups benutzen willst, dann kannst Du eigentlich nur noch JInternal-Frames benutzen.

Hier mal ein Beispiel dazu:
Java:
/* (@)FullscreenWithOptionPaneTestGui.java */

/* Copyright 2010 Sebastian Haufe

 * Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       [url]http://www.apache.org/licenses/LICENSE-2.0[/url]

 * Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License. */

package com.ebenius;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class FullscreenWithOptionPaneTestGui {

  /** Creates the GUI. Call on EDT, only! */
  static void createAndShowGui() {
    final JPanel contentPane = new JPanel(new FlowLayout());

    /* a color changing content pane */
    new Timer(340, new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        final Color background = contentPane.getBackground();
        final Color newBackground;
        if (Color.BLUE.equals(background)) {
          newBackground = Color.RED;
        } else if (Color.RED.equals(background)) {
          newBackground = Color.YELLOW;
        } else if (Color.YELLOW.equals(background)) {
          newBackground = Color.GREEN;
        } else if (Color.GREEN.equals(background)) {
          newBackground = Color.ORANGE;
        } else if (Color.ORANGE.equals(background)) {
          newBackground = Color.GRAY;
        } else {
          newBackground = Color.BLUE;
        }
        contentPane.setBackground(newBackground);
        contentPane.repaint();
      }
    }).start();

    /* the full screen window */
    final JWindow window = new JWindow();

    /* button to show the option pane */
    contentPane.add(new JButton(new AbstractAction("Show Option Pane") {

      private static final long serialVersionUID = 1L;

      public void actionPerformed(ActionEvent e) {
        /* create a desktop pane for the internal dialog */
        final JDesktopPane desktopPane = new JDesktopPane();
        desktopPane.setOpaque(false);

        /* center dialogs on the desktop pane */
        desktopPane.setLayout(new LayoutManager() {

          public void addLayoutComponent(String name, Component comp) {}

          public void removeLayoutComponent(Component comp) {}

          public Dimension preferredLayoutSize(Container parent) {
            return new Dimension(0, 0);
          }

          public Dimension minimumLayoutSize(Container parent) {
            return new Dimension(0, 0);
          }

          public void layoutContainer(Container parent) {
            final Dimension pSize = parent.getSize();
            final Insets pInsets = parent.getInsets();
            final int x = (pSize.width + pInsets.left - pInsets.right) / 2;
            final int y = (pSize.height + pInsets.top - pInsets.bottom) / 2;
            for (int i = 0; i < parent.getComponentCount(); i++) {
              final Component component = parent.getComponent(i);
              final Dimension size = component.getPreferredSize();
              component.setSize(size);
              component.setLocation(x - size.width / 2, y - size.height / 2);
            }
          }
        });

        /* set the desktop pane as glass pane, show dialog, reset glass */
        final Component oldGlassPane = window.getGlassPane();
        window.setGlassPane(desktopPane);
        JOptionPane.showInternalMessageDialog(desktopPane, "Huhu");
        window.setGlassPane(oldGlassPane);
      }
    }));

    /* exit */
    contentPane.add(new JToggleButton(new AbstractAction("Exit") {

      private static final long serialVersionUID = 1L;

      public void actionPerformed(ActionEvent e) {
        System.exit(0);
      }
    }));

    /* pack and show frame */
    window.setContentPane(contentPane);
    window.pack();
    window.setLocationRelativeTo(null);
    window.getGraphicsConfiguration().getDevice().setFullScreenWindow(window);
  }

  /** @param args ignored */
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {

      public void run() {
        createAndShowGui();
      }
    });
  }
}
Ebenius
 
Zuletzt bearbeitet:

Neue Themen


Oben