Пример #1
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());
  }
Пример #2
0
  public start() {

    MyModel lm = new MyModel();
    JList<Integer> jl = new JList<>(lm);
    JButton b = new JButton("ADD");
    b.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            lm.add(zahl++);
          }
        });

    JFrame jf = new JFrame("List Test");
    jf.setLayout(new BorderLayout());
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JScrollPane scrollen = new JScrollPane(jl);

    jf.add(b, BorderLayout.SOUTH);
    jf.add(scrollen, BorderLayout.NORTH);
    jf.setSize(300, 300);
    jf.setLocation(400, 500);
    jf.setVisible(true);
  }
Пример #3
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);
 }
Пример #4
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Reaction Timer");
    frame.setSize(280, 120);

    final TextField disp = new TextField();
    final JButton btn = new JButton("Go");

    btn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            u = System.currentTimeMillis();
            if (u - t < ONE_SECOND) {
              disp.setText("" + (u - t));
            }
            t = u;
          }
        });

    frame.setLayout(null);
    disp.setBounds(10, 10, 230, 20);
    frame.add(disp);
    btn.setBounds(10, 40, 210, 40);
    frame.add(btn);

    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
    frame.setResizable(false);
  }
  // -------------------------------------------------------------------
  public static void main(String[] args) {
    // Create the window
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(new Dimension(300, 100));
    frame.setTitle("A frame");
    frame.setLayout(new FlowLayout()); // This will be discuss in the next lesson

    // Create and add the first button
    JButton button1 = new JButton();
    button1.setText("I'm a button.");
    button1.setBackground(Color.BLUE);
    frame.add(button1);

    // Create and add the second button
    JButton button2 = new JButton();
    button2.setText("Click me!");
    button2.setBackground(Color.RED);
    frame.add(button2);

    // Reset the sizes of the buttons and window
    frame.pack();

    // Actually put the window on the screen and draw all its components
    frame.setVisible(true);
  }
  @Override
  public void display(HashBasedTable<String, String, Double> data) {

    roomToCodeMapping = generateNewRoomToCodeMapping();
    dataSet = createDataSet(data);
    final JFreeChart chart = createChart(dataSet);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(1000, 540));
    createNewFrameAndSetLocation();
    currentFrame.setTitle(this.getTitle());
    currentFrame.setContentPane(chartPanel);
    currentFrame.setVisible(true);
    currentFrame.setSize(new Dimension(1020, 560));
    currentFrame.addWindowListener(this);

    if (type == MarkovDataDialog.HeatMapType.COMPARISON) {
      unscaledDifferenceSlider.setLabelTable(unscaledDifferenceSlider.createStandardLabels(5, 5));
      differenceSelectorFrame = new JFrame("Choose Size of difference");
      differenceSelectorFrame.setLayout(new BorderLayout());
      differenceSelectorFrame.add(unscaledDifferenceSlider, BorderLayout.NORTH);

      statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
      statusLabel.setText("Current difference size:" + this.unscaledDifference);

      differenceSelectorFrame.add(statusLabel, BorderLayout.CENTER);

      differenceSelectorFrame.add(regenerate, BorderLayout.SOUTH);

      regenerate.addActionListener(this);

      differenceSelectorFrame.setLocation(100, 10);
      differenceSelectorFrame.setSize(300, 200);
      differenceSelectorFrame.setVisible(true);
    }
  }
  public void go() {
    picture();
    ActionListener listener = new BtListener();
    go.addActionListener(listener);
    btn_update_manual.addActionListener(listener);
    go.setForeground(Color.black);
    // rights.setFont((new Font("Arial", Font.PLAIN, 12)));
    title.setFont((new Font("Arial", Font.BOLD, 36)));
    title.setForeground(new Color(238, 253, 253));
    today.setFont((new Font("Arial", Font.BOLD, 16)));
    today.setForeground(new Color(163, 184, 204));
    frame.setLayout(new BorderLayout());
    from.setBackground(Color.white);
    to.setBackground(Color.white);
    converted.setFont(new Font("Arial", Font.BOLD, 24));
    converted.setForeground(new Color(238, 253, 253));
    Lfrom.setForeground(new Color(238, 253, 253));
    Lto.setForeground(new Color(238, 253, 253));
    quantity.setForeground(new Color(238, 253, 253));
    Lfrom.setFont(new Font("Arial", Font.BOLD, 24));
    Lto.setFont(new Font("Arial", Font.BOLD, 24));
    quantity.setFont(new Font("Arial", Font.BOLD, 24));
    north.setLayout(new FlowLayout());
    north.add(title);
    north.setBackground(new Color(59, 62, 71));
    frame.add(BorderLayout.NORTH, north);
    inner.setLayout(new BorderLayout());
    inner.add(BorderLayout.NORTH, today);
    inner.add(BorderLayout.WEST, picPanel);
    center.setLayout(new GridLayout(2, 4, 5, 5));
    center.add(Lfrom);
    center.add(from);
    center.add(Lto);
    center.add(to);
    center.add(quantity);
    center.add(amount);
    center.add(go);
    inner.setBackground(new Color(59, 62, 71));
    inner.add(BorderLayout.SOUTH, center);
    center.setBackground(new Color(59, 62, 71));
    frame.add(BorderLayout.CENTER, inner);
    south.setBackground(new Color(59, 62, 71));
    south.setLayout(new FlowLayout());
    south.add(converted);
    south.add(answer);
    south.add(btn_update_manual);
    // south.add(rights);
    frame.add(BorderLayout.SOUTH, south);
    frame.setSize(850, 700);
    frame.setVisible(true);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent event) {
            frame.setVisible(false);
            frame.dispose();
            System.exit(0);
          }
        });
  }
Пример #8
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();
  }
Пример #9
0
 public void init() {
   // 向内部窗口中添加组件
   iframe.add(new JScrollPane(new JTextArea(8, 40)));
   desktop.setPreferredSize(new Dimension(400, 300));
   // 把虚拟桌面添加到JFrame窗口中
   jf.add(desktop);
   // 设置内部窗口的大小、位置
   iframe.reshape(0, 0, 300, 200);
   // 显示并选中内部窗口
   iframe.show();
   desktop.add(iframe);
   JPanel jp = new JPanel();
   deskBn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 弹出内部对话框,以虚拟桌面作为父组件
           JOptionPane.showInternalMessageDialog(desktop, "属于虚拟桌面的对话框");
         }
       });
   internalBn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 弹出内部对话框,以内部窗口作为父组件
           JOptionPane.showInternalMessageDialog(iframe, "属于内部窗口的对话框");
         }
       });
   jp.add(deskBn);
   jp.add(internalBn);
   jf.add(jp, BorderLayout.SOUTH);
   jf.pack();
   jf.setVisible(true);
 }
Пример #10
0
  public static void main(String args[]) {
    File[] IFCFiles = new File("D:\\Data\\Emiel\\CreateTable\\IFC").listFiles();
    File[] XMLFiles = new File("D:\\Data\\Emiel\\CreateTable\\XML").listFiles();
    Object[] col = new Object[IFCFiles.length + 1];
    Object[][] dat = new Object[XMLFiles.length][IFCFiles.length + 1];
    col[0] = " ";
    for (int j = 0; j < IFCFiles.length; j++) {
      col[j + 1] = IFCFiles[j].getName();

      for (int i = 0; i < XMLFiles.length; i++) {
        File[] BCFFiles =
            new File(
                    "D:\\Data\\Emiel\\CreateTable\\Results\\"
                        + IFCFiles[j].getName()
                        + "\\"
                        + XMLFiles[i].getName())
                .listFiles();
        System.out.println(BCFFiles.length);

        dat[i][0] = XMLFiles[i].getName();
        dat[i][j + 1] = BCFFiles.length;
      }
    }

    JFrame frame = new JFrame("MVD Checker");
    JTable table = new JTable(dat, col);
    frame.setVisible(true);
    frame.setBounds(0, 0, 500, 500);
    frame.add(table.getTableHeader(), BorderLayout.PAGE_START);
    frame.add(table);
  }
Пример #11
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);
            }
          }
        });
  }
Пример #12
0
 Main() {
   f = new JFrame("Wiki Seach");
   JPanel p = new JPanel();
   JPanel p1 = new JPanel();
   b = new JButton("Search");
   b1 = new JButton("Exit");
   t = new JTextField(30);
   b.addActionListener(this);
   b1.addActionListener(this);
   p1.add(b);
   p1.add(b1);
   p.add(t);
   f.setLayout(new GridLayout(2, 1));
   f.add(p);
   f.add(p1);
   f.pack();
   f.setLocationRelativeTo(null);
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setVisible(true);
 }
Пример #13
0
  public GuiYahtzee() {
    final Match m = new Match();
    final JFrame f = new JFrame();
    JPanel titles = new JPanel();
    JPanel cheatok = new JPanel();

    titles.setLayout(new BorderLayout());
    JLabel maintitle = new JLabel("Yahtzee World!\nPlayer Details...");
    maintitle.setFont(new Font("SansSerif", Font.ITALIC, 24));
    JLabel instr =
        new JLabel("Type the name of each player (1 to " + Match.MAXPLAYERS + " players)");
    instr.setFont(new Font("SansSerif", Font.PLAIN, 16));
    titles.add(maintitle, "North");
    titles.add(instr, "South");

    JPanel names = new JPanel();
    JLabel l[] = new JLabel[Match.MAXPLAYERS];
    final JTextField t[] = new JTextField[Match.MAXPLAYERS];
    names.setLayout(new GridLayout(Match.MAXPLAYERS, 2));
    for (int player = 0; player < Match.MAXPLAYERS; player++) {
      l[player] = new JLabel("Player " + (player + 1) + " name");
      t[player] = new JTextField(20);
      names.add(l[player]);
      names.add(t[player]);
    }

    cheatok.setLayout(new BorderLayout());
    final JCheckBox cheat = new JCheckBox("Cheat", false);
    JButton ok = new JButton("OK");
    ok.addActionListener(
        new ActionListener() {
          // This method is called when the user clicks the JButton
          public void actionPerformed(ActionEvent e) {
            String name = "";
            for (int player = 0; player < Match.MAXPLAYERS; player++) {
              name = t[player].getText();
              if (name.length() != 0) m.addPlayer(name);
            }
            if (m.getNumPlayers() == 0) {
              m.addPlayer("DUMMY");
              System.out.println("No named players.  Inventing one called `DUMMY'");
            }
            GuiYahtzee me = new GuiYahtzee(m, cheat.isSelected());
            f.dispose();
          }
        });
    cheatok.add(cheat, "West");
    cheatok.add(ok, "East");

    f.add(titles, "North");
    f.add(names, "Center");
    f.add(cheatok, "South");
    f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
    f.setResizable(false);
  }
Пример #14
0
 public static void main(String[] args) {
   Plot2D test = new Plot2D();
   JFrame f = new JFrame();
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.add(test.getContent());
   f.add(test.getUIPanel(), "Last");
   f.setSize(400, 400);
   f.setLocation(50, 50);
   f.setVisible(true);
 }
Пример #15
0
 public void toSendWindow() {
   toWindow = new JFrame("Send Email To");
   toWindow.setLayout(new BorderLayout());
   contactList = new ContactListCheckBox(cList);
   toWindow.add(contactList, BorderLayout.CENTER);
   toWindow.add(addSendContacts, BorderLayout.SOUTH);
   toWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   toWindow.pack();
   toWindow.setVisible(true);
 }
Пример #16
0
  public JFrame buildFrame() {

    f = new JFrame("AMSA World");
    f.setSize(800, 600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new GridBagLayout());

    textArea.setFocusable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            checkInput();
          }
        };
    inputText.addActionListener(listener);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1.0;
    c.gridwidth = 3;
    c.weighty = 0.025;
    c.gridx = 0;
    c.gridy = 0;
    f.add(topPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 2;
    c.gridx = 0;
    c.gridy = 1;
    f.add(scrollPane, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 1;
    f.add(sidePanel, c);
    sidePanel.setVisible(false);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.025;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy = 2;
    f.add(inputText, c);

    f.setVisible(true);

    return f;
  }
Пример #17
0
 public void removeContactWindow() {
   removeWindow = new JFrame("Remove Contacts");
   removeWindow.setLayout(new BorderLayout());
   contactList = new ContactListCheckBox(cList);
   removeWindow.add(contactList, BorderLayout.CENTER);
   // Add List here
   removeWindow.add(deleteContact, BorderLayout.SOUTH);
   removeWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   removeWindow.pack();
   removeWindow.setVisible(true);
 }
Пример #18
0
  private void final_scores(Match m) {
    int numPlayers = 0;
    int playerTotal = 0;
    int gameNum = 0, maxGameNum = 0;
    Player p;

    // Create window
    final JFrame f = new JFrame();
    JPanel titles = new JPanel();
    titles.setLayout(new BorderLayout());
    JLabel maintitle = new JLabel("Yahtzee World!");
    maintitle.setFont(new Font("SansSerif", Font.ITALIC, 24));
    JLabel instr = new JLabel("Final Scores (total of game scores).");
    instr.setFont(new Font("SansSerif", Font.PLAIN, 16));
    titles.add(maintitle, "North");
    titles.add(instr, "South");

    JPanel names = new JPanel();
    JLabel l[] = new JLabel[Match.MAXPLAYERS];
    final JTextField t[] = new JTextField[Match.MAXPLAYERS];

    numPlayers = m.getNumPlayers();
    names.setLayout(new GridLayout(numPlayers, 2));
    for (int playerNum = 0; playerNum < numPlayers; playerNum++) {
      p = m.getPlayer(playerNum);
      playerTotal = 0;
      l[playerNum] = new JLabel(p.getName());
      t[playerNum] = new JTextField(20);
      names.add(l[playerNum]);
      names.add(t[playerNum]);
      maxGameNum = (m.getGameNum() >= Match.MAXGAMES) ? (Match.MAXGAMES - 1) : m.getGameNum();
      for (gameNum = 0; gameNum <= maxGameNum; gameNum++) {
        playerTotal += p.getScoreCell(gameNum, CellCodes.GRANDTOTAL);
      }
      t[playerNum].setText(String.valueOf(playerTotal));
    }

    JButton quit = new JButton("Quit");
    quit.addActionListener(
        new ActionListener() {
          // This method is called when the user clicks the JButton
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    f.add(titles, "North");
    f.add(names, "Center");
    f.add(quit, "South");
    f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
    f.setResizable(false);
  }
Пример #19
0
 public DialTest() {
   Debug.println("DialTest()");
   JFrame jf = new JFrame("Dial Test");
   jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   JComponent jc1 = new MVCCoordinator().getView1();
   jf.add(jc1, BorderLayout.WEST);
   JComponent jc2 = new MVCCoordinator().getView2();
   jf.add(jc2, BorderLayout.SOUTH);
   JComponent jc3 = new MVCCoordinator().getView3();
   jf.add(jc3, BorderLayout.CENTER);
   jf.pack();
   jf.setVisible(true);
 }
Пример #20
0
 public static void main(String[] ss) {
   JFrame f = new JFrame("Sample Frame");
   JTabbedPane jtp = new JTabbedPane();
   jtp.addTab("Cities", new Citi());
   jtp.addTab("Colors", new Colo());
   jtp.addTab("Flavors", new Fla());
   f.add(jtp);
   f.setVisible(true);
   f.setSize(400, 400);
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   JButton b = new JButton("Sam");
   f.add(b);
 }
  public Ui(Timer timer) {
    this.timer = timer;
    Timer.setCALLBACK(
        (i) -> {
          try (PrintWriter printWriter = new PrintWriter(new FileWriter("storage.txt"))) {
            printWriter.println("start" + (System.currentTimeMillis() - (i * 1000)));
          } catch (IOException e) {
            e.printStackTrace();
          }
          timeLabel.setText(String.valueOf(i));
        });

    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setMinimumSize(new Dimension(300, 100));

    frame.setContentPane(contentPanel);
    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.LINE_AXIS));

    frame.add(startButton);
    frame.add(pauseButton);
    frame.add(stopButton);
    frame.add(timeLabel);

    startButton.addActionListener(
        (actionEvent) -> {
          Timer.start();
        });

    pauseButton.addActionListener(
        (actionEvent) -> {
          Timer.pause();
          try (PrintWriter printWriter = new PrintWriter(new FileWriter("storage.txt"))) {
            printWriter.println("pause" + timer.curTime);
          } catch (IOException e) {
            e.printStackTrace();
          }
        });

    stopButton.addActionListener(
        (actionEvent) -> {
          Timer.stop();
          try (PrintWriter printWriter = new PrintWriter(new FileWriter("storage.txt"))) {
            printWriter.println("stop" + timer.curTime);
          } catch (IOException e) {
            e.printStackTrace();
          }
        });
  }
Пример #22
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));
  }
Пример #23
0
  public void launchFrame() {
    JFrame frame = new JFrame("Mensajero");
    frame.setLayout(new BorderLayout());
    frame.add(Salida, BorderLayout.CENTER);
    frame.add(Entrada, BorderLayout.SOUTH);

    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(2, 1));
    p1.add(Enviar);
    p1.add(Salir);

    frame.addWindowListener(new CerrarHandler());
    frame.add(p1, BorderLayout.EAST);
    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");
  }
Пример #25
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);
  }
Пример #26
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();
  }
Пример #27
0
  public Processing(Box root) {
    super(null);

    Log.log("startup.processing", " processing plugin is starting up ");

    frame = new JFrame("Field/Processing");
    __applet =
        new FieldProcessingApplet(
            sizeX,
            sizeY,
            queue,
            this,
            s -> {
              if (getLastErrorOutput() != null) getLastErrorOutput().accept(new Pair<>(-1, s));
            });

    __applet.init();
    __applet.loop();
    frame.add(__applet, BorderLayout.CENTER);
    frame.setSize(sizeX, sizeY);
    frame.setVisible(true);
    frame.validate();

    applet = new FieldProcessingAppletDelgate(__applet);

    this.properties.put(P, applet);

    Log.log("startup.processing", " searching for boxes that need processing support ");

    Log.log("startup.processing", " processing plugin has finished starting up ");
  }
Пример #28
0
 public static final void initialize(JPanel sceneHolder) {
   MazeWindow scene = new MazeWindow(frame);
   scene.setPreferredSize(new Dimension(500, 500));
   sceneHolder = new JPanel();
   sceneHolder.add(scene);
   frame.add(sceneHolder);
 }
Пример #29
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);
 }
Пример #30
0
 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);
 }