Esempio n. 1
0
  public Group4_GameStart() {

    JFrame newframe = new JFrame("Rebirth of Legends");

    JPanel ha = new JPanel();

    ngButton = new JButton("New Game");
    cgButton = new JButton("Continue");
    oButton = new JButton("Options");
    la = new JLabel("No Button Clicked!");

    ha.add(ngButton);
    ha.add(cgButton);
    ha.add(oButton);
    ha.add(la);

    ngButton.addActionListener(new action());
    oButton.addActionListener(new Test());
    cgButton.addActionListener(new Test());

    newframe.add(ha, BorderLayout.CENTER);
    newframe.add(la, BorderLayout.NORTH);
    newframe.setSize(600, 400);
    newframe.setVisible(true);
    newframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Esempio n. 2
0
  public void newframe() {
    JFrame frame = new JFrame("Cab Service ");
    frame.setSize(800, 600);

    frame.setVisible(true);
    // frame.setBackground(Color.CYAN);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton jb = new JButton("Set Name of Places ");
    jb.setBounds(100, 100, 20, 50);

    JPanel jp = new JPanel();
    jp.setBackground(Color.gray);
    jp.add(jb);
    frame.add(jp);
    JPanel jp1 = new JPanel();
    jp1.setBackground(Color.gray);
    frame.add(jp1);

    frame.add(jp);
    jb.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            try {
              CreateFrame();

            } catch (IOException ex) {
              Logger.getLogger(SetMap.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });
  }
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
Esempio n. 4
0
  private void create() {
    JFrame f = new JFrame("JSplitPane");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    MyPanel p1 = new MyPanel(Color.red);
    MyPanel p2 = new MyPanel(Color.blue);
    final JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, p1, p2);
    Timer timer =
        new Timer(
            200,
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                ratio += delta;
                if (ratio >= 1.0) {
                  ratio = 1.0;
                  delta = -delta;
                } else if (ratio <= 0) {
                  delta = -delta;
                  ratio = 0;
                }
                jsp.setDividerLocation(ratio);
              }
            });

    f.add(jsp);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    timer.start();
  }
Esempio n. 5
0
  /**
   * Constructs a new game.
   *
   * @param web <code>true</code> if this game is meant to be an applet (which can be played
   *     online), and <code>false</code> otherwise. Note: this doesn't work yet.
   */
  public Game() {
    Game.applet = false;
    canvas = new Canvas(this);
    solidShapes = Collections.newSetFromMap(new ConcurrentHashMap<Shape, Boolean>());
    allShapes = Collections.newSetFromMap(new ConcurrentHashMap<Shape, Boolean>());

    // TODO: sort out which data structures actually have to support concurrency
    layerContents = new ConcurrentHashMap<Integer, java.util.List<Shape>>();
    layers = new CopyOnWriteArrayList<Integer>();
    layerOf = new ConcurrentHashMap<Shape, Integer>();

    counters = new ArrayList<Counter>();

    Mouse mouse = new Mouse();
    if (applet) {
      addMouseMotionListener(mouse);
      addMouseListener(mouse);
      addKeyListener(new Keyboard());
    } else {
      frame = new JFrame();
      frame.addMouseMotionListener(mouse);
      frame.addMouseListener(mouse);
      frame.addKeyListener(new Keyboard());
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    setDefaults();
  }
Esempio n. 6
0
 public static void main(String[] args) {
   JFrame gameWindow = new JFrame("Tic Tac Toe");
   gameWindow.add(new TicTacToeGame());
   gameWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   gameWindow.pack();
   gameWindow.setVisible(true);
 }
Esempio n. 7
0
 public static void panelInit() {
   JFrame frame = new JFrame("Test");
   frame.setContentPane(new Test().mainPanel);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
Esempio n. 8
0
  void makeFrame() {
    JPanel p = new JPanel();
    p.setBackground(Color.blue);
    p.setLayout(new BorderLayout(0, 0));
    p.setBorder(new EmptyBorder(0, GAP, GAP, GAP));
    days.setFont(BIG);
    days.setForeground(COLOR);
    p.add(days, "North");
    left.setFont(NORM);
    left.setForeground(COLOR);
    p.add(left, "South");

    JFrame f = new JFrame("Sayaç"); // a window
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.setContentPane(p);
    setDate();
    f.pack(); // minimal size
    f.setVisible(true); // show

    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            stop();
          }
        });
  }
Esempio n. 9
0
  /** Displays the character window */
  public void characterWindow() {
    if (characterWindow != null) {
      characterWindow.dispose();
    }
    characterWindow = new JFrame("Character");
    characterWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    JTextField health = new JTextField(player.health());
    health.setEditable(false);

    JButton weapon = new JButton(player.weapon().split(" ")[1]);
    if (player.weapon().split(" ")[1].equals("none")) {
      weapon.setEnabled(false);
    }
    weapon.addActionListener(this);

    JButton armor = new JButton(player.armor().split(" ")[1]);
    if (player.armor().split(" ")[1].equals("none")) {
      armor.setEnabled(false);
    }
    armor.addActionListener(this);

    characterWindow.setBounds(
        mainWindow.getX() + mainWindow.getWidth(), mainWindow.getY(), 200, 150);
    characterWindow.setResizable(false);
    characterWindow.setLayout(new GridLayout(3, 1));
    characterWindow.add(health);
    characterWindow.add(weapon);
    characterWindow.add(armor);

    characterWindow.setVisible(true);
  }
Esempio n. 10
0
 public void start() {
   JFrame frame = new JFrame("All panel");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.add(new AllPanels());
   frame.pack();
   frame.setVisible(true);
 }
Esempio n. 11
0
  public SchiebePuzzle() {
    JFrame jF = new JFrame("Misc_2015/SchiebePuzzle");
    jF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jF.setLayout(new GridLayout(YY, XX)); // ggf zu ändern
    try {
      BufferedImage fuYou = ImageIO.read(new File("fuYou.jpg"));
      int w = fuYou.getWidth();
      int h = fuYou.getHeight();
      for (int y = 0; y < YY; y++)
        for (int x = 0; x < XX; x++) {
          buttons[y][x] =
              new PuzzButton(
                  new ImageIcon(fuYou.getSubimage(x * (w / XX), y * (h / YY), w / XX, h / YY)));

          buttons[y][x].setBorder(new LineBorder(Color.BLACK, 1));
          buttons[y][x].setActionCommand("" + x + y);
          buttons[y][x].setName("" + x + y);
          buttons[y][x].setPosY(y);
          buttons[y][x].setPosX(x);
          buttons[y][x].addActionListener(this);
          jF.add(buttons[y][x]);
        }

    } catch (IOException e) {
      System.out.println("Bild nicht gefunden!");
    }

    jF.pack();
    jF.setVisible(true);
  }
Esempio n. 12
0
 public void setUpGui() {
   m1 = new MyDrawPanel();
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.setContentPane(m1);
   f.setBounds(30, 30, 300, 300);
   f.setVisible(true);
 } // quit meth
Esempio n. 13
0
  public static void main(String[] args) {
    Toolkit theKit = aWindow.getToolkit(); // Get the window Toolkit
    Dimension wndSize = theKit.getScreenSize(); // Get the screen size

    // Set the position to screen center & size to half screen size
    aWindow.setBounds(
        wndSize.width / 4,
        wndSize.height / 4, // Position
        wndSize.width / 2,
        wndSize.height / 2); // Size
    aWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    GridLayout grid = new GridLayout(5, 2, 30, 20); // Create a layout manager
    Container content = aWindow.getContentPane();
    content.setLayout(grid);

    EtchedBorder edge = new EtchedBorder(EtchedBorder.RAISED); // Button border

    // Now add ten Button compenents
    JButton button;
    for (int i = 1; i <= 10; i++) {
      content.add(button = new JButton("Press " + i));
      button.setBorder(edge);
    }

    aWindow.getContentPane().setBackground(new Color(238, 233, 233));
    aWindow.setVisible(true);
  }
Esempio n. 14
0
  public void go() throws IOException {
    // DefaultRouteTable route = new DefaultRouteTable();
    // System.out.println(route.routeInfo());
    // route.routeInfo();
    totalSize = Toolkit.getDefaultToolkit().getScreenSize(); // getting screen size
    int width = totalSize.width;
    int height = totalSize.height;
    frame = new JFrame(); // creating frame
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            FileInput data = null;
            try {
              data = new FileInput("input.txt");
            } catch (Exception e) {

            }
            String[][] origRoutes =
                convertArrayListTo2DArray(data.routeArrayList(data.routesToken), 1);
            String[][] routesList = Main.convertArrayListTo2DArray(routesInfo, 1);
            Main.changesCheck(origRoutes, routesList);
          }
        });
    frame.setTitle("Air Route Planner");
    frame.add(Panels());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize((width * 3 / 4), (height * 3 / 4));
    frame.setJMenuBar(menuBar());
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
  }
 public static void main(String[] args) {
   JFrame win = new JFrame("MouseMotionEvents");
   win.setSize(1024, 768);
   win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   win.add(new MouseMotionEvents());
   win.setVisible(true);
 }
Esempio n. 16
0
 /** Displays the inventory window */
 public void inventoryWindow() {
   if (inventoryWin != null) {
     inventoryWin.dispose();
   }
   inventoryWin = new JFrame("Inventory");
   inventoryWin.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   Inventory inv = player.getInventory();
   int y = inv.getSize();
   if (y == 0) {
     displayMessage("Inventory is empty");
     return;
   }
   int cols = 2;
   int rows = (y - y % cols) / cols;
   if (y % cols != 0) rows = rows + 1;
   inventoryWin.setLayout(new GridLayout(0, cols * 2));
   for (int i = 0; i < y; i++) {
     JButton b = new JButton(inv.getItem(i).getName());
     inventoryWin.add(b);
     b.addActionListener(this);
     JButton d = new JButton("drop " + inv.getItem(i).getName());
     inventoryWin.add(d);
     d.addActionListener(this);
   }
   // inventoryWin.setBounds(350, 0, 300, 80*rows);
   inventoryWin.setLocation(mainWindow.getX(), mainWindow.getY() + mainWindow.getHeight());
   inventoryWin.pack();
   inventoryWin.setVisible(true);
 }
Esempio n. 17
0
 public RemoveFrame() {
   frame = new JFrame("Select Files you wish to Remove from Drive");
   frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   frame.getRootPane().setDefaultButton(confirm);
   try {
     files = DriveList.list();
   } catch (IOException e) {
     files = new ArrayList<File>();
   }
   confirm = new JButton("Remove");
   quit = new JButton("Cancel");
   confirm.addActionListener(this);
   quit.addActionListener(this);
   frame.setLayout(new BorderLayout());
   checkPanel = new JPanel();
   control = new JPanel();
   control.setLayout(new GridLayout(1, 2));
   control.add(confirm);
   control.add(quit);
   frame.add(control, BorderLayout.SOUTH);
   drawCheckPanel();
   frame.add(checkPanel, BorderLayout.CENTER);
   frame.pack();
   frame.setVisible(true);
 }
Esempio n. 18
0
  public static void main(final String[] args)
      throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException,
          IllegalAccessException {
    // Create a frame
    final JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setSize(550, 300);

    // Create a flow layout panel
    final JPanel panel = new JPanel();
    frame.getContentPane().add(panel);

    // Change the component defaults before instantiating
    ComponentFormatDefaults defaults = ComponentFormatDefaults.getInstance();

    defaults.setFormat(
        ComponentFormatDefaults.Key.TODAY_SELECTOR, new SimpleDateFormat("EEE dd MMM yy"));
    defaults.setFormat(ComponentFormatDefaults.Key.DOW_HEADER, new SimpleDateFormat("EEEE"));
    defaults.setFormat(
        ComponentFormatDefaults.Key.SELECTED_DATE_FIELD, new SimpleDateFormat("MM.dd.yy"));
    defaults.setFormat(ComponentFormatDefaults.Key.MONTH_SELECTOR, new SimpleDateFormat("MMM"));

    // Create the JDatePanel
    final JDatePanel datePanel = new JDatePanel(Calendar.getInstance());
    panel.add(datePanel);

    // Create the JDatePicker
    final JDatePicker datePicker = new JDatePicker(Calendar.getInstance());
    datePicker.setTextEditable(true);
    panel.add(datePicker);

    // Make the frame visible
    frame.setVisible(true);
  }
  public static void main(String[] args) {
    ArrayList<Pattern> patterns = new ArrayList<Pattern>();
    ArrayList<Cut> cuts;
    ArrayList<Garment> garments;

    patterns.add(new Pattern(2, 2, 1, "Tie"));
    patterns.add(new Pattern(2, 6, 4, "Skirt"));
    patterns.add(new Pattern(4, 2, 3, "Blouse"));
    patterns.add(new Pattern(5, 3, 5, "Dress"));
    int width = 30;
    int height = 15;
    ClothCutter cutter = new ClothCutter(width, height, patterns);
    System.out.println("Optimized value: " + cutter.optimize());
    cuts = cutter.getCuts();
    garments = cutter.getGarments();

    ClothPanel panel = new ClothPanel(width, height);
    JFrame frame = new JFrame("A luxurious bolt of fabric");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
    sleep(1000);
    for (int i = 0; i < cuts.size(); i++) {
      panel.drawCut(cuts.get(i));
      sleep(100);
    }
    for (int i = 0; i < garments.size(); i++) {
      System.out.println(garments.get(i));
      panel.drawGarment(garments.get(i));
      sleep(100);
    }
  }
Esempio n. 20
0
  /**
   * 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);
  }
Esempio n. 21
0
  /** *********************************************************************** */
  private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true); // give JFrame nice decorations
    JFrame frame = new JFrame("Java GUI"); // create the JFrame
    frame.setDefaultCloseOperation(
        JFrame.EXIT_ON_CLOSE); // set up the JFrame to end the program when it closes
    Container c = frame.getContentPane();
    c.setLayout(new BorderLayout());

    ColorBars drawingPanel = new ColorBars(); // set up the panel to draw in
    drawingPanel.setBackground(Color.BLACK); // the the background to black

    drawingPanel.btnDraw = new JButton("Click me"); // instantiate a swing button
    drawingPanel.btnDraw.addActionListener(drawingPanel); // register the panel with the button
    drawingPanel.btnClear = new JButton("Clear Screen");
    drawingPanel.btnClear.addActionListener(drawingPanel);

    Panel buttonPanel = new Panel(); // instantiate the panel for buttons
    buttonPanel.add(drawingPanel.btnDraw); // add the swing button the the button panel
    buttonPanel.add(drawingPanel.btnClear);

    c.add(
        drawingPanel,
        BorderLayout.CENTER); // add the drawing panel to the frame (take up the entire frame)
    c.add(buttonPanel, BorderLayout.SOUTH); // add the button panel to the bottom of the frame

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // set the window to maximized
    frame.setSize(600, 400); // set the frame size (in case user un-maximizes
    frame.setVisible(true); // display the frame
  }
Esempio n. 22
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Add");
    frame.setLocation(500, 400);
    //		frame.setPreferredSize(new Dimension(250, 100));
    Container contentPane = frame.getContentPane();

    FlowLayout layout = new FlowLayout();
    contentPane.setLayout(layout);
    JPanel panel = new JPanel();
    panel.add(new JTextField(6));
    panel.add(new JLabel("+"));
    panel.add(new JTextField(6));
    panel.add(new JLabel("="));
    panel.add(new JTextField(6));

    contentPane.add(panel, BorderLayout.CENTER);

    JPanel panel2 = new JPanel();
    panel2.add(new JButton("확인"));
    panel2.add(new JButton("취소"));
    contentPane.add(panel2, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
  public static void main(String[] args) {
    Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(800, 600);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    browser.setDownloadHandler(
        new DownloadHandler() {
          public boolean allowDownload(DownloadItem download) {
            download.addDownloadListener(
                new DownloadListener() {
                  public void onDownloadUpdated(DownloadEvent event) {
                    DownloadItem download = event.getDownloadItem();
                    if (download.isCompleted()) {
                      System.out.println("Download is completed!");
                    }
                  }
                });
            System.out.println(
                "Destination file: " + download.getDestinationFile().getAbsolutePath());
            return true;
          }
        });

    browser.loadURL("ftp://ftp.teamdev.com/updates/jxbrowser-4.0-beta.zip");
  }
Esempio n. 24
0
  public void makeInterface() {
    frame = new JFrame("俄罗斯方块多人对战");

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.setResizable(false);

    listModel = new DefaultListModel();
    listModel.ensureCapacity(100);

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    list.setSelectedIndex(0);

    JButton exitButton = new JButton("Disconnect/Exit");
    exitButton.setActionCommand("exit");
    exitButton.addActionListener(this);

    JScrollPane listScroller = new JScrollPane(list);
    listScroller.setPreferredSize(new Dimension(250, 125));

    frame.getContentPane().add(listScroller, BorderLayout.CENTER);
    frame.getContentPane().add(exitButton, BorderLayout.SOUTH);

    frame.pack();
    frame.setVisible(false);
  }
Esempio n. 25
0
 public static void main(String[] args) {
   JFrame frame = new JFrame("MainForm");
   frame.setContentPane(new MainForm().panel1);
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
Esempio n. 26
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Maze View");

    Random random = new Random();
    long startTime = System.nanoTime();
    MazeNode maze = MazeNode.generate(random, 100, 100);
    System.out.println("Gen : " + elapsedMs(startTime) + "ms");

    startTime = System.nanoTime();
    int sx = 0; // random.nextInt(maze.width);
    int sy = 0; // random.nextInt(maze.height);
    int dx = maze.width - 1; // random.nextInt(maze.width);
    int dy = maze.height - 1; // random.nextInt(maze.height);
    Path path = PathSolver.solve(maze, sx, sy, dx, dy);
    System.out.println("Solve : " + elapsedMs(startTime) + "ms");
    int pathSize = 0;
    PathCell pathIt = path.first;
    while (pathIt != null) {
      pathSize++;
      pathIt = pathIt.next;
    }
    System.out.println("Path Size: " + pathSize);

    frame.add(new JScrollPane(new MazeView(maze, sx, sy, dx, dy, path)));

    frame.setSize(500, 500);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    SwingUtilities.invokeLater(() -> frame.setVisible(true));
  }
Esempio n. 27
0
  public static void main(String[] args) {
    final Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);

    final JTextField addressBar = new JTextField("http://www.teamdev.com/jxbrowser");
    addressBar.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            browser.loadURL(addressBar.getText());
          }
        });

    JPanel addressPane = new JPanel(new BorderLayout());
    addressPane.add(new JLabel(" URL: "), BorderLayout.WEST);
    addressPane.add(addressBar, BorderLayout.CENTER);

    JFrame frame = new JFrame("JxBrowser - Hello World");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(addressPane, BorderLayout.NORTH);
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(800, 500);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    browser.loadURL(addressBar.getText());
  }
Esempio n. 28
0
  /** GUIコンポーネントを初期化する。 */
  public void initComponent() {

    frame = new JFrame(ClientContext.getFrameTitle(title));
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            stop();
          }
        });

    JPanel contentPane = createBrowsePane();
    contentPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));

    contentPane.setOpaque(true);
    frame.setContentPane(contentPane);
    frame.pack();

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int n = ClientContext.isMac() ? 3 : 2;
    int x = (screen.width - frame.getPreferredSize().width) / 2;
    int y = (screen.height - frame.getPreferredSize().height) / n;
    frame.setLocation(x, y);

    blockGlass = new BlockGlass();
    frame.setGlassPane(blockGlass);

    frame.setVisible(true);
  }
 public static void main(final String[] args) {
   JFrame frame = new JFrame("Credit calculator");
   frame.setContentPane(new HypothecCalculator().mainPanel);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }
Esempio n. 30
0
  private Game() {
    // Top-level frame
    final JFrame frame = new JFrame("Falling Blocks");
    frame.setLocation(200, 50);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Main playing area
    final TetrisCourt court = new TetrisCourt();
    frame.add(court, BorderLayout.CENTER);

    // Reset button
    final JPanel panel = new JPanel();
    frame.add(panel, BorderLayout.NORTH);
    final JButton reset = new JButton("Reset");
    reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            court.reset();
          }
        });

    panel.add(reset);

    // Put the frame on the screen
    frame.pack();
    frame.setVisible(true);
    // Start the game running
    court.reset();
  }