예제 #1
0
  public GalaxyViewer(Settings settings, boolean animatorFrame) throws Exception {
    super("Stars GalaxyViewer");
    this.settings = settings;
    this.animatorFrame = animatorFrame;
    if (settings.gameName.equals("")) throw new Exception("GameName not defined in settings.");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    File dir = new File(settings.directory);
    File map = new File(dir, settings.getGameName() + ".MAP");
    if (map.exists() == false) {
      File f = new File(dir.getParentFile(), settings.getGameName() + ".MAP");
      if (f.exists()) map = f;
      else {
        String error = "Could not find " + map.getAbsolutePath() + "\n";
        error += "Export this file from Stars! (Only needs to be done one time pr game)";
        throw new Exception(error);
      }
    }
    Vector<File> mFiles = new Vector<File>();
    Vector<File> hFiles = new Vector<File>();
    for (File f : dir.listFiles()) {
      if (f.getName().toUpperCase().endsWith("MAP")) continue;
      if (f.getName().toUpperCase().endsWith("HST")) continue;
      if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".M")) mFiles.addElement(f);
      else if (f.getName().toUpperCase().startsWith(settings.getGameName() + ".H"))
        hFiles.addElement(f);
    }
    if (mFiles.size() == 0) throw new Exception("No M-files found matching game name.");
    if (hFiles.size() == 0) throw new Exception("No H-files found matching game name.");
    parseMapFile(map);
    Vector<File> files = new Vector<File>();
    files.addAll(mFiles);
    files.addAll(hFiles);
    p = new Parser(files);
    calculateColors();

    // UI:
    JPanel cp = (JPanel) getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(universe, BorderLayout.CENTER);
    JPanel south = createPanel(0, hw, new JLabel("Search: "), search, names, zoom, colorize);
    search.setPreferredSize(new Dimension(100, -1));
    cp.add(south, BorderLayout.SOUTH);
    hw.addActionListener(this);
    names.addActionListener(this);
    zoom.addChangeListener(this);
    search.addKeyListener(this);
    colorize.addActionListener(this);
    setSize(800, 600);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2);
    setVisible(animatorFrame == false);
    if (animatorFrame) names.setSelected(false);
  }
예제 #2
0
  void jbInit() throws Exception {
    titledBorder1 =
        new TitledBorder(
            BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages");
    this.getContentPane().setLayout(borderLayout1);

    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);

    this.setTitle("EDIT");

    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(470);
    sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12));
    controlPanel.setLayout(gridBagLayout1);
    controlPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    positionPanel.setLayout(gridBagLayout2);
    fileLabel.setText("Source file:");
    fileText.setEditable(false);
    browseButton.setSelected(false);
    browseButton.setText("Browse ...");
    assembleButton.setEnabled(false);
    assembleButton.setText("Assemble file");
    saveButton.setEnabled(false);
    saveButton.setText("Save file");
    lineLabel.setText("Line:");
    lineText.setMinimumSize(new Dimension(50, 20));
    lineText.setPreferredSize(new Dimension(50, 20));
    lineText.setEditable(false);
    columnLabel.setText("Column:");
    columnText.setMinimumSize(new Dimension(41, 20));
    columnText.setPreferredSize(new Dimension(41, 20));
    columnText.setEditable(false);
    columnText.setText("");
    messageScrollPane.setBorder(titledBorder1);
    messageScrollPane.setMinimumSize(new Dimension(33, 61));
    messageScrollPane.setPreferredSize(new Dimension(60, 90));
    optionsButton.setEnabled(false);
    optionsButton.setText("Assembler options ...");
    messageScrollPane.getViewport().add(messageList, null);
    messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.add(textScrollPane, JSplitPane.TOP);
    splitPane.add(controlPanel, JSplitPane.BOTTOM);
    textScrollPane.getViewport().add(sourceArea, null);

    controlPanel.add(
        fileLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        fileText,
        new GridBagConstraints(
            1,
            0,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        browseButton,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        optionsButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        assembleButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        saveButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        positionPanel,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        lineLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    positionPanel.add(
        lineText,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        columnLabel,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    positionPanel.add(
        columnText,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        messageScrollPane,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
예제 #3
0
  FlashPlayer() {
    BrComponent.DESIGN_MODE = false;
    BrComponent.setDefaultPaintAlgorithm(BrComponent.PAINT_NATIVE);

    setTitle("Flash Player");

    JPanel rootPanel = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    rootPanel.setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;

    final BrComponent player = new BrComponent();
    player.setBounds(0, 0, 500, 363);
    player.setPreferredSize(new Dimension(425, 363));
    final String stGame = "http://flashportal.ru/monstertruckcurfew.swfi";
    final String stMovie =
        "<html><body border=\"no\" scroll=\"no\" style=\"margin: 0px 0px 0px 0px;\">"
            + "<object style=\"margin: 0px 0px 0px 0px; width:100%; height:100%\""
            + "        value=\"http://www.youtube.com/v/mlTKOsBOVMw&hl=en\">"
            + "<param name=\"wmode\" value=\"transparent\"> "
            + "<embed style=\"margin: 0px 0px 0px 0px; width:100%; height:100%\" src=\"http://www.youtube.com/v/mlTKOsBOVMw&hl=en\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></embed>"
            + "</object>"
            + "</body></html>";
    player.setHTML((InputStream) new StringBufferInputStream(stMovie), "");

    c.gridwidth = GridBagConstraints.REMAINDER; // end row REMAINDER
    gridbag.setConstraints(player, c);
    rootPanel.add(player);

    final JTextField help = new JTextField("Please, use \u2190,\u2191,\u2192,\u2193 keys!");
    help.setPreferredSize(new Dimension(220, 10));
    help.setBounds(50, 10, 220, 16);
    player.add(help, BorderLayout.LINE_END);

    // c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row
    c.weightx = 0.0; // reset to the default
    c.weighty = 0.0;

    //
    {
      JPanel p2 = new JPanel();
      gridbag.setConstraints(p2, c);
      rootPanel.add(p2);

      JButton edSampleGame = new JButton("Sample Game (SWF)");
      edSampleGame.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              player.setHTML(getFlashHTMLSource(stGame), stGame);
              help.setText("Please, use \u2190,\u2191,\u2192,\u2193 keys!");
            }
          });
      p2.add(edSampleGame, BorderLayout.LINE_START);

      JButton edSampleMovie = new JButton("Sample Movie (FLV)");
      edSampleMovie.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              player.setHTML((InputStream) new StringBufferInputStream(stMovie), "");
              help.setText("Enjoy!");
            }
          });
      p2.add(edSampleMovie, BorderLayout.LINE_START);

      JButton edSave = new JButton("Open flash file...");
      edSave.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              JFileChooser fc = new JFileChooser();
              FileNameExtensionFilter filter = new FileNameExtensionFilter("Flash Files", "swf");
              fc.setFileFilter(filter);
              if (JFileChooser.APPROVE_OPTION == fc.showDialog(FlashPlayer.this, "Play")) {
                String stGame = fc.getSelectedFile().getAbsolutePath();
                player.setHTML(getFlashHTMLSource(stGame), stGame);
                help.setText("Enjoy!");
              }
            }
          });
      p2.add(edSave, BorderLayout.LINE_END);
    }

    add(rootPanel);
    pack();
    setVisible(true);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
예제 #4
0
파일: JChat.java 프로젝트: ThatoP/JChat
  public JChat() {
    this.setSize(500, 600);
    this.setResizable(false);
    this.setLayout(new BorderLayout());

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridLayout(2, 1));

    // set up buttons
    openChat = new JButton("Open to chat");
    openChat.addActionListener(new OpenChat());
    chatWith = new JButton("Chat with");
    chatWith.addActionListener(new ChatWith());
    send = new JButton("send");
    send.addActionListener(new Send());
    send.setEnabled(false);
    InputMap inputMap = send.getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    inputMap.put(enter, "ENTER");
    send.getActionMap().put("ENTER", new ClickAction(send));

    // set up labels
    pickPort = new JLabel();
    pickPort.setText("Pick your port number:");
    desPort = new JLabel();
    desPort.setText("Or enter a destinaltion port number:");

    // set up text fields
    pickText = new JTextField();
    pickText.setPreferredSize(new Dimension(150, 30));
    desText = new JTextField();
    desText.setPreferredSize(new Dimension(150, 30));
    chatText = new JTextField();
    chatText.setPreferredSize(new Dimension(400, 30));
    chatText.setEnabled(false);

    JPanel top1 = new JPanel();
    top1.add(pickPort);
    top1.add(pickText);
    top1.add(openChat);

    JPanel top2 = new JPanel();
    top2.add(desPort);
    top2.add(desText);
    top2.add(chatWith);

    topPanel.add(top1);
    topPanel.add(top2);

    chatField = new JTextArea();
    chatField.setAutoscrolls(true);
    chatField.setDragEnabled(true);
    chatField.setEditable(false);
    chatField.setAlignmentY(TOP_ALIGNMENT);

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(chatText);
    bottomPanel.add(send);

    this.add(topPanel, BorderLayout.NORTH);
    this.add(chatField, BorderLayout.CENTER);
    this.add(bottomPanel, BorderLayout.SOUTH);

    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
예제 #5
0
  /**
   * Open the config dialog, send the config update to the robot, save it for future, and refresh
   * the preview tab.
   */
  public void UpdateConfig() {
    final JDialog driver = new JDialog(mainframe, "Configure Limits", true);
    driver.setLayout(new GridBagLayout());

    final JTextField mtop = new JTextField(String.valueOf(limit_top));
    final JTextField mbottom = new JTextField(String.valueOf(limit_bottom));
    final JTextField mleft = new JTextField(String.valueOf(limit_left));
    final JTextField mright = new JTextField(String.valueOf(limit_right));

    final JTextField ptop = new JTextField(String.valueOf(paper_top));
    final JTextField pbottom = new JTextField(String.valueOf(paper_bottom));
    final JTextField pleft = new JTextField(String.valueOf(paper_left));
    final JTextField pright = new JTextField(String.valueOf(paper_right));

    final JButton cancel = new JButton("Cancel");
    final JButton save = new JButton("Save");

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 3;
    c.gridy = 0;
    driver.add(mtop, c);
    c.gridx = 3;
    c.gridy = 5;
    driver.add(mbottom, c);
    c.gridx = 0;
    c.gridy = 3;
    driver.add(mleft, c);
    c.gridx = 5;
    c.gridy = 3;
    driver.add(mright, c);

    c.gridx = 3;
    c.gridy = 1;
    driver.add(ptop, c);
    c.gridx = 3;
    c.gridy = 4;
    driver.add(pbottom, c);
    c.gridx = 1;
    c.gridy = 3;
    driver.add(pleft, c);
    c.gridx = 4;
    c.gridy = 3;
    driver.add(pright, c);

    c.gridx = 4;
    c.gridy = 6;
    driver.add(save, c);
    c.gridx = 5;
    c.gridy = 6;
    driver.add(cancel, c);

    Dimension s = ptop.getPreferredSize();
    s.width = 80;
    ptop.setPreferredSize(s);
    pbottom.setPreferredSize(s);
    pleft.setPreferredSize(s);
    pright.setPreferredSize(s);
    mtop.setPreferredSize(s);
    mbottom.setPreferredSize(s);
    mleft.setPreferredSize(s);
    mright.setPreferredSize(s);

    ActionListener driveButtons =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Object subject = e.getSource();
            if (subject == save) {
              paper_top = Float.valueOf(ptop.getText());
              paper_bottom = Float.valueOf(pbottom.getText());
              paper_right = Float.valueOf(pright.getText());
              paper_left = Float.valueOf(pleft.getText());
              limit_top = Float.valueOf(mtop.getText());
              limit_bottom = Float.valueOf(mbottom.getText());
              limit_right = Float.valueOf(mright.getText());
              limit_left = Float.valueOf(mleft.getText());
              previewPane.setMachineLimits(limit_top, limit_bottom, limit_left, limit_right);
              previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right);
              SetRecentPaperSize();
              SaveConfig();
              SendConfig();
              driver.dispose();
            }
            if (subject == cancel) {
              driver.dispose();
            }
          }
        };

    save.addActionListener(driveButtons);
    cancel.addActionListener(driveButtons);
    SendLineToRobot("M114"); // "where" command
    driver.pack();
    driver.setVisible(true);
  }
예제 #6
0
  public ChatClient() {
    super(APPNAME);

    JPanel topPanel = new JPanel();
    JPanel leftPanel = new JPanel();
    JPanel buttomPanel = new JPanel();

    JPanel roomPanel = new JPanel();
    JPanel userPanel = new JPanel();

    roomList = new JList();
    userList = new JList();
    msgTextArea = new JTextArea();
    msgTextField = new JTextField();
    nameTextField = new JTextField();
    submitButton = new JButton("送信");
    renameButton = new JButton("名前の変更");
    addRoomButton = new JButton("部屋を追加");
    enterRoomButton = new JButton("入室");

    submitButton.addActionListener(this);
    submitButton.setActionCommand("submit");

    renameButton.addActionListener(this);
    renameButton.setActionCommand("rename");

    addRoomButton.addActionListener(this);
    addRoomButton.setActionCommand("addRoom");

    enterRoomButton.addActionListener(this);
    enterRoomButton.setActionCommand("enterRoom");

    roomPanel.setLayout(new BorderLayout());
    roomPanel.add(new JLabel("チャットルーム"), BorderLayout.NORTH);
    roomPanel.add(new JScrollPane(roomList), BorderLayout.CENTER);
    roomPanel.add(enterRoomButton, BorderLayout.SOUTH);

    userPanel.setLayout(new BorderLayout());
    userPanel.add(new JLabel("参加ユーザー"), BorderLayout.NORTH);
    userPanel.add(new JScrollPane(userList), BorderLayout.CENTER);

    topPanel.setLayout(new FlowLayout());
    topPanel.add(new JLabel("名前"));
    topPanel.add(nameTextField);
    topPanel.add(renameButton);
    topPanel.add(addRoomButton);

    nameTextField.setPreferredSize(new Dimension(200, nameTextField.getPreferredSize().height));

    leftPanel.setLayout(new GridLayout(2, 1));
    leftPanel.add(roomPanel);
    leftPanel.add(userPanel);

    buttomPanel.setLayout(new BorderLayout());
    buttomPanel.add(msgTextField, BorderLayout.CENTER);
    buttomPanel.add(submitButton, BorderLayout.EAST);

    // テキストエリアはメッセージを表示するだけなので編集不可に設定
    msgTextArea.setEditable(false);

    // コンポーネントの状態を退室状態で初期化
    exitedRoom();

    this.getContentPane().add(new JScrollPane(msgTextArea), BorderLayout.CENTER);
    this.getContentPane().add(topPanel, BorderLayout.NORTH);
    this.getContentPane().add(leftPanel, BorderLayout.WEST);
    this.getContentPane().add(buttomPanel, BorderLayout.SOUTH);

    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            try {
              close();
            } catch (Exception err) {
            }
          }
        });
    connectServer();

    // メッセージ受信監視用のスレッドを生成してスタートさせる
    thread = new Thread(this);
    thread.start();

    // 現在の部屋を取得する
    sendMessage("getRooms");
  }