Exemplo n.º 1
1
 public int getTitleHeight(Component c) {
   int th = 21;
   int fh = getBorderInsets(c).top + getBorderInsets(c).bottom;
   if (c instanceof JDialog) {
     JDialog dialog = (JDialog) c;
     th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
     if (dialog.getJMenuBar() != null) {
       th -= dialog.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JInternalFrame) {
     JInternalFrame frame = (JInternalFrame) c;
     th = frame.getSize().height - frame.getRootPane().getSize().height - fh - 1;
     if (frame.getJMenuBar() != null) {
       th -= frame.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JRootPane) {
     JRootPane jp = (JRootPane) c;
     if (jp.getParent() instanceof JFrame) {
       JFrame frame = (JFrame) c.getParent();
       th = frame.getSize().height - frame.getContentPane().getSize().height - fh - 1;
       if (frame.getJMenuBar() != null) {
         th -= frame.getJMenuBar().getSize().height;
       }
     } else if (jp.getParent() instanceof JDialog) {
       JDialog dialog = (JDialog) c.getParent();
       th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
       if (dialog.getJMenuBar() != null) {
         th -= dialog.getJMenuBar().getSize().height;
       }
     }
   }
   return th;
 }
Exemplo n.º 2
0
  private void rightJustifyFrame(JFrame frame) {
    final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int yPos = (screen.height - frame.getSize().height) / 2;
    int xPos = screen.width - frame.getSize().width;
    if (yPos < 10) yPos = 10;

    frame.setLocation(new Point(xPos, yPos));
  }
Exemplo n.º 3
0
  public void init() {

    jf.setSize(350, 200);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 창 닫으면 프로그램 종료
    jf.setAlwaysOnTop(topview);
    jf.setTitle("로그인");
    jf.setVisible(true);

    // 전체 창 사이즈 가져오는거네
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    // 컴퓨터 화면 크기가 다르지만 모든 컴퓨터의 화면에 -- 창을 중앙에 위치시킬 수 있다.
    int xPos = screenSize.width / 2 - jf.getSize().width / 2;
    int yPos = screenSize.height / 2 - jf.getSize().height / 2;

    jf.setLocation(xPos, yPos);
    jf.setResizable(false);
    /*
     * jf.addWindowListener(new WindowAdapter() { public void
     * windowClosing(WindowEvent e) { System.exit(1); } });
     */

    // 화면구성
    gbl = new GridBagLayout();
    jf.setLayout(gbl);
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx = 0;
    gbc.weightx = 0.1;
    gbc.weighty = 0.2;
    gbc.insets.right = 10;
    jf.add(new JLabel("아이디"), gbc);
    gbc.gridx = 1;
    gbc.gridwidth = 2;
    gbc.weightx = 0.2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    jf.add(idtextfield, gbc);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = 1;
    gbc.weightx = 0.1;
    gbc.fill = GridBagConstraints.NONE;
    jf.add(new JLabel("비밀번호"), gbc);
    gbc.gridx = 1;
    gbc.gridwidth = 2;
    gbc.weightx = 0.2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    jf.add(pwdtextfield, gbc);
    JPanel pn1 = new JPanel();
    pn1.add(signupbt);
    pn1.add(loginbt);
    gbc.gridy = 2;
    gbc.gridx = 0;
    gbc.gridwidth = 3;
    jf.add(pn1, gbc);
  }
Exemplo n.º 4
0
  public static void framecreation() {
    int framesizex = 400;
    int framesizey = 600;

    frame = new JFrame("TwitchBot: Connection-Window");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setResizable(false);

    JPanel panel = new JPanel();
    panel.setLayout(null);

    status = new JLabel();
    status.setText("Bereit");
    status.setBounds(50, 550, 300, 15);
    JLabel statusbeschr = new JLabel();
    statusbeschr.setBounds(5, 550, 50, 15);
    statusbeschr.setText("Status: ");
    JLabel twitchnamelabel = new JLabel("Twitch Name");
    twitchnamelabel.setBounds(10, 50, 80, 25);

    JTextField twitchname = new JTextField("Twitch Channel");
    twitchname.setBounds(90, 50, 300, 25);
    twitchname.setText(main.Streamername);
    twitchname.setToolTipText("Enter here your Twitch Name.");

    JButton connect = new JButton();
    connect.setBounds(270, 520, 100, 25);
    connect.setText("Verbinden");
    connect.setToolTipText("Connect");
    connect.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            main.botconnection();
          }
        });
    JButton cancel = new JButton();
    cancel.setBounds(30, 520, 100, 25);
    cancel.setText("Abbrechen");
    cancel.setToolTipText("Cancel");

    panel.add(connect);
    panel.add(twitchnamelabel);
    panel.add(twitchname);
    panel.add(cancel);
    panel.add(statusbeschr);
    panel.add(status);
    frame.add(panel);

    Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setSize(framesizex, framesizey);
    frame.setLocation(
        screensize.width / 2 - frame.getSize().width / 2,
        screensize.height / 2 - frame.getSize().height / 2);
    frame.setVisible(true);
  }
Exemplo n.º 5
0
  // function to center the frame
  public static void center(JFrame jfrm) {
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    int width = jfrm.getSize().width;
    int height = jfrm.getSize().height;

    int x = (dim.width - width) / 2;
    int y = (dim.height - height) / 2;

    jfrm.setLocation(x, y);
  }
Exemplo n.º 6
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame = new JFrame();
    frame.setSize(1050, 781);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    int x = (dim.width - frame.getSize().width) / 2;
    int y = (dim.height - frame.getSize().height) / 2;
    frame.setLocation(x, y);
    // top
    AppMenu mn = new AppMenu();
    JPanel container = new JPanel();
    JPanel top = new JPanel();
    preview = new Canvas("PREVIEW", false, false, new Dimension(200, 200));
    top.add(preview);
    BorderLayout border = new BorderLayout();
    container.setLayout(border);
    container.add(mn, BorderLayout.NORTH);
    container.add(top, BorderLayout.SOUTH);
    frame.getContentPane().add(container, BorderLayout.NORTH);

    // left
    JPanel leftContainner = new JPanel();
    BorderLayout leftLyout = new BorderLayout();
    leftContainner.setLayout(leftLyout);

    JPanel left = new JPanel();
    move = new Canvas("MOVE", true, false, new Dimension(500, 500));
    left.add(move);
    leftContainner.add(left, BorderLayout.SOUTH);
    frame.getContentPane().add(leftContainner, BorderLayout.WEST);

    // right
    JPanel rightContainner = new JPanel();
    BorderLayout rightLyout = new BorderLayout();
    rightContainner.setLayout(rightLyout);
    JPanel right = new JPanel();
    zoom = new Canvas("ZOOM", false, true, new Dimension(500, 500));
    right.add(zoom);
    rightContainner.add(right, BorderLayout.SOUTH);
    frame.getContentPane().add(rightContainner, BorderLayout.EAST);
    Singleton.getInstance().getPreview().register(preview);
    Singleton.getInstance().getEdit().register(move);
    Singleton.getInstance().getEdit().register(zoom);

    preview.setSubject(Singleton.getInstance().getPreview());
    move.setSubject(Singleton.getInstance().getEdit());
    zoom.setSubject(Singleton.getInstance().getEdit());

    Singleton.getInstance().getWarpper().setTopCanvas(this.preview);
    Singleton.getInstance().getWarpper().setLeftCanvas(this.move);
    Singleton.getInstance().getWarpper().setRightCanvas(this.zoom);
  }
Exemplo n.º 7
0
  // ---------- Draw Window Thread Run & Main Program Run Loop ----------
  @Override
  public void run() {

    // Set Settings For JFrame
    frame.add(buildMenuBar());
    frame.setVisible(true);

    height = (int) frame.getSize().getHeight();
    width = (int) frame.getSize().getWidth();

    render = new Render(this, width, height);

    // Set Up Buffer Strategy For Direct Pixel Access
    img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    setPixels(((DataBufferInt) img.getRaster().getDataBuffer()).getData());

    // Mouse Setup
    dwm = new DrawWindowMouse(render);
    frame.addMouseListener(dwm);

    // Keyboard Setup
    dwk = new DrawWindowKeyboard(render);
    frame.addKeyListener(dwk);

    // Draw Loop
    do {
      // Starts Recording Render Time
      frameTime = System.currentTimeMillis();

      if (System.currentTimeMillis() - startRecodTime >= 1000) {
        startRecodTime = System.currentTimeMillis();
        lastFPS = frames;
        frames = 0;
      }

      // Renders Screen
      render();

      // Calculates FPS (Try  - Catch for catching start divide by zero)
      try {
        if (frameTime < maxWaitTime && fpsCap) Thread.sleep(maxWaitTime - frameTime);
        // lastFPS = 1000 / (System.currentTimeMillis() - startRecodTime);
      } catch (Exception e) {
        if (TreeGen.isDebug()) e.printStackTrace();
      }

      frames++;
    } while (TreeGen.running);

    if (!TreeGen.running) System.exit(0);
  }
Exemplo n.º 8
0
  /**
   * Entry point for the demo application.
   *
   * @param args ignored.
   */
  public static void main(String[] args) {

    final CompassDemo panel = new CompassDemo();

    JFrame frame = new JFrame();
    frame.getContentPane().setLayout(new BorderLayout(5, 5));
    frame.setDefaultCloseOperation(3);
    frame.setTitle("Compass Demo");
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    frame.setSize(700, 400);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(
        (d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
    frame.setVisible(true);
  }
Exemplo n.º 9
0
 public static void main(String[] args) {
   TableModelDemo applet = new TableModelDemo();
   JFrame frame = new JFrame();
   // EXIT_ON_CLOSE == 3
   frame.setDefaultCloseOperation(3);
   frame.setTitle("TableModelDemo");
   frame.getContentPane().add(applet, BorderLayout.CENTER);
   applet.init();
   applet.start();
   frame.setSize(500, 220);
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
   frame.setLocation(
       (d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
   frame.setVisible(true);
 }
Exemplo n.º 10
0
 public PlayGamePanel(JFrame frame, BoardConfiguration bc) {
   this.bc = bc;
   this.frame = frame;
   ImageIcon icon = new ImageIcon("ent.jpg");
   this.image = icon.getImage();
   this.one = new TransparentButton("1 Player");
   this.two = new TransparentButton("2 Players");
   this.three = new TransparentButton("3 Players");
   this.four = new TransparentButton("4 Players");
   this.setSize(frame.getSize());
   this.setLocation(0, 0);
   this.setLayout(null);
   one.setBounds(450, 140, 200, 40);
   two.setBounds(450, 200, 200, 40);
   three.setBounds(450, 260, 200, 40);
   four.setBounds(450, 320, 200, 40);
   this.add(one);
   this.add(two);
   this.add(three);
   this.add(four);
   this.back = new TransparentButton("Back");
   back.setBounds(450, 380, 200, 40);
   this.add(back);
   this.one.setFont(new Font("calibri", Font.ITALIC, 30));
   this.two.setFont(new Font("calibri", Font.ITALIC, 30));
   this.three.setFont(new Font("calibri", Font.ITALIC, 30));
   this.four.setFont(new Font("calibri", Font.ITALIC, 30));
   this.back.setFont(new Font("calibri", Font.ITALIC, 30));
   this.one.addMouseListener(this);
   this.two.addMouseListener(this);
   this.three.addMouseListener(this);
   this.four.addMouseListener(this);
   this.back.addMouseListener(this);
   this.back.setForeground(Color.red);
 }
Exemplo n.º 11
0
  @Override
  public void streamOpen() {
    if (isStreamOpen) {
      L.og("INTERNAL L ERROR: trying to re-open alreadyopen stream ");
      return;
    }

    logFrame = new JFrame("Logging Window");
    logArea = new JTextArea();
    logArea.setEditable(false);

    logFrame.setSize(width, height);
    logFrame.setResizable(false);
    logFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    JScrollPane logAreaScroller = new JScrollPane(logArea);
    logAreaScroller.setSize(logFrame.getSize());
    logAreaScroller.setPreferredSize(
        new Dimension((logFrame.getWidth() * 3) / 4, (logFrame.getHeight() * 3) / 4));

    logPanel.add(logAreaScroller);
    logFrame.getContentPane().add(logPanel);

    logFrame.setVisible(true);

    isStreamOpen = true;
  }
  public SimpleDialog(JFrame parent, String title, String message) {
    // Set default settings
    super(parent, title, true);

    if (parent != null) {
      Dimension parentSize = parent.getSize();
      Point p = parent.getLocation();
      setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
    }

    // The message is the contentPane
    JPanel messagePane = new JPanel();
    messagePane.add(new JLabel(message));
    getContentPane().add(messagePane);
    JPanel buttonPane = new JPanel();

    // Add an "OK" button
    JButton button = new JButton("OK");
    buttonPane.add(button);

    // Adding a listener to make the dialog box close when the "OK" button is clicked
    button.addActionListener(this);
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    pack();

    // Make the dialog box visible
    setVisible(true);
  }
Exemplo n.º 13
0
  /**
   * Constructor for FontDialog
   *
   * @param parent the parent frame needed by all dialogs
   * @param text the text we want to set.
   */
  public FontDialog(JFrame parent) {
    super(parent, "Font", true);

    effect_ = DrawSWFFont.NO_EFFECT;
    effect_buttons_ = new JRadioButton[3];
    draw_font_ = null;
    self_ = this;

    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    getContentPane().add(createFontSelection());
    getContentPane().add(createFontEffects());
    getContentPane().add(createColorChoice());
    getContentPane().add(Box.createVerticalStrut(5));
    getContentPane().add(createTextField());
    getContentPane().add(createButtons());

    updatePreview();

    pack();
    Dimension d1 = getSize();
    Dimension d2 = parent.getSize();
    int x = Math.max((d2.width - d1.width) / 2, 0);
    int y = Math.max((d2.height - d1.height) / 2, 0);
    setBounds(x, y, d1.width, d1.height);
  }
Exemplo n.º 14
0
 public DialogView(JFrame parent, String item, int position, String property) {
   super(parent, "Legend", true);
   this.addWindowListener(new CloseHandler());
   itemType = item;
   itemPosition = position;
   detailProperty = property;
   String message = "Which " + item + " would you like to replace?";
   messagePane.add(new JLabel(message));
   getContentPane().add(messagePane);
   buttonPane.add(buttonLeft, BorderLayout.WEST);
   buttonPane.add(buttonRight, BorderLayout.EAST);
   buttonLeft.addActionListener(this);
   buttonRight.addActionListener(this);
   getContentPane().add(buttonPane, BorderLayout.SOUTH);
   setDefaultCloseOperation(DISPOSE_ON_CLOSE);
   pack();
   if (parent != null) {
     Dimension parentSize = parent.getSize();
     Dimension dialogSize = this.getSize();
     Point p = parent.getLocation();
     setLocation(
         p.x + parentSize.width / 2 - dialogSize.width / 2,
         p.y + parentSize.height / 2 - dialogSize.height / 2);
   }
   setTitle("Legend");
   setVisible(true);
 }
  public void run() {
    // set the icon image and layout manager of the rootPane
    f.setIconImage(Program.windowIcon);
    f.setLayout(new BorderLayout());

    // set component borders
    mainBox.setBorder(new EmptyBorder(new Insets(5, 10, 10, 5)));

    // set component alignment
    rawEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    gapEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    huffEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    vbEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    mainBox.add(rawEncLabel);
    mainBox.add(gapEncLabel);
    mainBox.add(vbEncLabel);
    mainBox.add(huffEncLabel);

    f.add(mainBox, BorderLayout.CENTER);

    // final setup and show of the window
    f.pack();
    f.setSize(250, f.getSize().height);
    f.setLocationByPlatform(true);
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.setVisible(true);
  }
Exemplo n.º 16
0
 public static void centraliza(JFrame frame) {
   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   Dimension frameSize = frame.getSize();
   if (frameSize.height > screenSize.height) frameSize.height = screenSize.height;
   if (frameSize.width > screenSize.width) frameSize.width = screenSize.width;
   frame.setLocation(
       (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
 }
  public FrameRenderer(final JFrame target, boolean isFullscreen, RenderFitMode renderFitMode) {
    m_renderTarget = target;
    m_renderFitMode = renderFitMode;

    m_renderTarget.setSize(target.getSize());

    m_canvasRenderWidth = target.getWidth();
    m_canvasRenderHeight = target.getHeight();

    target.setIgnoreRepaint(true);
    target.createBufferStrategy(2);
    m_bufferStrategy = target.getBufferStrategy();

    BufferCapabilities cap = m_bufferStrategy.getCapabilities();

    if (!cap.getBackBufferCapabilities().isAccelerated())
      m_logger.warn("Backbuffer is not accelerated, may result in poorer render performance.");

    if (!cap.isPageFlipping())
      m_logger.warn(
          "Page flipping is not supported by this device. This may result in increased image flicker or tearing.");

    if (!cap.isMultiBufferAvailable())
      m_logger.warn(
          "Multiple buffering for page flipping is not supported by this device. This may result in poorer performance.");

    if (cap.isFullScreenRequired() && !isFullscreen)
      m_logger.warn(
          "Full screen required for hardware acceleration - not running in fullscreen may cause performance issues.");

    if (isFullscreen) {
      enterFullscreen();

      target.addKeyListener(
          new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {}

            @Override
            public void keyReleased(KeyEvent e) {}

            @Override
            public void keyPressed(KeyEvent e) {
              if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                GraphicsDevice device = target.getGraphicsConfiguration().getDevice();

                Window fullscreen = device.getFullScreenWindow();

                if (fullscreen != target) fullscreen = null;

                if (fullscreen == null) enterFullscreen();
                else exitFullscreen();
              }
            }
          });
    }
  }
Exemplo n.º 18
0
 private void initMainFrame() {
   mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   mainFrame.setSize(WIDTH, HEIGHT);
   Toolkit toolkit = Toolkit.getDefaultToolkit();
   Dimension d = toolkit.getScreenSize();
   mainFrame.setLocation(
       (int) (d.getWidth() - mainFrame.getSize().getWidth()) / 2,
       (int) (d.getHeight() - mainFrame.getSize().getHeight()) / 2);
   mainFrame.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosed(WindowEvent e) {
           if (executor != null) {
             executor.shutdown();
           }
         }
       });
 }
Exemplo n.º 19
0
 public static void setPosition(javax.swing.JFrame dialog) {
   Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
   // calculate the new location of the window
   int w = dialog.getSize().width;
   int h = dialog.getSize().height;
   int x = (dim.width - w) / 2;
   int y = (dim.height - h) / 2;
   dialog.setLocation(x, y);
 }
Exemplo n.º 20
0
  public void setCenterToFrame(JFrame frame) {

    Xpos = frame.getSize().width / 10 + 1;
    loopImage2.setVisible(false);
    loopImage3.setVisible(false);

    Xpos2 = Xpos2 + loopImage2.getImgWidth();
    Xpos3 = Xpos3 - loopImage3.getImgWidth();
  }
Exemplo n.º 21
0
        public void run() {
          String command = inputTextArea.getText().trim();
          if (command == null || command.length() == 0) {
            JOptionPane.showMessageDialog(
                mainWindow, "Command window is empty", "Out of order", JOptionPane.WARNING_MESSAGE);
            return;
          }

          // make busy dialog same width as main window.
          Dimension dlgBounds = busyDialog.getSize();
          dlgBounds.width = mainWindow.getSize().width;
          busyDialog.setSize(dlgBounds);

          runButton.setEnabled(false);
          Configuration config = (Configuration) connectionsList.getSelectedItem();
          if (passwdPromptCheckBox.isSelected() || !config.hasPassword()) {
            String pass = getPassword("Connection password for " + config.getName());
            config.setPassword(pass);
          }
          resultsStatusBar.reset();
          busyDialog.setVisible(true);

          try {
            currentConnection = configManager.getConnection(config);

            SQLRunner.setVerbosity(Verbosity.QUIET);
            SQLRunner prog = new SQLRunner(currentConnection, null, "t");
            prog.setGUI(SQLRunnerGUI.this);
            if (mode != null) {
              prog.setOutputMode(mode);
            }
            prog.setOutputFile(out);

            // RUN THE SQL
            prog.runStatement(command);

            if (prog.isEscape()) {
              outputPanel.setSelectedIndex(0);
            }
            resultsStatusBar.showSuccess(); // If no exception thrown!
          } catch (Exception e) {
            resultsStatusBar.showFailure();
            eHandler.handleError(e);
          } finally {
            runButton.setEnabled(true);
            busyDialog.setVisible(false);
            try {
              // Nested try here is deliberate, not a big deal if this call crashes
              if (currentConnection != null) {
                currentConnection.close();
              }
            } catch (SQLException ex) {
              System.err.println("Warning: close caused " + ex);
            }
          }
        }
Exemplo n.º 22
0
 private void centerFrame() {
   GraphicsEnvironment screen = GraphicsEnvironment.getLocalGraphicsEnvironment();
   Dimension effectiveScreenSize = screen.getMaximumWindowBounds().getSize();
   Dimension frameSize = frame.getSize();
   Point preferredNW =
       new Point(
           (effectiveScreenSize.width - frameSize.width) / 2,
           (effectiveScreenSize.height - frameSize.height) / 2);
   frame.setLocation(preferredNW);
 }
Exemplo n.º 23
0
 /**
  * Creates a new JInternalFrame based on the contents of an existing JFrame
  *
  * @param f the JFrame that will be used to create the JInternalFrame
  * @param desktop the JDesktopPane that will receive the JInternalFrame, if null it only retunrs
  *     the internal frame
  * @return a new JInternalFrame
  */
 public JInternalFrame transformToInternalFrame(JFrame f, JDesktopPane desktop) {
   JInternalFrame jif = new JInternalFrame(f.getTitle(), true, true, true, true);
   if (f.getIconImage() != null) jif.setFrameIcon(new ImageIcon(f.getIconImage()));
   if (desktop != null) desktop.add(jif);
   jif.setSize(f.getSize());
   jif.setContentPane(f.getContentPane());
   if (desktop != null) SwingUtilities.convertPointFromScreen(f.getLocation(), desktop);
   jif.setLocation(new Point(0, 0));
   jif.setBounds(f.getBounds());
   f.dispose();
   jif.setVisible(true);
   return (jif);
 }
Exemplo n.º 24
0
  public static void Center(JFrame frame) {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }

    frame.setLocation(
        (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    frame.show();
  }
Exemplo n.º 25
0
 public FramePrefsHandler(JFrame frame) {
   this.frame = frame;
   frame.pack(); // makes the frame displayable, so that maximizing works
   frame.setMinimumSize(frame.getSize());
   frame.setMaximizedBounds(
       GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
   frame.setBounds(Util.stringToRectangle(PREFS.get("WINDOW_BOUNDS", null), frame.getBounds()));
   int state =
       frame.getExtendedState()
           | (PREFS.getBoolean("WINDOW_MAXIMIZED", true) ? JFrame.MAXIMIZED_BOTH : 0);
   frame.setExtendedState(state);
   frame.addComponentListener(this);
   frame.addWindowStateListener(this);
 }
Exemplo n.º 26
0
 public static void lockInMinSize(final JFrame frame) {
   // Ensures user cannot resize frame to be smaller than frame is right now.
   final int origX = frame.getSize().width;
   final int origY = frame.getSize().height;
   // frame.setSize(new Dimension(origX, origY));
   frame.addComponentListener(
       new java.awt.event.ComponentAdapter() {
         @Override
         public void componentResized(ComponentEvent event) {
           frame.setSize(Math.max(frame.getWidth(), origX), Math.max(frame.getHeight(), origY));
           frame.repaint();
         }
       });
 }
Exemplo n.º 27
0
  private void storeConfig() {
    Configuration.Graphics graphics = config.graphics;
    Point location = frame.getLocation();
    Dimension size = frame.getSize();
    int state = frame.getState();

    graphics.frameX = location.x;
    graphics.frameY = location.y;
    graphics.frameWidth = size.width;
    graphics.frameHeight = size.height;
    graphics.centerFrame = false;
    graphics.isMaximized = (state & Frame.MAXIMIZED_BOTH) > 0;

    config.write();
  }
Exemplo n.º 28
0
  /** Sets the location on the given dialog for the given index. */
  private void setLocation(JDialog dialog, int index) {
    Rectangle bounds = dialog.getBounds();
    JFrame frame = findOwner();
    Dimension dim;
    if (frame == null) {
      dim = Toolkit.getDefaultToolkit().getScreenSize();
    } else {
      dim = frame.getSize();
    }

    int x = (int) (150 * Math.cos(index * 15 * (Math.PI / 180)));
    int y = (int) (150 * Math.sin(index * 15 * (Math.PI / 180)));
    x += (dim.width - bounds.width) / 2;
    y += (dim.height - bounds.height) / 2;
    dialog.setLocation(x, y);
  }
Exemplo n.º 29
0
  public static void main(String[] args) {

    frame = new JFrame("Arkanoid");
    frame.setSize(1000, 700);
    // frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    game = new Game(frame, 8, 3);
    game.setSize(frame.getSize());
    frame.add(game);

    //		bat = new Bat();
    //		frame.add(bat);
    //		frame.repaint();

    frame.setVisible(true);
  }
  public LaberintoEdd() {
    logger.info("Lanzando aplicacion de laberinto para estructura de datos");

    JFrame frame = new VentanaLaberinto();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }
    frame.setLocation(
        (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }