示例#1
0
 // Set up the quiz window
 Quiz() {
   initializeData();
   setTitle("FOSS Quiz App");
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   setSize(440, 400);
   setLocation(300, 100);
   setResizable(true);
   Container cont = getContentPane();
   cont.setLayout(null);
   cont.setBackground(Color.WHITE);
   bg = new ButtonGroup();
   choice1 = new JRadioButton("Choice1", true);
   choice2 = new JRadioButton("Choice2", false);
   choice3 = new JRadioButton("Choice3", false);
   choice4 = new JRadioButton("Choice4", false);
   bg.add(choice1);
   bg.add(choice2);
   bg.add(choice3);
   bg.add(choice4);
   lblmess = new JLabel("Choose a correct anwswer");
   lblmess.setForeground(Color.BLACK);
   lblmess.setFont(new Font("Sans_Serif", Font.BOLD, 15));
   btnext = new JButton("Next");
   btnext.setForeground(Color.WHITE);
   btnext.setFont(new Font("Sans_Serif", Font.BOLD, 17));
   btnext.setBackground(Color.DARK_GRAY);
   btnext.addActionListener(this);
   panel = new JPanel();
   panel.setBackground(Color.WHITE);
   panel.setLocation(10, 60);
   panel.setSize(400, 300);
   panel.setLayout(new GridLayout(0, 1));
   title = new JPanel();
   title.setBackground(Color.WHITE);
   title.setLocation(10, 10);
   title.setSize(1000, 50);
   title.setLayout(new GridLayout(1, 0));
   title.add(lblmess);
   panel.add(choice1);
   panel.add(choice2);
   panel.add(choice3);
   panel.add(choice4);
   panel.add(btnext);
   cont.add(title);
   cont.add(panel);
   setVisible(true);
   quizAnswerID = 0;
   readQuestionAnswer(quizAnswerID);
 }
  private JPanel createContentPane() {
    JPanel panel = new JPanel();

    combo1 = new JComboBox<>(numData);
    panel.add(combo1);
    combo2 = new JComboBox<>(dayData);
    combo2.setEditable(true);
    panel.add(combo2);
    panel.setSize(300, 200);

    popupMenu = new JPopupMenu();
    JMenuItem item;
    for (int i = 0; i < dayData.length; i++) {
      item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i]));
      item.addActionListener(this);
    }
    panel.addMouseListener(new PopupListener(popupMenu));

    JTextField field = new JTextField("CTRL+down for Popup");
    // CTRL-down will show the popup.
    field
        .getInputMap()
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP");
    field.getActionMap().put("OPEN_POPUP", new PopupHandler());

    panel.add(field);

    return panel;
  }
示例#3
0
文件: Game.java 项目: jollex/Life
  private void createCells() {
    // Sets the right size for the panel and sets up a GridBagLayout
    grid.setSize(rows * 18, (cols * 18) + 22);
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints g = new GridBagConstraints();
    grid.setLayout(gridBag);

    // Creates the arrays needed for the cells
    cells = new JLabel[rows][cols];
    alive = new boolean[rows][cols];
    mark = new boolean[rows][cols];

    // Two for loops with which we can reach every cell
    for (int x = 0; x < rows; x++) {
      for (int y = 0; y < cols; y++) {
        // Makes a new JLabel for each cell, sets its icon to blank, and adds a border
        cells[x][y] = new JLabel();
        cells[x][y].setIcon(white);
        cells[x][y].setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));

        // All cells start dead and not marked for change
        alive[x][y] = false;
        mark[x][y] = false;

        // Adds the mouselistener to each cell so it's state can be changed
        cells[x][y].addMouseListener(click);

        // Adds the cell to the correct position in the grid
        g.gridx = x;
        g.gridy = y;
        grid.add(cells[x][y], g);
      }
    }
  }
  public void ListePaletteConteneur(int numero) {

    try {

      Connexion connec = new Connexion(Connexion.log, Connexion.password);
      ResultSet rs = connec.listerPaletteConteneur(numero);

      if (rs.next()) {

        rs.previous();

        String[] nomColonnes = {"id_colis"};

        LinkedList<Object[]> liste = new LinkedList<Object[]>();
        Object[][] donnees;

        while (rs.next()) {
          Object[] data = new Object[8];

          data[0] = rs.getString(1);

          liste.add(data);
        }

        donnees = new Object[liste.size()][];

        for (int i = 0; i < donnees.length; i++) {
          donnees[i] = liste.get(i);
        }

        for (int i = 0; i < 8; i++) System.out.println(nomColonnes[i]);
        table = new JTable(donnees, nomColonnes);

        jp = new JPanel();

        jp.setLayout(new BorderLayout());
        jp.add(table.getTableHeader(), BorderLayout.PAGE_START);
        scroll = new JScrollPane(table);

        jp.add(scroll, BorderLayout.CENTER);

        jp.setVisible(true);
        jp.setSize(800, 700);

        fermer.addActionListener(this);
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(jp, BorderLayout.CENTER);
        panel.add(fermer, BorderLayout.SOUTH);
        this.setContentPane(panel);
        this.setVisible(true);
      }

    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
示例#5
0
  private JPanel getJContentPane() {
    if (jContentPane == null) {
      jLabel6 = new JLabel();
      jLabel6.setBounds(new Rectangle(11, 72, 218, 19));
      jLabel6.setText("Install log directory:");
      jLabel5 = new JLabel();
      jLabel5.setBounds(new Rectangle(11, 2, 394, 26));
      jLabel5.setText("Advanced Install. Please select your preferences");
      ButtonGroup group = new ButtonGroup();
      pathSuffix = new JTextArea();
      pathSuffix.setBounds(new Rectangle(232, 48, 61, 21));
      pathSuffix.setText("BIRCH");
      jLabel4 = new JLabel();
      jLabel4.setBounds(new Rectangle(22, 351, 312, 20));
      jLabel4.setText("* - Automatically detected, recommended.");
      jLabel3 = new JLabel();
      jLabel3.setBounds(new Rectangle(220, 48, 10, 21));
      jLabel3.setText(" /");
      jLabel2 = new JLabel();
      jLabel2.setBounds(new Rectangle(18, 250, 132, 18));
      jLabel2.setText("Binaries:");
      jLabel1 = new JLabel();
      jLabel1.setBounds(new Rectangle(11, 115, 127, 21));
      jLabel1.setText("Framework Type:");
      jLabel = new JLabel();
      jLabel.setBounds(new Rectangle(11, 28, 131, 17));
      jLabel.setText("Install directory:");
      jContentPane = new JPanel();
      jContentPane.setLayout(null);
      jContentPane.setSize(new Dimension(464, 376));
      jContentPane.add(jLabel, null);
      jContentPane.add(getJButton(), null);
      jContentPane.add(getJTextArea(), null);
      jContentPane.add(jLabel3, null);
      jContentPane.add(pathSuffix, null);
      jContentPane.add(jLabel1, null);
      jContentPane.add(getJCheckBox(), null);
      jContentPane.add(getJCheckBox1(), null);
      jContentPane.add(jLabel2, null);
      jContentPane.add(getJCheckBox2(), null);
      jContentPane.add(getJCheckBox3(), null);
      jContentPane.add(getJCheckBox4(), null);
      jContentPane.add(getJCheckBox5(), null);
      jContentPane.add(getJCheckBox6(), null);

      jContentPane.add(getLogTextField(), null);
      jContentPane.add(getLogButton(), null);
      jContentPane.add(jLabel4, null);
      jContentPane.add(getWindows32Checkbox(), null);
      jContentPane.add(getJRadioButton(), null);
      jContentPane.add(jLabel5, null);
      jContentPane.add(jLabel6, null);
      jContentPane.add(getGitRadioButton(), null);
      jContentPane.add(getGitComboBox(), null);
      group.add(releaseRadioButton);
      group.add(developmentRadioButton);
      group.add(gitRadioButton);
    }
    return jContentPane;
  }
  public PleaseWaitFrame() throws HeadlessException {

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int locationX = (int) (screenSize.getWidth() - FRAME_SIZE.getWidth()) / 2;
    int locationY = (int) (screenSize.getHeight() - FRAME_SIZE.getHeight()) / 2;
    this.setSize(FRAME_SIZE);
    this.setLocation(locationX, locationY);
    this.setUndecorated(true);
    this.setResizable(false);
    JPanel panel = new JPanel();

    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.fill = GridBagConstraints.CENTER;
    panel.setLayout(gbl);
    messageLabel = new JLabel(message);
    messageLabel.setFont(new Font(null, Font.BOLD, 25));
    panel.add(messageLabel, gbc);

    Border border = new LineBorder(Color.BLACK, 1);

    panel.setSize(FRAME_SIZE);

    panel.setBorder(border);

    this.setContentPane(panel);

    // super.setVisible(true);
    super.setVisible(false);
  }
示例#7
0
  public JPanel createLaneTrafficGenerator(
      Route in, RouteAspect aspect, Engine engine, RouteAspect routes) {
    JPanel controller = vertical();
    TrafficGenerator generator = new TrafficGenerator(in, engine, routes);
    aspect.addTrafficGenerator(generator);
    IntTextField imprecision = new IntTextField();
    IntTextField traffic = new IntTextField();
    JLabel message = new JLabel();
    generator.configure(0, DEFAULT_TRAFFIC_PER_HOUR);
    imprecision.setText("" + 0);
    traffic.setText("" + DEFAULT_TRAFFIC_PER_HOUR);

    JButton validate =
        new JButton("Valider") {
          public TrafficGenerator holder = generator;
        };

    validate.addActionListener(
        (e) -> {
          int imp = imprecision.getValue();
          int traf = traffic.getValue();
          if (traf < 0) traf = 0;
          if (imp < 0) imp = 0;
          if (imp > 100) imp = 100;
          generator.configure(imp, traf);
          message.setText("Modifcation prise en compte");
        });

    controller.add(horizontal(new JLabel("Imprecision (+/-)      "), imprecision));
    controller.add(horizontal(new JLabel("Densite (voiture/heure)"), traffic));
    controller.add(horizontal(validate, message));
    controller.setPreferredSize(new Dimension(100, 100));
    controller.setSize(100, 100);
    return controller;
  }
  private void resetRemainderProblems() {

    problemDisplays = new RemainderProblemDisplay[round.getNumProblems()];

    JPanel panel = new JPanel();
    panel.setMinimumSize(new Dimension(2, 2));
    panel.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
    for (int i = round.getNumProblems() / 4 + (round.getNumProblems() % 4 == 0 ? 0 : 1);
        i >= 0;
        i--) {
      panel.setSize(new Dimension(370, panel.getSize().height + 60));
    }
    panel.setLayout(new Layout(0, 4));

    for (int i = 0; i < round.getNumProblems(); i++) {
      RemainderProblemDisplay problem =
          new RemainderProblemDisplay(
              round.getProblem(i), round.getGenerator().getParam().charAt(0));
      problemDisplays[i] = problem;
      panel.add(problem);
    }
    panel.revalidate();
    problems.setPreferredSize(new Dimension(388, 360));
    problems.setViewportView(panel);
    problems.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    problems.revalidate();
  }
示例#9
0
  /** methode creatWidget dimmensionne panelConnect et panelInit */
  public void createWidget() {

    panConn = createPanelConnect();
    panConn.setSize(new Dimension(350, 100));
    panInit = createPanelInit();
    panInit.setPreferredSize(new Dimension(1200, 300));
    panParty = createPanelPlay();

    setContentPane(panConn);
  }
示例#10
0
  public RobotUI(BatClicked clicked) {
    super("Robot");
    setContentPane(root);
    root.setSize(900, 500);
    pack();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setVisible(true);

    dropButton.addActionListener(e -> clicked.bat());
  }
  public void createProgressScreen() {
    exportingProgressContainer = new JPanel();
    exportingProgressContainer.setSize(new Dimension(this.getWidth(), this.getHeight()));
    exportingProgressContainer.setLayout(new BorderLayout());
    exportingProgressContainer.setBackground(UIHelper.BG_COLOR);

    exportingProgressContainer.add(
        UIHelper.wrapComponentInPanel(new JLabel(creatingArchiveAnimation, JLabel.CENTER)),
        BorderLayout.CENTER);
    exportingProgressContainer.add(
        UIHelper.wrapComponentInPanel(archiveOutputUtil.getArchiveOutputStatus()),
        BorderLayout.SOUTH);
  }
示例#12
0
文件: View.java 项目: presly808/ACP9
 /**
  * init() - метод, в котором: 1.Определается реакция на нажатие кнопки openButton; 2.Определается
  * реакция на нажатие кнопки confirmButton; 3.происходит сборка GUI
  */
 public void init() {
   // собираем весь GUI
   JPanel mainPanel = new JPanel(new BorderLayout());
   allPanel = new JPanel(new GridLayout(3, 1, 5, 5));
   allPanel.setSize(this.getSize());
   allPanel.add(topPanel);
   allPanel.add(new JLabel());
   allPanel.add(midGrid);
   mainPanel.add(allPanel, BorderLayout.NORTH);
   mainPanel.add(textAreaPanel);
   mainPanel.add(gridBotPanel, BorderLayout.SOUTH);
   container.add(mainPanel);
 }
  public BorderedComponent(String text, JComponent comp, boolean collapsible) {
    super(null);

    this.comp = comp;

    // Only add border if text is not null
    if (text != null) {
      TitledBorder border;
      if (collapsible) {
        final JLabel textLabel = new JLabel(text);
        JPanel borderLabel =
            new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)) {
              public int getBaseline(int w, int h) {
                Dimension dim = textLabel.getPreferredSize();
                return textLabel.getBaseline(dim.width, dim.height) + textLabel.getY();
              }
            };
        borderLabel.add(textLabel);
        border = new LabeledBorder(borderLabel);
        textLabel.setForeground(border.getTitleColor());

        if (IS_WIN) {
          collapseIcon = new ImageIcon(getImage("collapse-winlf"));
          expandIcon = new ImageIcon(getImage("expand-winlf"));
        } else {
          collapseIcon = new ArrowIcon(SOUTH, textLabel);
          expandIcon = new ArrowIcon(EAST, textLabel);
        }

        moreOrLessButton = new JButton(collapseIcon);
        moreOrLessButton.setContentAreaFilled(false);
        moreOrLessButton.setBorderPainted(false);
        moreOrLessButton.setMargin(new Insets(0, 0, 0, 0));
        moreOrLessButton.addActionListener(this);
        String toolTip = Messages.BORDERED_COMPONENT_MORE_OR_LESS_BUTTON_TOOLTIP;
        moreOrLessButton.setToolTipText(toolTip);
        borderLabel.add(moreOrLessButton);
        borderLabel.setSize(borderLabel.getPreferredSize());
        add(borderLabel);
      } else {
        border = new TitledBorder(text);
      }
      setBorder(new CompoundBorder(new FocusBorder(this), border));
    } else {
      setBorder(new FocusBorder(this));
    }
    if (comp != null) {
      add(comp);
    }
  }
示例#14
0
  /**
   * @param wizardModel The overall wizard data model containing the aggregate information of all
   *     components in the wizard
   * @param isExiting True if the exit button should trigger an application shutdown
   * @param wizardParameter An optional parameter that can be referenced during construction
   * @param escapeIsCancel If true, ESC cancels the wizard, if false, it does nothing
   */
  protected AbstractWizard(
      M wizardModel, boolean isExiting, Optional wizardParameter, boolean escapeIsCancel) {

    Preconditions.checkNotNull(wizardModel, "'model' must be present");

    log.debug("Building wizard...");

    this.wizardModel = wizardModel;
    this.exiting = isExiting;
    this.wizardParameter = wizardParameter;

    // Subscribe to events
    ViewEvents.subscribe(this);
    CoreEvents.subscribe(this);

    // Optionally bind the ESC key to a Cancel event (escape to safety)
    if (escapeIsCancel) {
      wizardScreenHolder
          .getInputMap(JPanel.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
          .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "quit");
      wizardScreenHolder.getActionMap().put("quit", getCancelAction());
    }

    // TODO Bind the ENTER key to a Next/Finish/Apply event to speed up data entry through keyboard
    // wizardPanel.getInputMap(JPanel.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "next");
    // wizardPanel.getActionMap().put("next", getNextAction(null));

    log.debug("Populating view map and firing initial state view events...");

    // Populate based on the current locale
    populateWizardViewMap(wizardViewMap);

    // Once all the views are created allow events to occur
    for (Map.Entry<String, AbstractWizardPanelView> entry : wizardViewMap.entrySet()) {

      // Ensure the panel is in the correct starting state
      entry.getValue().fireInitialStateViewEvents();
    }

    wizardScreenHolder.setMinimumSize(
        new Dimension(MultiBitUI.WIZARD_MIN_WIDTH, MultiBitUI.WIZARD_MIN_HEIGHT));
    wizardScreenHolder.setPreferredSize(
        new Dimension(MultiBitUI.WIZARD_MIN_WIDTH, MultiBitUI.WIZARD_MIN_HEIGHT));
    wizardScreenHolder.setSize(
        new Dimension(MultiBitUI.WIZARD_MIN_WIDTH, MultiBitUI.WIZARD_MIN_HEIGHT));

    // Show the panel specified by the initial state
    show(wizardModel.getPanelName());
  }
示例#15
0
  public void startGui() {
    JTerminalListener listener = new JTerminalListener();

    jFrame = new JFrame("Glowstone");
    jTerminal = new JTerminal();
    jInput =
        new JTextField(80) {
          @Override
          public void setBorder(Border border) {}
        };
    jInput.paint(null);
    jInput.setFont(new Font("Monospaced", Font.PLAIN, 12));
    jInput.setBackground(Color.BLACK);
    jInput.setForeground(Color.WHITE);
    jInput.setMargin(new Insets(0, 0, 0, 0));
    jInput.addKeyListener(listener);

    JLabel caret = new JLabel("> ");
    caret.setFont(new Font("Monospaced", Font.PLAIN, 12));
    caret.setForeground(Color.WHITE);

    JPanel ipanel = new JPanel();
    ipanel.add(caret, BorderLayout.WEST);
    ipanel.add(jInput, BorderLayout.EAST);
    ipanel.setBorder(BorderFactory.createEmptyBorder());
    ipanel.setBackground(Color.BLACK);
    ipanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    ipanel.setSize(jTerminal.getWidth(), ipanel.getHeight());

    jFrame.getContentPane().add(jTerminal, BorderLayout.NORTH);
    jFrame.getContentPane().add(ipanel, BorderLayout.SOUTH);
    jFrame.addWindowListener(listener);
    jFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    jFrame.setLocationRelativeTo(null);
    jFrame.pack();
    jFrame.setVisible(true);

    sender = new ColoredCommandSender();
    logger.removeHandler(consoleHandler);
    logger.addHandler(
        new StreamHandler(new TerminalOutputStream(), new DateOutputFormatter(CONSOLE_DATE)));
  }
示例#16
0
  /**
   * Constructor del juego que inicializa los valores.
   *
   * @param juga
   * @param jugadorActual
   */
  public Juego(ArrayList<Jugador> juga, Jugador jugadorActual) {
    jugadores = new ArrayList<>();
    this.jugadores = juga;
    this.jugador = jugadorActual;
    loader = Juego.class.getClassLoader();
    utilidades = new Util();
    claseTime = new Time();
    ventana = new JFrame("Concéntrese - Juan S.");
    ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ventana.setSize(520, 475);
    ventana.setLayout(null);
    ventana.setResizable(false);
    contadorJugadas = 0;
    cartaPorDefecto = new ImageIcon(loader.getResource("recursos/carta8.gif"));
    panel = new JPanel();
    panel.setSize(300, 450);
    panel.setLayout(new GridLayout(4, 4));
    intentos = new JLabel("Intento : 0");
    etiquetaTiempoPartida = new JLabel("Tiempo: ");
    tiempoPartida = new JLabel("00.00.000");
    etiquetaTiempoPartida.setFont(etiquetaTiempoPartida.getFont().deriveFont(20.0f));
    tiempoPartida.setFont(tiempoPartida.getFont().deriveFont(20.0f));
    intentos.setFont(intentos.getFont().deriveFont(20.0f));
    intentos.setBounds(320, 50, 200, 30);
    tiempoPartida.setBounds(420, 5, 200, 30);
    etiquetaTiempoPartida.setBounds(320, 5, 200, 30);
    ventana.add(tiempoPartida);
    ventana.add(etiquetaTiempoPartida);
    ventana.add(intentos);
    ventana.add(panel);

    crearMenuSuperior();
    crearMatrizIconos();
    crearArrayBotones();
    crearTemporizador();

    ventana.setLocationRelativeTo(null);
    ventana.setVisible(true);
  }
  protected void layout1280() {
    // Resolution of the camera pictures divided by 2

    // 320x240, Creative camera for layout1280
    size_x = 320 / 2;
    size_y = 240 / 2;
    sizeCaptureWindow_x = size_x * 2;
    sizeCaptureWindow_y = size_y * 2;

    imagepanels = new WebcamCaptureAndFadeImagePanel[4];
    imagepanels[0] = new WebcamCaptureAndFadeImagePanel(3, 8, size_x, size_y);
    imagepanels[1] = new WebcamCaptureAndFadeImagePanel(2, 3, size_x, size_y);
    imagepanels[2] = new WebcamCaptureAndFadeImagePanel(2, 3, size_x, size_y);
    imagepanels[3] = new WebcamCaptureAndFadeImagePanel(3, 8, size_x, size_y);

    setLayout(new BorderLayout());
    setSize((4 + 2 + 4) * size_x, (6) * size_y);

    add(imagepanels[0], BorderLayout.WEST);

    JPanel middle = new JPanel(new BorderLayout());
    middle.add(imagepanels[1], BorderLayout.NORTH);
    if ((comp = player.getVisualComponent()) != null) {
      middle.add(comp, BorderLayout.CENTER);
    }
    middle.add(imagepanels[2], BorderLayout.SOUTH);
    middle.setSize(new Dimension(4 * size_x, 2 * size_y));
    add(middle, BorderLayout.CENTER);

    add(imagepanels[3], BorderLayout.EAST);

    enable_datetext = false;
    enable_forceNewImage = false;
    captureWindow = false;

    txt_location_x = txt_location_y = 0;
    txt_size_x = 18;
    txt_size_y = size_y;
  }
示例#18
0
  private void GUI() {

    // gui components
    JFrame frame = new JFrame();
    JPanel pane = new JPanel();

    // buttons and areas
    JTextArea uName = new JTextArea("Spy Alias");
    JTextArea pWord = new JTextArea("Top Secret Password");
    JButton submit = new JButton("Login");
    JButton register = new JButton("Register");

    // sizing GUI components
    submit.setBounds(545, 260, 100, 50);
    register.setBounds(650, 260, 100, 50);
    uName.setBounds(545, 200, 100, 50);
    pWord.setBounds(650, 200, 100, 50);

    // adding action listeners
    submit.addActionListener(this);

    // sizing, making visible, and adding pane to Frame
    frame.setLayout(null);
    frame.setVisible(true);
    frame.setSize(1600, 850);
    frame.add(pane);

    // adding components to panel and sizing
    pane.setLayout(null);
    pane.setSize(1600, 850);
    pane.add(uName);
    pane.add(pWord);
    pane.add(submit);
    pane.add(register);
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
  public ScalaApplicationSettingsForm(ScalaApplicationSettings settings) {
    mySettings = settings;

    myEnableCompileServer.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            updateCompilationServerSettingsPanel();
          }
        });

    initCompilerTypeCmb();
    initCompileOrderCmb();

    ProjectSdksModel model = new ProjectSdksModel();
    model.reset(null);

    myCompilationServerSdk = new JdkComboBox(model);
    myCompilationServerSdk.insertItemAt(new JdkComboBox.NoneJdkComboBoxItem(), 0);

    mySdkPanel.add(myCompilationServerSdk, BorderLayout.CENTER);
    mySdkPanel.setSize(mySdkPanel.getPreferredSize());

    myNote.setForeground(JBColor.GRAY);

    delaySpinner.setEnabled(showTypeInfoOnCheckBox.isSelected());
    showTypeInfoOnCheckBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            delaySpinner.setEnabled(showTypeInfoOnCheckBox.isSelected());
          }
        });
    delaySpinner.setValue(mySettings.SHOW_TYPE_TOOLTIP_DELAY);

    updateCompilationServerSettingsPanel();
  }
示例#20
0
  void setupGUI() {
    taDictionary = new TextArea();
    taDictionary.setLocation(0, 0);
    taDictionary.setSize(106, 567);
    taDictionary.setBackground(new Color(-1));
    taDictionary.setText("");
    taDictionary.setRows(5);
    taDictionary.setColumns(1);
    getContentPane().add(taDictionary);

    tfSourc = new TextField();
    tfSourc.setLocation(224, 90);
    tfSourc.setSize(266, 25);
    tfSourc.setBackground(new Color(-1));
    tfSourc.setText("");
    tfSourc.setColumns(10);
    getContentPane().add(tfSourc);

    lblSourc = new Label();
    lblSourc.setLocation(106, 90);
    lblSourc.setSize(119, 25);
    lblSourc.setText("Source Word:");
    getContentPane().add(lblSourc);
    /*
    lblDestinatio = new Label();
    lblDestinatio.setLocation(106,97);
    lblDestinatio.setSize(119,25);
    lblDestinatio.setText("Destination Wor");
    getContentPane().add(lblDestinatio);
       */

    lblDestinatio = new Label();
    lblDestinatio.setLocation(106, 120);
    lblDestinatio.setSize(119, 25);
    lblDestinatio.setText("Destination Word:");
    getContentPane().add(lblDestinatio);

    lblWordSize = new Label();
    lblWordSize.setLocation(106, 27); // 106,120
    lblWordSize.setSize(119, 25);
    lblWordSize.setText("Word Size:");
    getContentPane().add(lblWordSize);

    tfWordSize = new TextField();
    tfWordSize.setLocation(224, 27); // 224,120
    tfWordSize.setSize(263, 25);
    tfWordSize.setBackground(new Color(-1));
    tfWordSize.setText("5");
    tfWordSize.setColumns(10);
    getContentPane().add(tfWordSize);

    tfSourc_6 = new TextField();
    tfSourc_6.setLocation(226, 120);
    tfSourc_6.setSize(263, 25);
    tfSourc_6.setBackground(new Color(-1));
    tfSourc_6.setText("");
    tfSourc_6.setColumns(10);
    getContentPane().add(tfSourc_6);

    lblFileNam = new Label();
    lblFileNam.setLocation(104, 0);
    lblFileNam.setSize(119, 25);
    lblFileNam.setText("FilePath:");
    getContentPane().add(lblFileNam);

    tfFilePat = new TextField();
    tfFilePat.setLocation(224, 0);
    tfFilePat.setSize(266, 25);
    tfFilePat.setBackground(new Color(-1));

    // OS Detection
    if (System.getProperty("os.name").startsWith("Windows")) {
      // includes: Windows 2000,  Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP
      tfFilePat.setText("c:\\ics340\\words.txt");
      System.out.println("Detected Windows: " + System.getProperty("os.name"));
    } else {
      tfFilePat.setText("/Users/jasonedstrom/ics340/d1.txt");
      System.out.println("Detected Mac OS X: " + System.getProperty("os.name"));
    }

    tfFilePat.setColumns(10);
    getContentPane().add(tfFilePat);

    btLoadTextFiel = new JButton();
    btLoadTextFiel.setLocation(108, 50); // 108,27
    btLoadTextFiel.setSize(198, 32);
    btLoadTextFiel.setText("Load Words from Text Field");
    getContentPane().add(btLoadTextFiel);

    btLoadFil = new JButton();
    btLoadFil.setLocation(306, 50); // 306,27
    btLoadFil.setSize(183, 32);
    btLoadFil.setText("Load Words from File");
    getContentPane().add(btLoadFil);

    btFindPat = new JButton();
    btFindPat.setLocation(106, 160);
    btFindPat.setSize(384, 38);
    btFindPat.setText("Find Path");
    getContentPane().add(btFindPat);

    lblDictCoun = new JLabel();
    lblDictCoun.setLocation(108, 513);
    lblDictCoun.setSize(300, 27);
    lblDictCoun.setForeground(new Color(-65536));
    lblDictCoun.setText("Words in Dictionary = 0 words");
    getContentPane().add(lblDictCoun);

    lblIndexing1 = new JLabel();
    lblIndexing1.setLocation(107, 454);
    lblIndexing1.setSize(130, 27);
    lblIndexing1.setForeground(new Color(-16777216));
    lblIndexing1.setText("");
    getContentPane().add(lblIndexing1);

    lblFindPat = new JLabel();
    lblFindPat.setLocation(108, 540);
    lblFindPat.setSize(250, 27);
    lblFindPat.setForeground(new Color(-14646771));
    lblFindPat.setText("Time to find Path: 0 milliseconds");
    getContentPane().add(lblFindPat);

    lblCos = new JLabel();
    lblCos.setLocation(360, 540);
    lblCos.setSize(175, 27);
    lblCos.setForeground(new Color(-16777216));
    lblCos.setText("Cost of Path: 0.0");
    getContentPane().add(lblCos);

    lblProgres = new JLabel();
    lblProgres.setLocation(108, 484);
    lblProgres.setSize(371, 26);
    lblProgres.setForeground(new Color(-14646771));
    lblProgres.setText("Time to Build Graph: 0 milliseconds");
    getContentPane().add(lblProgres);

    testpanel = new JPanel();
    testpanel.setLocation(106, 200);
    testpanel.setSize(350, 200);
    testpanel.setForeground(new Color(-14646771));
    // testpanel.setText("Test Location");
    getContentPane().add(testpanel);

    btClear = new JButton();
    btClear.setLocation(355, 513);
    btClear.setSize(125, 25);
    btClear.setText("Clear Results");
    getContentPane().add(btClear);

    // add actionlisteners to buttons
    btFindPat.addActionListener(this);
    btLoadTextFiel.addActionListener(this);
    btLoadFil.addActionListener(this);
    btClear.addActionListener(this);

    setTitle("WordLadderGUI");
    setSize(500, 600);
    setVisible(true);
    setResizable(false);
  }
示例#21
0
  void startAnimation(final boolean enlarge) {
    staticImage = myController.getStaticImage();
    JPanel staticPanel =
        new JPanel() {
          @Override
          public void paint(Graphics g) {
            super.paint(g);
            if (staticImage != null) {
              Graphics2D g2d = (Graphics2D) g.create();

              g2d.setBackground(
                  new JBColor(new Color(255, 255, 255, 0), new Color(110, 110, 110, 0)));
              g2d.clearRect(0, 0, myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT);

              g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.95f));

              int multiplyFactor = staticImage.getWidth(null) / myController.SHEET_NC_WIDTH;

              g.drawImage(
                  staticImage,
                  0,
                  0,
                  myController.SHEET_NC_WIDTH,
                  imageHeight,
                  0,
                  staticImage.getHeight(null) - imageHeight * multiplyFactor,
                  staticImage.getWidth(null),
                  staticImage.getHeight(null),
                  null);
            }
          }
        };
    staticPanel.setOpaque(false);
    staticPanel.setSize(myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT);
    myWindow.setContentPane(staticPanel);

    Animator myAnimator =
        new Animator(
            "Roll Down Sheet Animator", myController.SHEET_NC_HEIGHT, TIME_TO_SHOW_SHEET, false) {
          @Override
          public void paintNow(int frame, int totalFrames, int cycle) {
            setPositionRelativeToParent();
            float percentage = (float) frame / (float) totalFrames;
            imageHeight =
                enlarge
                    ? (int) (((float) myController.SHEET_NC_HEIGHT) * percentage)
                    : (int) (myController.SHEET_NC_HEIGHT - percentage * myController.SHEET_HEIGHT);
            myWindow.repaint();
          }

          @Override
          protected void paintCycleEnd() {
            setPositionRelativeToParent();
            if (enlarge) {
              imageHeight = myController.SHEET_NC_HEIGHT;
              staticImage = null;
              myWindow.setContentPane(myController.getPanel(myWindow));

              myController.requestFocus();
            } else {
              if (restoreFullscreenButton) {
                FullScreenUtilities.setWindowCanFullScreen(myParent, true);
              }
              myWindow.dispose();
            }
          }
        };

    myAnimator.resume();
  }
示例#22
0
  /**
   * Create a visualization of the mapping showing what columns the file had and what isatab fields
   * each of these columns have been mapped to
   *
   * @param sequence - sequence of assay processing.
   * @param nameOfFileBeingMapped - name to save the mapping visualization as.
   * @param mapping - Mappings for each isatab file to the incoming column name(s) and any literals.
   * @return JLayeredPane containing the GUI to display the mapping visualization.
   */
  private JLayeredPane createMappingVisualization(
      final int sequence,
      final String nameOfFileBeingMapped,
      Map<MappingField, List<String>> mapping) {

    JPanel visContainer = new JPanel();
    visContainer.setLayout(new BoxLayout(visContainer, BoxLayout.PAGE_AXIS));
    visContainer.setSize(
        new Dimension((int) (menuPanels.getWidth() * 0.80), (int) (menuPanels.getHeight() * 0.90)));

    Tree t = null;

    GenerateMappingView gmv = new GenerateMappingView(nameOfFileBeingMapped, mapping);
    File treeFile = gmv.generateView();

    try {
      t = (Tree) new TreeMLReader().readGraph(treeFile);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // create a new treemap
    final TreeView tview =
        new TreeView(
            t,
            new Dimension(
                (int) (menuPanels.getWidth() * 0.80), (int) (menuPanels.getHeight() * 0.90)));

    tview.setBackground(UIHelper.BG_COLOR);
    tview.setForeground(UIHelper.GREY_COLOR);

    visContainer.add(tview);

    JLabel help_section = new JLabel(mappingVisualisationHelp);
    visContainer.add(help_section);

    ImageIcon crumb = ((sequence - 1) == -1) ? breadcrumb4 : breadcrumb6;

    final JLayeredPane finalPanel =
        getGeneralLayout(mappingOverviewHeader, crumb, "", visContainer, getHeight());

    final MouseListener[] listeners = new MouseListener[2];

    listeners[0] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            backButton.setIcon(backOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            backButton.setIcon(back);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            backButton.setIcon(back);

            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    HistoryComponent hc = previousPage.pop();
                    setCurrentPage(hc.getDisplayComponent());
                    assignListenerToLabel(backButton, hc.getListeners()[0]);
                    assignListenerToLabel(nextButton, hc.getListeners()[1]);
                  }
                });
          }
        };

    assignListenerToLabel(backButton, listeners[0]);

    listeners[1] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            nextButton.setIcon(nextOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            nextButton.setIcon(next);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            nextButton.setIcon(next);
            Thread performMappingProcess =
                new Thread(
                    new Runnable() {
                      public void run() {
                        try {
                          if (sequence <= assaysToBeDefined.size() - 1) {
                            AssaySelection aso = assaysToBeDefined.get(sequence);
                            String nextMeasurement = aso.getMeasurement();
                            String nextTechnology = aso.getTechnology();
                            setCurrentPage(
                                createMappings(
                                    sequence,
                                    getTableReferenceObject(nextTechnology, nextMeasurement),
                                    fileColumns,
                                    nameOfFileBeingMapped,
                                    reader));
                          } else {
                            setCurrentPage(createSaveMappings());
                          }
                        } catch (BiffException e) {
                          setCurrentPage(lastPage);
                          log.error(e.getMessage());
                        } catch (IOException e) {
                          setCurrentPage(lastPage);
                          log.error(e.getMessage());
                        } catch (NoAvailableLoaderException e) {
                          setCurrentPage(lastPage);
                          log.error(e.getMessage());
                        }
                      }
                    });
            lastPage = currentPage;
            setCurrentPage(workingProgressScreen);
            performMappingProcess.start();
          }
        };

    assignListenerToLabel(nextButton, listeners[1]);
    return finalPanel;
  }
示例#23
0
  /**
   * setupNoLandPermPanel.
   *
   * @param p a {@link javax.swing.JPanel} object.
   * @param list a {@link java.util.ArrayList} object.
   * @param stack a boolean.
   */
  private static void setupNoLandPermPanel(JPanel p, ArrayList<Card> list, boolean stack) {

    int maxY = 0;
    int maxX = 0;

    Card c;

    if (stack) {
      // add all Cards in list to the GUI, add arrows to Local Enchantments

      ArrayList<Card> planeswalkers = getPlaneswalkers(list);
      ArrayList<Card> equippedEnchantedCreatures =
          getEquippedEnchantedCreatures(
              list); // this will also fetch the equipment and/or enchantment
      ArrayList<Card> nonTokenCreatures = getNonTokenCreatures(list);
      ArrayList<Card> tokenCreatures = getTokenCreatures(list);

      // sort tokenCreatures by name (TODO: fix the warning message somehow)
      Collections.sort(
          tokenCreatures,
          new Comparator<Card>() {
            public int compare(Card c1, Card c2) {
              return c1.getName().compareTo(c2.getName());
            }
          });

      ArrayList<Card> artifacts = getNonCreatureArtifacts(list);
      ArrayList<Card> enchantments = getGlobalEnchantments(list);
      // ArrayList<Card> nonBasics = getNonBasics(list);

      list = new ArrayList<Card>();
      list.addAll(planeswalkers);
      list.addAll(equippedEnchantedCreatures);
      list.addAll(nonTokenCreatures);
      list.addAll(tokenCreatures);
      list.addAll(artifacts);
      list.addAll(enchantments);

      int atInStack = 0;

      int marginX = 5;
      int marginY = 5;

      int x = marginX;

      int cardOffset = Constant.Runtime.stackOffset[0];

      String color = "";
      ArrayList<JPanel> cards = new ArrayList<JPanel>();

      ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>();

      boolean nextEquippedEnchanted = false;
      int nextXIfNotStacked = 0;
      Card prevCard = null;
      for (int i = 0; i < list.size(); i++) {
        JPanel addPanel;
        c = list.get(i);
        addPanel = new CardPanel(c);

        boolean startANewStack = false;

        if (!isStackable(c)) {
          startANewStack = true;
        } else {
          String newColor = c.getName(); // CardUtil.getColor(c);

          if (!newColor.equals(color)) {
            startANewStack = true;
            color = newColor;
          }
        }

        if (i == 0) {
          startANewStack = false;
        }

        if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) {
          startANewStack = true;
        }

        if ((c.isEquipment() || c.isAura())
            && (c.isEquipping() || c.isEnchanting())
            && !nextEquippedEnchanted) startANewStack = false;
        else if ((c.isEquipment() || c.isAura()) && (c.isEquipping() || c.isEnchanting())) {
          startANewStack = true;
          nextEquippedEnchanted = false;
        }

        if (c.isCreature() && (c.isEquipped() || c.isEnchanted())) {
          startANewStack = false;
          nextEquippedEnchanted = true;
        }
        // very hacky, but this is to ensure equipment stacking occurs correctly when a token is
        // equipped/enchanted, and there are more tokens of that same name
        else if ((prevCard != null
            && c.isCreature()
            && prevCard.isCreature()
            && (prevCard.isEquipped() || prevCard.isEnchanted())
            && prevCard.getName().equals(c.getName()))) startANewStack = true;
        else if (prevCard != null
            && c.isCreature()
            && prevCard.isCreature()
            && !prevCard.getName().equals(c.getName())) startANewStack = true;

        if (((c.isAura() && c.isEnchanting()) || (c.isEquipment() && c.isEquipping()))
            && prevCard != null
            && prevCard.isPlaneswalker()) startANewStack = true;

        if (startANewStack) {
          setupConnectedCards(connectedCards);
          connectedCards.clear();

          // Fixed distance if last was a stack, looks a bit nicer
          if (atInStack > 1) {
            x +=
                Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height)
                    + marginX;
          } else {
            x = nextXIfNotStacked;
          }

          atInStack = 0;
        } else {
          if (i != 0) {
            x += cardOffset;
          }
        }

        nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width;

        int xLoc = x;

        int yLoc = marginY;
        yLoc += atInStack * cardOffset;

        addPanel.setLocation(new Point(xLoc, yLoc));
        addPanel.setSize(addPanel.getPreferredSize());

        cards.add(addPanel);

        connectedCards.add((CardPanel) addPanel);

        atInStack++;
        prevCard = c;
      }

      setupConnectedCards(connectedCards);
      connectedCards.clear();

      for (int i = cards.size() - 1; i >= 0; i--) {
        JPanel card = cards.get(i);
        // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX);
        maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY);
        p.add(card);
      }

      maxX = nextXIfNotStacked;

      if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) {
        p.setPreferredSize(new Dimension(maxX, maxY));
      }

    } else {
      JPanel addPanel;
      for (int i = 0; i < list.size(); i++) {
        c = list.get(i);
        addPanel = new CardPanel(c);

        p.add(addPanel);
      }
    }
  } // setupPanel()
示例#24
0
  /** Main function for building the merge entry JPanel */
  private void initialize() {

    joint = new TreeSet<>(one.getFieldNames());
    joint.addAll(two.getFieldNames());

    // Remove field starting with __
    TreeSet<String> toberemoved = new TreeSet<>();
    for (String field : joint) {
      if (field.startsWith("__")) {
        toberemoved.add(field);
      }
    }

    for (String field : toberemoved) {
      joint.remove(field);
    }

    // Create storage arrays
    rb = new JRadioButton[3][joint.size() + 1];
    ButtonGroup[] rbg = new ButtonGroup[joint.size() + 1];
    identical = new Boolean[joint.size() + 1];
    jointStrings = new String[joint.size()];

    // Create main layout
    String colSpecMain =
        "left:pref, 5px, center:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, center:3cm:grow";
    String colSpecMerge =
        "left:pref, 5px, fill:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, fill:3cm:grow";
    String rowSpec = "pref, pref, 10px, fill:5cm:grow, 10px, pref, 10px, fill:3cm:grow";
    StringBuilder rowBuilder = new StringBuilder("");
    for (int i = 0; i < joint.size(); i++) {
      rowBuilder.append("pref, ");
    }
    rowBuilder.append("pref");

    FormLayout mainLayout = new FormLayout(colSpecMain, rowSpec);
    FormLayout mergeLayout = new FormLayout(colSpecMerge, rowBuilder.toString());
    mainPanel.setLayout(mainLayout);
    mergePanel.setLayout(mergeLayout);

    JLabel label = new JLabel(Localization.lang("Use"));
    Font font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));

    mainPanel.add(label, cc.xyw(4, 1, 7, "center, bottom"));

    // Set headings
    JLabel headingLabels[] = new JLabel[6];
    for (int i = 0; i < 6; i++) {
      headingLabels[i] = new JLabel(columnHeadings[i]);
      font = headingLabels[i].getFont();
      headingLabels[i].setFont(font.deriveFont(font.getStyle() | Font.BOLD));
      mainPanel.add(headingLabels[i], cc.xy(1 + (i * 2), 2));
    }

    mainPanel.add(new JSeparator(), cc.xyw(1, 3, 11));

    // Start with entry type
    EntryType type1 = one.getType();
    EntryType type2 = two.getType();

    mergedEntry.setType(type1);
    label = new JLabel(Localization.lang("Entry type"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mergePanel.add(label, cc.xy(1, 1));

    JTextArea type1ta = new JTextArea(type1.getName());
    type1ta.setEditable(false);
    mergePanel.add(type1ta, cc.xy(3, 1));
    if (type1.compareTo(type2) != 0) {
      identical[0] = false;
      rbg[0] = new ButtonGroup();
      for (int k = 0; k < 3; k += 2) {
        rb[k][0] = new JRadioButton();
        rbg[0].add(rb[k][0]);
        mergePanel.add(rb[k][0], cc.xy(5 + (k * 2), 1));
        rb[k][0].addChangeListener(
            new ChangeListener() {

              @Override
              public void stateChanged(ChangeEvent e) {
                updateAll();
              }
            });
      }
      rb[0][0].setSelected(true);
    } else {
      identical[0] = true;
    }
    JTextArea type2ta = new JTextArea(type2.getName());
    type2ta.setEditable(false);
    mergePanel.add(type2ta, cc.xy(11, 1));

    // For all fields in joint add a row and possibly radio buttons
    int row = 2;
    int maxLabelWidth = -1;
    int tmpLabelWidth = 0;
    for (String field : joint) {
      jointStrings[row - 2] = field;
      label = new JLabel(CaseChangers.UPPER_FIRST.format(field));
      font = label.getFont();
      label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
      mergePanel.add(label, cc.xy(1, row));
      String string1 = one.getField(field);
      String string2 = two.getField(field);
      identical[row - 1] = false;
      if ((string1 != null) && (string2 != null)) {
        if (string1.equals(string2)) {
          identical[row - 1] = true;
        }
      }

      tmpLabelWidth = label.getPreferredSize().width;
      if (tmpLabelWidth > maxLabelWidth) {
        maxLabelWidth = tmpLabelWidth;
      }

      if ("abstract".equals(field) || "review".equals(field)) {
        // Treat the abstract and review fields special
        JTextArea tf = new JTextArea();
        tf.setLineWrap(true);
        tf.setEditable(false);
        JScrollPane jsptf = new JScrollPane(tf);

        mergeLayout.setRowSpec(row, RowSpec.decode("center:2cm:grow"));
        mergePanel.add(jsptf, cc.xy(3, row, "f, f"));
        tf.setText(string1);
        tf.setCaretPosition(0);

      } else {
        JTextArea tf = new JTextArea(string1);
        mergePanel.add(tf, cc.xy(3, row));
        tf.setCaretPosition(0);
        tf.setEditable(false);
      }

      // Add radio buttons if the two entries do not have identical fields
      if (!identical[row - 1]) {
        rbg[row - 1] = new ButtonGroup();
        for (int k = 0; k < 3; k++) {
          rb[k][row - 1] = new JRadioButton();
          rbg[row - 1].add(rb[k][row - 1]);
          mergePanel.add(rb[k][row - 1], cc.xy(5 + (k * 2), row));
          rb[k][row - 1].addChangeListener(
              new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                  updateAll();
                }
              });
        }
        if (string1 != null) {
          mergedEntry.setField(field, string1);
          rb[0][row - 1].setSelected(true);
          if (string2 == null) {
            rb[2][row - 1].setEnabled(false);
          }
        } else {
          rb[0][row - 1].setEnabled(false);
          mergedEntry.setField(field, string2);
          rb[2][row - 1].setSelected(true);
        }
      } else {
        mergedEntry.setField(field, string1);
      }
      if ("abstract".equals(field) || "review".equals(field)) {
        // Again, treat abstract and review special
        JTextArea tf = new JTextArea();
        tf.setLineWrap(true);
        tf.setEditable(false);
        JScrollPane jsptf = new JScrollPane(tf);

        mergePanel.add(jsptf, cc.xy(11, row, "f, f"));
        tf.setText(string2);
        tf.setCaretPosition(0);

      } else {
        JTextArea tf = new JTextArea(string2);
        mergePanel.add(tf, cc.xy(11, row));
        tf.setCaretPosition(0);
        tf.setEditable(false);
      }

      row++;
    }

    JScrollPane scrollPane =
        new JScrollPane(
            mergePanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    mainPanel.add(scrollPane, cc.xyw(1, 4, 11));
    mainPanel.add(new JSeparator(), cc.xyw(1, 5, 11));

    // Synchronize column widths
    String rbAlign[] = {"right", "center", "left"};
    mainLayout.setColumnSpec(1, ColumnSpec.decode(Integer.toString(maxLabelWidth) + "px"));
    Integer maxRBWidth = -1;
    Integer tmpRBWidth;
    for (int k = 0; k < 3; k++) {
      tmpRBWidth = headingLabels[k + 2].getPreferredSize().width;
      if (tmpRBWidth > maxRBWidth) {
        maxRBWidth = tmpRBWidth;
      }
    }
    for (int k = 0; k < 3; k++) {
      mergeLayout.setColumnSpec(
          5 + (k * 2), ColumnSpec.decode(rbAlign[k] + ":" + maxRBWidth + "px"));
    }

    // Setup a PreviewPanel and a Bibtex source box for the merged entry
    label = new JLabel(Localization.lang("Merged entry"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mainPanel.add(label, cc.xyw(1, 6, 6));

    String layoutString = Globals.prefs.get(JabRefPreferences.PREVIEW_0);
    pp = new PreviewPanel(null, mergedEntry, null, new MetaData(), layoutString);
    // JScrollPane jsppp = new JScrollPane(pp, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    // JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    mainPanel.add(pp, cc.xyw(1, 8, 6));

    label = new JLabel(Localization.lang("Merged BibTeX source code"));
    font = label.getFont();
    label.setFont(font.deriveFont(font.getStyle() | Font.BOLD));
    mainPanel.add(label, cc.xyw(8, 6, 4));

    jta = new JTextArea();
    jta.setLineWrap(true);
    JScrollPane jspta = new JScrollPane(jta);
    mainPanel.add(jspta, cc.xyw(8, 8, 4));
    jta.setEditable(false);
    StringWriter sw = new StringWriter();
    try {
      new BibtexEntryWriter(new LatexFieldFormatter(), false).write(mergedEntry, sw);
    } catch (IOException ex) {
      LOGGER.error("Error in entry" + ": " + ex.getMessage(), ex);
    }
    jta.setText(sw.getBuffer().toString());
    jta.setCaretPosition(0);

    // Add some margin around the layout
    mainLayout.appendRow(RowSpec.decode("10px"));
    mainLayout.appendColumn(ColumnSpec.decode("10px"));
    mainLayout.insertRow(1, RowSpec.decode("10px"));
    mainLayout.insertColumn(1, ColumnSpec.decode("10px"));

    if (mainPanel.getHeight() > DIM.height) {
      mainPanel.setSize(new Dimension(mergePanel.getWidth(), DIM.height));
    }
    if (mainPanel.getWidth() > DIM.width) {
      mainPanel.setSize(new Dimension(DIM.width, mergePanel.getHeight()));
    }

    // Everything done, allow any action to actually update the merged entry
    doneBuilding = true;

    // Show what we've got
    mainPanel.setVisible(true);
    javax.swing.SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            scrollPane.getVerticalScrollBar().setValue(0);
          }
        });
  }
示例#25
0
  /**
   * Constructor
   *
   * @param game
   */
  public SwingView(Game game) {
    this.game = game;

    // get frame size
    this.size = game.getSize();
    this.side = size * 100;

    UIManager.getDefaults().put("Button.disabledText", Color.BLACK);

    // set size (the game field size + the status line size + the buttons panel)
    this.setSize(side, side + 20 + 30);

    this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    this.setTitle("TicTacToe");

    // Create the main panel which will
    // contain all other panels
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    this.add(mainPanel);

    // The game status string
    JPanel status = new JPanel();
    status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS));
    status.setMaximumSize(new Dimension(side, 20));
    statusStr = new JLabel(game.getState().toString());

    status.add(statusStr);
    mainPanel.add(status);

    // The game field panel
    gameField = new JPanel();
    gameField.setSize(side, side);
    gameField.setLayout(new GridLayout(size, size));

    // Fill the game field with buttons
    for (int i = 0; i < size * size; i++) {
      gameField.add(createButton());
    }
    mainPanel.add(gameField);

    // The buttons panel
    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.setMaximumSize(new Dimension(side, 50));

    JButton restartBtn = new JButton();
    restartBtn.setMaximumSize(new Dimension(side, 50));
    restartBtn.setText("Restart");

    restartBtn.addActionListener(
        e -> {
          this.dispose();
          this.game = new Game();
          new SwingView(this.game);
        });

    buttons.add(restartBtn);
    mainPanel.add(buttons);

    this.setResizable(false);
    // Game window appears on center
    this.setLocationRelativeTo(null);
    this.setVisible(true);
  }
示例#26
0
  public void launchChess() {

    mainWindow = new JFrame("网络黑白棋	作者:张炀");
    jpWest = new JPanel();
    jpEast = new JPanel();
    jpNorth = new JPanel();
    jpSouth = new JPanel();
    jpCenter = new JPanel();

    turnLabel = new JLabel();
    blackNumberLabel = new JLabel("黑棋:\n" + black + "		");
    whiteNumberLabel = new JLabel("白棋:\n" + white + "		");
    timeLabel = new JLabel("时间:  " + time + "		s");
    noticeLabel = new JLabel();

    noticeLabel = new JLabel("请选择:");
    numberPane = new JPanel();
    readyPane = new JPanel();
    jt1 = new JTextField(18); // 发送信息框
    jt2 = new JTextArea(3, 30); // 显示信息框
    js = new JScrollPane(jt2);
    jt2.setLineWrap(true);
    jt2.setEditable(false);
    //		jt1.setLineWrap(true);

    send = new JButton("发送");
    cancel = new JButton("取消");
    regret = new JButton("悔棋");
    submit = new JButton("退出");
    begin = new JButton("开始");
    save = new JButton("存盘");

    save.setEnabled(true);
    begin.setEnabled(true);

    fighter = new JRadioButton("下棋");
    audience = new JRadioButton("观看");
    group = new ButtonGroup();
    group.add(audience);
    group.add(fighter);
    group.add(AIPlayer);

    submit.addActionListener(this);
    begin.addActionListener(this);
    save.addActionListener(this);
    send.addActionListener(this);
    cancel.addActionListener(this);
    regret.addActionListener(this);
    fighter.addActionListener(this);
    audience.addActionListener(this);

    jpNorth.setLayout(new BorderLayout());
    jpNorth.add(turnLabel, BorderLayout.NORTH);
    jpNorth.add(jpCenter, BorderLayout.CENTER);
    jpSouth.add(js);
    jpSouth.add(jt1);
    jpSouth.add(send);
    jpSouth.add(cancel);
    jpEast.setLayout(new GridLayout(3, 1));
    submit.setBackground(new Color(130, 251, 241));
    panel x = new panel();
    jpEast.add(x);
    jpEast.add(numberPane);
    jpEast.add(readyPane);

    numberPane.add(blackNumberLabel);
    numberPane.add(whiteNumberLabel);
    numberPane.add(timeLabel);
    numberPane.add(submit);
    numberPane.add(begin);
    numberPane.add(save);
    numberPane.add(regret);

    readyPane.add(noticeLabel);
    readyPane.add(fighter);
    readyPane.add(audience);
    //		readyPane.add(save);
    //		readyPane.add(regret);

    jpCenter.setSize(400, 400);
    jmb = new JMenuBar();
    document = new JMenu("游戏		");
    edit = new JMenu("设置		");
    insert = new JMenu("棋盘			");
    help = new JMenu("帮助		");
    jmb.add(document);
    jmb.add(edit);
    jmb.add(insert);
    jmb.add(help);
    // mainWindow.setJMenuBar(jmb);

    mainWindow.setBounds(80, 80, 600, 600);
    mainWindow.setResizable(false);

    jsLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jpNorth, jpSouth);
    jsBase = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jsLeft, jpEast);

    mainWindow.add(jsBase);
    mainWindow.setVisible(true);
    mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jsBase.setDividerLocation(0.7);
    jsLeft.setDividerLocation(0.78);

    jpCenter.setLayout(new GridLayout(8, 8, 0, 0));
    ImageIcon key = new ImageIcon("chess1.jpg");
    for (int i = 0; i < cell.length; i++)
      for (int j = 0; j < cell.length; j++) {
        cell[i][j] = new ChessBoard(i, j);
        cell[i][j].addMouseListener(this);
        jpCenter.add(cell[i][j]);
      }

    cell[3][3].state = cell[4][4].state = '黑';
    cell[4][3].state = cell[3][4].state = '白';
    cell[3][3].taken = cell[4][4].taken = true;
    cell[4][3].taken = cell[3][4].taken = true;

    RememberState();

    new Thread(new TurnLabel(this)).start();

    file = new File("D:/" + myRole);
    try {
      fout = new FileOutputStream(file);
      out = new ObjectOutputStream(fout);
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    Connect();

    try {
      out99 = new ObjectOutputStream(socket99.getOutputStream());
      in99 = new ObjectInputStream(socket99.getInputStream());

      out66 = new ObjectOutputStream(socket66.getOutputStream());
      in66 = new ObjectInputStream(socket66.getInputStream());

      out88 = new DataOutputStream(socket88.getOutputStream());
    } catch (IOException e) {
      e.printStackTrace();
    }

    new Thread(new Client9999(this)).start();
    new Thread(new Client6666(this)).start();
  }
示例#27
0
  /**
   * Create the JPanel to allow users to save the mappings created to be used in a proceeding
   * mapping activity!
   *
   * @return JLayeredPane containing the gui to allow a user to save the mapping file!
   */
  private JLayeredPane createSaveMappings() {
    JPanel saveMappingFilesCont = new JPanel();
    saveMappingFilesCont.setSize(new Dimension(400, 300));
    saveMappingFilesCont.setLayout(new BoxLayout(saveMappingFilesCont, BoxLayout.PAGE_AXIS));

    saveMappingFilesCont.add(
        UIHelper.wrapComponentInPanel(new JLabel(saveMappingHelp, SwingConstants.CENTER)));
    saveMappingFilesCont.add(Box.createVerticalStrut(10));
    saveMappingFilesCont.add(
        UIHelper.wrapComponentInPanel(
            UIHelper.createLabel(
                ""
                    + "<html>"
                    + "Please be aware, the mappings saved are saved on a field by field basis. "
                    + "This means that regardless of what assay you selected to do this/these mappings,"
                    + " common fields amongst all assays automatically inherit the mapping information. This has a number"
                    + " of benefits and a number of negative points. "
                    + "<br/>"
                    + "<p>The <strong>main benefit</strong> being that common field mappings are transportable regardless of assay types.<p>"
                    + "<p>The <strong>main problem</strong> is that because fields are saved on a field name basis, duplicate fields like"
                    + " <strong>Protocol REF</strong> columns are not saved. This mechanism for saving will be changed in the next release!</p>"
                    + "<br/>"
                    + "<br/>"
                    + "<br/>"
                    + "</html>",
                UIHelper.VER_11_PLAIN,
                UIHelper.GREY_COLOR)));

    // create selector for mapping files
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("Choose where and what to save the file as...");
    chooser.setApproveButtonText("Select file");

    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    JPanel selectMappingPanel = new JPanel();
    selectMappingPanel.setLayout(new BoxLayout(selectMappingPanel, BoxLayout.PAGE_AXIS));
    selectMappingPanel.setOpaque(false);

    // need a jcheckbox to ask users if they wish to use a mapping
    JPanel useMappingContainer = new JPanel(new BorderLayout());
    useMappingContainer.setOpaque(false);

    final JPanel savedMappingsPanel = new JPanel();
    savedMappingsPanel.setLayout(new BoxLayout(savedMappingsPanel, BoxLayout.PAGE_AXIS));
    savedMappingsPanel.setOpaque(false);
    savedMappingsPanel.setVisible(false);

    final JLabel saveStatusInfo =
        UIHelper.createLabel("", UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR);

    final FileSelectionPanel savedMappingsFile =
        new FileSelectionPanel(
            "<html>select <strong>where</strong> to save file and <strong>it's name</strong>: </html>",
            chooser,
            FileSelectionPanel.SAVE);

    final JCheckBox useMapping = new JCheckBox("save mapping?");
    UIHelper.renderComponent(useMapping, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    useMapping.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            savedMappingsPanel.setVisible(useMapping.isSelected());
            saveStatusInfo.setText("");
          }
        });

    useMappingContainer.add(useMapping, BorderLayout.WEST);
    selectMappingPanel.add(useMappingContainer);

    // add button to save mappings
    final JLabel saveMappingsButton = new JLabel(saveMappingsButtonIcon);
    saveMappingsButton.setVerticalAlignment(JLabel.BOTTOM);
    saveMappingsButton.addMouseListener(
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            saveMappingsButton.setIcon(saveMappingsButtonIconOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            saveMappingsButton.setIcon(saveMappingsButtonIcon);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            // save the mapping

            MappingXMLCreator mappingCreator = new MappingXMLCreator();
            try {
              if (useMapping.isSelected()) {
                if (!savedMappingsFile.getSelectedFilePath().equals("")) {
                  nextButton.setEnabled(false);
                  backButton.setEnabled(false);
                  mappingCreator.createXMLFile(
                      savedMappingsFile.getSelectedFilePath(), mappingsToSave, assaysToBeDefined);
                  saveStatusInfo.setText("mappings saved successfully...");
                } else {
                  saveStatusInfo.setText("please select a file...");
                }
              }
            } catch (FileNotFoundException e) {
              e.printStackTrace();
              saveStatusInfo.setText("mappings not saved..." + e.getMessage());
            } finally {
              nextButton.setEnabled(true);
              backButton.setEnabled(true);
            }
          }
        });

    final JLayeredPane finalPanel =
        getGeneralLayout(saveMappingsHeader, breadcrumb7, "", saveMappingFilesCont, getHeight());

    final MouseListener[] listeners = new MouseListener[2];

    listeners[0] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            backButton.setIcon(backOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            backButton.setIcon(back);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            backButton.setIcon(back);
            saveStatusInfo.setText("");
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    HistoryComponent hc = previousPage.pop();
                    setCurrentPage(hc.getDisplayComponent());
                    assignListenerToLabel(backButton, hc.getListeners()[0]);
                    assignListenerToLabel(nextButton, hc.getListeners()[1]);
                  }
                });
          }
        };

    assignListenerToLabel(backButton, listeners[0]);

    listeners[1] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            nextButton.setIcon(nextOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            nextButton.setIcon(next);
          }

          public void mousePressed(MouseEvent mouseEvent) {

            nextButton.setIcon(next);
            Thread performMappingLogic =
                new Thread(
                    new Runnable() {
                      public void run() {
                        investigation =
                            MappingLogic.createInvestigation(
                                definitions, assaySelections, dataEntryEnvironment);
                        // now we need to construct the investigation from the defined table
                        // reference objects and the
                        ApplicationManager.assignDataEntryToISASection(
                            investigation,
                            new InvestigationDataEntry(investigation, dataEntryEnvironment));

                        investigation.setConfigurationCreateWith(
                            ApplicationManager.getCurrentApplicationInstance()
                                .getLoadedConfiguration());
                        investigation.setLastConfigurationUsed(
                            ApplicationManager.getCurrentApplicationInstance()
                                .getLoadedConfiguration());

                        dataEntryEnvironment.createGUIFromInvestigation(investigation);

                        previousPage.push(new HistoryComponent(finalPanel, listeners));
                        ApplicationManager.getCurrentApplicationInstance().hideGlassPane();
                        ApplicationManager.getCurrentApplicationInstance()
                            .setCurDataEntryPanel(dataEntryEnvironment);
                        ApplicationManager.getCurrentApplicationInstance()
                            .setCurrentPage(dataEntryEnvironment);
                      }
                    });

            setCurrentPage(workingProgressScreen);
            performMappingLogic.start();
          }
        };

    JPanel saveMappingsSection = new JPanel();
    saveMappingsSection.setLayout(new BoxLayout(saveMappingsSection, BoxLayout.LINE_AXIS));

    saveMappingsSection.add(savedMappingsFile);
    saveMappingsSection.add(Box.createHorizontalStrut(10));

    JPanel saveButtonContainer = new JPanel(new BorderLayout());
    saveButtonContainer.add(saveMappingsButton, BorderLayout.SOUTH);

    saveMappingsSection.add(UIHelper.wrapComponentInPanel(saveButtonContainer));

    savedMappingsPanel.add(saveMappingsSection);
    selectMappingPanel.add(savedMappingsPanel);

    saveMappingFilesCont.add(selectMappingPanel);
    saveMappingFilesCont.add(UIHelper.wrapComponentInPanel(saveStatusInfo));

    assignListenerToLabel(nextButton, listeners[1]);
    return finalPanel;
  }
示例#28
0
  private void setupComponents() {
    panel.removeAll();

    JScrollPane scrollPane1 =
        new JScrollPane(
            parametersTable,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane1.setOpaque(false);

    ActionPanel actionPanel1 = new ActionPanel(false);
    actionPanel1.setAddAction(addParameterAction);
    actionPanel1.setRemoveAction(removeParameterAction);
    actionPanel1.setAddToolTipText("Use this button to add an existing parameter to the prior");
    actionPanel1.setRemoveToolTipText("Use this button to remove a parameter from the prior");

    removeParameterAction.setEnabled(false);

    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.setOpaque(false);
    controlPanel1.add(actionPanel1);

    JPanel panel1 = new JPanel(new BorderLayout(0, 0));
    panel1.setOpaque(false);
    panel1.add(new JLabel("Linked parameters:"), BorderLayout.NORTH);
    panel1.add(scrollPane1, BorderLayout.CENTER);

    // removing the control panel for now. Not sure whether we really want adding and
    // removing of parameteres in this dialog.
    //        panel1.add(controlPanel1, BorderLayout.SOUTH);
    panel1.setSize(new Dimension(PREFERRED_TABLE_WIDTH, PREFERRED_TABLE_HEIGHT));
    panel1.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, PREFERRED_TABLE_HEIGHT));
    panel1.setMinimumSize(new Dimension(MINIMUM_TABLE_WIDTH, MINIMUM_TABLE_HEIGHT));

    OptionsPanel optionsPanel = new OptionsPanel(0, 6);
    if (parameter.getName() != null) {
      nameField.setText(parameter.getName());
    } else {
      nameField.setText("Untitled");
    }
    optionsPanel.addComponentWithLabel("Unique Name: ", nameField);
    //        optionsPanel.addComponentWithLabel("Initial Value: ", initialField);

    panel.setOpaque(false);
    panel.setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12)));

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.PAGE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 2;
    panel.add(optionsPanel, c);

    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.PAGE_START;
    c.fill = GridBagConstraints.VERTICAL;
    c.gridwidth = 1;
    panel.add(panel1, c);

    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.PAGE_START;
    c.gridwidth = GridBagConstraints.REMAINDER;
    panel.add(priorSettingsPanel, c);
  }
  // Constructor connection receiving a socket number
  public ClientGUI(String host, int port, int udpPort) {

    super("Clash of Clans");
    defaultPort = port;
    defaultUDPPort = udpPort;
    defaultHost = host;

    // the server name and the port number
    JPanel serverAndPort = new JPanel(new GridLayout(1, 5, 1, 3));
    tfServer = new JTextField(host);
    tfPort = new JTextField("" + port);
    tfPort.setHorizontalAlignment(SwingConstants.RIGHT);

    // CHAT COMPONENTS
    chatStatus = new JLabel("Please login first", SwingConstants.LEFT);
    chatField = new JTextField(18);
    chatField.setBackground(Color.WHITE);

    JPanel chatControls = new JPanel();
    chatControls.add(chatStatus);
    chatControls.add(chatField);
    chatControls.setBounds(0, 0, 200, 50);

    chatArea = new JTextArea("Welcome to the Chat room\n", 80, 80);
    chatArea.setEditable(false);
    JScrollPane jsp = new JScrollPane(chatArea);
    jsp.setBounds(0, 50, 200, 550);

    JPanel chatPanel = new JPanel(null);
    chatPanel.setSize(1000, 600);
    chatPanel.add(chatControls);
    chatPanel.add(jsp);

    // LOGIN COMPONENTS
    mainLogin = new MainPanel();
    mainLogin.add(new JLabel("Main Login"));

    usernameField = new JTextField("user", 15);
    passwordField = new JTextField("password", 15);
    login = new CButton("Login");
    login.addActionListener(this);

    sideLogin = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    sideLogin.add(usernameField);
    sideLogin.add(passwordField);
    sideLogin.add(login);

    // MAIN MENU COMPONENTS
    mainMenu = new MainPanel();
    mmLabel = new JLabel("Main Menu");
    timer = new javax.swing.Timer(1000, this);
    mainMenu.add(mmLabel);

    sideMenu = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    cmButton = new CButton("Customize Map");
    tmButton = new CButton("Troop Movement");
    gsButton = new CButton("Game Start");
    logout = new CButton("Logout");
    cmButton.addActionListener(this);
    tmButton.addActionListener(this);
    gsButton.addActionListener(this);
    logout.addActionListener(this);
    sideMenu.add(cmButton);
    // sideMenu.add(tmButton);
    sideMenu.add(gsButton);
    sideMenu.add(logout);

    // CM COMPONENTS
    mainCM = new MainPanel(new GridLayout(mapSize, mapSize));
    tiles = new Tile[mapSize][mapSize];
    int tileSize = mainCM.getWidth() / mapSize;
    for (int i = 0; i < mapSize; i++) {
      tiles[i] = new Tile[mapSize];
      for (int j = 0; j < mapSize; j++) {
        tiles[i][j] = new Tile(i, j);
        tiles[i][j].setPreferredSize(new Dimension(tileSize, tileSize));
        tiles[i][j].setSize(tileSize, tileSize);
        tiles[i][j].addActionListener(this);

        if ((i + j) % 2 == 0) tiles[i][j].setBackground(new Color(102, 255, 51));
        else tiles[i][j].setBackground(new Color(51, 204, 51));

        mainCM.add(tiles[i][j]);
      }
    }

    sideCM = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    cmBack = new CButton("Main Menu");
    cmBack.setSize(150, 30);
    cmBack.setPreferredSize(new Dimension(150, 30));
    cmBack.addActionListener(this);
    sideCM.add(cmBack);

    // TM COMPONENTS
    mainTM = new MainPanel(null);
    mapTM = new Map(600);
    mapTM.setPreferredSize(new Dimension(600, 600));
    mapTM.setSize(600, 600);
    mapTM.setBounds(0, 0, 600, 600);
    mainTM.add(mapTM);

    sideTM = new SidePanel(new FlowLayout(FlowLayout.LEFT));
    tmBack = new CButton("Main Menu");
    tmBack.setSize(150, 30);
    tmBack.setPreferredSize(new Dimension(150, 30));
    tmBack.addActionListener(this);
    sideTM.add(tmBack);

    JRadioButton button;
    ButtonGroup group;

    ub = new ArrayList<JRadioButton>();
    group = new ButtonGroup();

    button = new JRadioButton("Barbarian");
    button.addActionListener(this);
    ub.add(button);
    sideTM.add(button);
    group.add(button);

    button = new JRadioButton("Archer");
    button.addActionListener(this);
    ub.add(button);
    sideTM.add(button);
    group.add(button);

    createBuildings();
    bb = new ArrayList<JRadioButton>();

    group = new ButtonGroup();

    JRadioButton removeButton = new JRadioButton("Remove Building");
    bb.add(removeButton);
    sideCM.add(removeButton);
    group.add(removeButton);

    for (int i = 0; i < bList.size(); i++) {
      button = new JRadioButton(bList.get(i).getName() + '-' + bList.get(i).getQuantity());
      bb.add(button);
      sideCM.add(button);
      group.add(button);
    }

    mainPanels = new MainPanel(new CardLayout());
    mainPanels.add(mainLogin, "Login");
    mainPanels.add(mainMenu, "Menu");
    mainPanels.add(mainCM, "CM");
    mainPanels.add(mainTM, "TM");

    sidePanels = new SidePanel(new CardLayout());
    sidePanels.add(sideLogin, "Login");
    sidePanels.add(sideMenu, "Menu");
    sidePanels.add(sideCM, "CM");
    sidePanels.add(sideTM, "TM");

    JPanel mainPanel = new JPanel(null);
    mainPanel.setSize(1000, 600);
    mainPanel.add(sidePanels);
    mainPanel.add(mainPanels);
    mainPanel.add(chatPanel);

    add(mainPanel, BorderLayout.CENTER);

    try {
      setIconImage(ImageIO.read(new File("images/logo.png")));
    } catch (IOException exc) {
      exc.printStackTrace();
    }

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(1000, 600);
    setVisible(true);
    setResizable(false);
    chatField.requestFocus();
  }
示例#30
0
  /**
   * Create JPanel asking users to select the file or directory containing files to be mapped and an
   * existing mapping file if they have one.
   *
   * @return JPanel containing elements!
   */
  private JLayeredPane createSelectFilesPanel() {
    // create overall panel

    final JPanel selectFilesContainer = new JPanel();
    selectFilesContainer.setSize(new Dimension(400, 100));
    selectFilesContainer.setLayout(new BoxLayout(selectFilesContainer, BoxLayout.PAGE_AXIS));

    // create selector for mapping files
    final FileSelectionPanel fileToMapFSP =
        new FileSelectionPanel(
            "<html>please select file(s) to be mapped (txt, csv or xls (Excel). Please ensure "
                + "that this file has <b>no empty columns</b> and if possible, please remove any special characters, e.g. &mu;</html>",
            fileChooser);
    selectFilesContainer.add(fileToMapFSP);

    JPanel selectMappingPanel = new JPanel();
    selectMappingPanel.setLayout(new BoxLayout(selectMappingPanel, BoxLayout.PAGE_AXIS));
    selectMappingPanel.setOpaque(false);

    // need a jcheckbox to ask users if they wish to use a mapping
    JPanel useMappingContainer = new JPanel(new BorderLayout());
    useMappingContainer.setOpaque(false);

    // need a file selection panel to select the file.
    JFileChooser mappingFileChooser = new JFileChooser();
    mappingFileChooser.setDialogTitle("Choose mapping file (XML)");
    mappingFileChooser.setApproveButtonText("select file");
    mappingFileChooser.setFont(UIHelper.VER_11_PLAIN);
    mappingFileChooser.setFileFilter(new CustomizableFileFilter("xml"));

    final FileSelectionPanel savedMappingsFile =
        new FileSelectionPanel(
            "<html>please select saved mapping file (xml): </html>", mappingFileChooser);
    savedMappingsFile.setVisible(false);

    final JCheckBox useMapping = new JCheckBox("use a previous mapping?");
    UIHelper.renderComponent(useMapping, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    useMapping.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            savedMappingsFile.setVisible(useMapping.isSelected());
          }
        });

    useMappingContainer.add(useMapping, BorderLayout.WEST);

    selectMappingPanel.add(useMappingContainer);

    selectMappingPanel.add(savedMappingsFile);

    selectFilesContainer.add(selectMappingPanel);

    final RoundedJTextField rowOffset = new RoundedJTextField(3);
    rowOffset.setEnabled(false);
    rowOffset.setSize(new Dimension(20, 20));
    rowOffset.setText("1");

    final JCheckBox overrideRowPosition = new JCheckBox("override row start position?");
    UIHelper.renderComponent(overrideRowPosition, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    overrideRowPosition.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            rowOffset.setEnabled(overrideRowPosition.isSelected());
          }
        });

    Box fileInputPanel = Box.createHorizontalBox();
    fileInputPanel.setSize(new Dimension(100, 20));
    fileInputPanel.add(overrideRowPosition);
    fileInputPanel.add(Box.createHorizontalStrut(5));
    fileInputPanel.add(rowOffset);

    selectFilesContainer.add(fileInputPanel);

    selectFilesContainer.add(selectMappingPanel);

    final JCheckBox mapToBlankFieldsCheckbox = new JCheckBox("Do not remove blank fields?", false);
    UIHelper.renderComponent(
        mapToBlankFieldsCheckbox, UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR, false);
    mapToBlankFieldsCheckbox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            mapToBlankFields = mapToBlankFieldsCheckbox.isSelected();
          }
        });

    JPanel removeBlanksContainer = new JPanel(new BorderLayout());
    removeBlanksContainer.setOpaque(false);

    removeBlanksContainer.add(mapToBlankFieldsCheckbox, BorderLayout.WEST);

    selectFilesContainer.add(removeBlanksContainer);

    JPanel statusPanel = new JPanel(new GridLayout(1, 1));
    statusPanel.setPreferredSize(new Dimension(400, 30));
    final JLabel statusLab = UIHelper.createLabel("", UIHelper.VER_11_BOLD, UIHelper.RED_COLOR);
    statusPanel.add(statusLab);

    selectFilesContainer.add(statusPanel);

    final JLayeredPane finalLayout =
        getGeneralLayout(selectFilesHeader, breadcrumb1, "", selectFilesContainer, getHeight());

    final MouseListener[] listeners = new MouseListener[2];

    listeners[0] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            backButton.setIcon(backOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            backButton.setIcon(back);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            backButton.setIcon(back);
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    ApplicationManager.getCurrentApplicationInstance().setCurrentPage(menuPanels);
                    ApplicationManager.getCurrentApplicationInstance()
                        .setGlassPanelContents(menuPanels.getCreateISAMenuGUI());
                    menuPanels.startAnimation();
                  }
                });
          }
        };

    assignListenerToLabel(backButton, listeners[0]);

    listeners[1] =
        new MouseAdapter() {

          public void mouseEntered(MouseEvent mouseEvent) {
            nextButton.setIcon(nextOver);
          }

          public void mouseExited(MouseEvent mouseEvent) {
            nextButton.setIcon(next);
          }

          public void mousePressed(MouseEvent mouseEvent) {
            nextButton.setIcon(next);

            Thread loadFile =
                new Thread(
                    new Runnable() {
                      public void run() {
                        ISAcreatorProperties.setProperty(
                            "isacreator.rowOffset",
                            rowOffset.isEnabled() ? rowOffset.getText() : "1");

                        if (useMapping.isSelected()) {

                          if (!savedMappingsFile.getSelectedFilePath().trim().equals("")) {

                            MappingXMLLoader loader =
                                new MappingXMLLoader(savedMappingsFile.getSelectedFilePath());
                            try {
                              preExistingMapping = loader.loadMappings();
                            } catch (XmlException e) {
                              log.error(e.getMessage());
                              statusLab.setText(
                                  "<html>problem found in xml for saved mapping: "
                                      + e.getMessage()
                                      + " </html>");
                              setCurrentPage(lastPage);
                              return;
                            } catch (IOException e) {
                              log.error(e.getMessage());
                              statusLab.setText(
                                  "<html>problem found when resolving file for saved mapping: "
                                      + e.getMessage()
                                      + " </html>");
                              setCurrentPage(lastPage);
                              return;
                            }
                          } else {
                            statusLab.setText(
                                "<html>please select a file containing previous mappings...</html>");
                            setCurrentPage(lastPage);
                            return;
                          }
                        } else {
                          log.info("Mapping is not selected");
                          statusLab.setText("");
                        }

                        if (fileToMapFSP.notEmpty()) {
                          previousPage.push(new HistoryComponent(finalLayout, listeners));
                          statusLab.setText("");
                          SwingUtilities.invokeLater(
                              new Runnable() {
                                public void run() {
                                  setCurrentPage(
                                      createAssayUsedPanel(fileToMapFSP.getSelectedFilePath()));
                                }
                              });
                        } else {
                          statusLab.setText(
                              "<html>please <strong>select</strong> a file to map!</html>");
                          setCurrentPage(lastPage);
                        }
                      }
                    });

            if (fileToMapFSP.notEmpty()
                && fileToMapFSP.checkFileExtensionValid("xls", "csv", "txt")) {
              statusLab.setText("");
              lastPage = currentPage;
              setCurrentPage(workingProgressScreen);
              loadFile.start();
            } else {
              statusLab.setText(
                  "<html>please select a file with the extension <strong>.xls</strong>, <strong>.csv</strong> or <strong>.txt</strong>...</html>");
            }
          }
        };
    assignListenerToLabel(nextButton, listeners[1]);
    return finalLayout;
  }