/**
   * Creates a new GraphicUI with the given title.
   *
   * @param title the title of the JFrame.
   */
  public GraphicUI(String title) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    f = new JFrame("BackgroundBorderExample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final Container cp = f.getContentPane();
    final JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    BufferedImage im =
        ResourceLoader.getResourceLoader().getBufferedImage(Values.MenuImages + "backsmall.jpg");
    Dimension size = new Dimension(im.getWidth(null), im.getHeight(null));
    f.setPreferredSize(size);
    f.setMinimumSize(size);
    f.setMaximumSize(size);
    f.setSize(size);
    final Border bkgrnd = new CentredBackgroundBorder(im);
    Runnable r =
        new Runnable() {
          public void run() {
            p.setBorder(bkgrnd);
            cp.repaint();
          }
        };
    SwingUtilities.invokeLater(r);
    readFile();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    p.add(createResolution(), BorderLayout.CENTER);
    p.add(createStartButton(), BorderLayout.SOUTH);

    cp.add(p);

    f.setLocationRelativeTo(null);
    f.pack();
    f.setVisible(true);
  }
示例#2
0
  public Window(int width, int height, String title, Game game) {
    JFrame frame = new JFrame(title);

    frame.setPreferredSize(new Dimension(width, height + 22));
    frame.setMaximumSize(new Dimension(width, height + 22));
    frame.setMinimumSize(new Dimension(width, height + 22));

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.add(game);
    frame.setVisible(true);
    game.start();
  }
  public NewRenderMethod() {
    try {
      sSocket = new Socket("localhost", 7214);
      in = new DataInputStream(sSocket.getInputStream());
      PlayerID = in.readInt();
      out = new DataOutputStream(sSocket.getOutputStream());
      Input input = new Input(in, this);
      Thread thread = new Thread(input);
      thread.start();
    } catch (Exception e) {
      e.printStackTrace();
    }

    manager.addMap(map);
    manager.addPlayer(new Player(445, 575));
    manager.PlayerX.add(0);
    manager.PlayerXOffset.add(-220);
    manager.PlayerY.add(0);
    manager.PlayerYOffset.add(-370);
    manager.addPlayer(new Player(445, 575));
    manager.PlayerX.add(0);
    manager.PlayerXOffset.add(-220);
    manager.PlayerY.add(0);
    manager.PlayerYOffset.add(-370);
    manager.addPlayer(new Player(445, 575));
    manager.PlayerX.add(0);
    manager.PlayerXOffset.add(-220);
    manager.PlayerY.add(0);
    manager.PlayerYOffset.add(-370);

    this.addKeyListener(input);
    this.addMouseListener(mouse);
    this.addMouseMotionListener(mouse);

    frame.setPreferredSize(new Dimension(Width, Height));
    frame.setMaximumSize(new Dimension(Width, Height));
    frame.setMinimumSize(new Dimension(Width, Height));
    frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    frame.setFocusable(true);
    frame.setFocusableWindowState(true);
    frame.add(this);

    thread.start();
  }
示例#4
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("计算器");
    //        frame.setBounds(500,250,100,100);
    Dimension min = new Dimension(500, 500);
    frame.setMinimumSize(min);

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension max = toolkit.getScreenSize();
    frame.setMaximumSize(max);

    frame.setLayout(new BorderLayout());
    frame.add(new TextField(40), BorderLayout.NORTH);
    frame.add(gridPanel());

    frame.pack();
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
示例#5
0
  private void loadGUI() {
    clientFrame = new JFrame("Client File Transfer Control Panel");
    clientFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            ClientMain.terminate();
          }
        });
    clientFrame.setMaximumSize(new Dimension(1920, 1080));
    buttonPanel = new JPanel();
    selectPanel = new JPanel();
    controlPanel = new JPanel();
    controlPanel.setLayout(new BorderLayout());
    displayPanel = new JPanel();
    displayPanel.setLayout(new BorderLayout());
    receivePanel = new JPanel();
    receivePanel.setLayout(new BorderLayout());
    receiveControlPanel = new JPanel();
    receiveControlPanel.setLayout(new BorderLayout());
    statusPanel = new JPanel();
    statusPanel.setLayout(new BorderLayout());

    setUpButtonPanel();
    setUpSelectBox();
    setUpDisplayPanel();
    setUpStatusPanel();
    setUpReceivePanel();

    receiveControlPanel.add(receivePanel, BorderLayout.WEST);
    receiveControlPanel.add(displayPanel, BorderLayout.CENTER);
    controlPanel.add(buttonPanel, BorderLayout.NORTH);
    controlPanel.add(receiveControlPanel, BorderLayout.CENTER);
    clientFrame.add(controlPanel, BorderLayout.CENTER);

    clientFrame.validate();
    clientFrame.pack();
    clientFrame.setVisible(true);

    // add action listener
    input.addActionListener(new InputDirectoryChooser());
    output.addActionListener(new OutputDirectoryChooser());
    receive.addActionListener(new Receive());
  }
  @Override
  public void lancerAffichage() throws IOException {
    JPanel panneauPrincipal = new JPanel();
    for (JCheckBox box2 : listCheckBoxLog) {
      box2.addActionListener(this);
      panneauPrincipal.add(box2);
    }
    startButton.addActionListener(this);
    panneauPrincipal.add(startButton, BorderLayout.SOUTH);

    scrollPane.getViewport().setView(panneauPrincipal);

    cadre.setContentPane(panneauPrincipal);
    cadre.setLocation(DEFAULT_LOCATION_X, DEFAULT_LOCATION_Y);
    cadre.pack();
    cadre.setResizable(false);
    cadre.setMaximumSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
    cadre.setVisible(true);
    cadre.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
  }
示例#7
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }