private void setLayout() {
   GroupLayout layout = new GroupLayout(dialog.getContentPane());
   dialog.getContentPane().setLayout(layout);
   dialog.setResizable(true);
   layout.setAutoCreateContainerGaps(true);
   layout.setHorizontalGroup(layout.createParallelGroup().addComponent(tabbedPane));
   layout.setVerticalGroup(layout.createParallelGroup().addComponent(tabbedPane));
   layout.setHonorsVisibility(tabbedPane, true);
   // TODO set color here
   dialog.getContentPane().setBackground(new Color(0x132638));
   dialog.validate();
   dialog.repaint();
 }
Ejemplo n.º 2
0
  public MainFrame() {
    super("P2 Auto Update and Automatic Build Test");

    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      System.out.println("Error loading System Look and Feel: " + e.getMessage());
      try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      } catch (Exception ex) {
        System.out.println("Error loading CrossPlatform Look and Feel: " + e.getMessage());
      }
    }

    LabelOne one = new LabelOne();
    LabelTwo two = new LabelTwo();
    LabelThree three = new LabelThree();
    LabelFour four = new LabelFour();

    JPanel mainPanel = new JPanel();
    GroupLayout layout = new GroupLayout(mainPanel);
    mainPanel.setLayout(layout);

    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);

    layout.setHorizontalGroup(
        layout
            .createParallelGroup()
            .addComponent(one)
            .addComponent(two)
            .addComponent(three)
            .addComponent(four));

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addComponent(one)
            .addComponent(two)
            .addComponent(three)
            .addComponent(four));

    this.addWindowListener(this);

    this.add(mainPanel);
    this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    this.pack();
    this.setVisible(true);
  }
Ejemplo n.º 3
0
  /**
   * Universally creates layout for dialog.
   *
   * @param jcs
   */
  protected final void createLayout(JComponent... jcs) {
    Container pane = getContentPane();
    GroupLayout gl = new GroupLayout(pane);
    pane.setLayout(gl);

    gl.setAutoCreateContainerGaps(true);
    gl.setAutoCreateGaps(true);

    GroupLayout.ParallelGroup pg = gl.createParallelGroup(CENTER);

    for (JComponent jc : jcs) {
      pg.addComponent(jc).addGap(200);
    }
    gl.setHorizontalGroup(pg);

    GroupLayout.SequentialGroup sg = gl.createSequentialGroup();

    for (JComponent jc : jcs) {
      sg.addGap(30).addComponent(jc).addGap(20);
    }
    gl.setVerticalGroup(sg);

    pack();
  }
Ejemplo n.º 4
0
  protected void buildErrorPanel() {
    errorPanel = new JPanel();
    GroupLayout layout = new GroupLayout(errorPanel);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    errorPanel.setLayout(layout);
    //    errorPanel.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
    errorMessage = new JTextPane();
    errorMessage.setEditable(false);
    errorMessage.setContentType("text/html");
    errorMessage.setText(
        "<html><body>Could not connect to the Processing server.<br>"
            + "Contributions cannot be installed or updated without an Internet connection.<br>"
            + "Please verify your network connection again, then try connecting again.</body></html>");
    errorMessage.setFont(Toolkit.getSansFont(14, Font.PLAIN));
    errorMessage.setMaximumSize(new Dimension(550, 50));
    errorMessage.setOpaque(false);

    StyledDocument doc = errorMessage.getStyledDocument();
    SimpleAttributeSet center = new SimpleAttributeSet();
    StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
    doc.setParagraphAttributes(0, doc.getLength(), center, false);

    closeButton = new JButton("X");
    closeButton.setContentAreaFilled(false);
    closeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            contribDialog.makeAndShowTab(false, false);
          }
        });
    tryAgainButton = new JButton("Try Again");
    tryAgainButton.setFont(Toolkit.getSansFont(14, Font.PLAIN));
    tryAgainButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            contribDialog.makeAndShowTab(false, true);
            contribDialog.downloadAndUpdateContributionListing(editor.getBase());
          }
        });
    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.CENTER)
                    .addComponent(errorMessage)
                    .addComponent(
                        tryAgainButton,
                        StatusPanel.BUTTON_WIDTH,
                        StatusPanel.BUTTON_WIDTH,
                        StatusPanel.BUTTON_WIDTH))
            .addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addComponent(closeButton));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout.createParallelGroup().addComponent(errorMessage).addComponent(closeButton))
            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(tryAgainButton));
    errorPanel.setBackground(Color.PINK);
    errorPanel.validate();
  }
Ejemplo n.º 5
0
  public FindReplaceDialog(RobocodeEditor owner) {
    super(owner, false);
    editor = owner;

    GroupLayout layout = new GroupLayout(getContentPane());

    getContentPane().setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    JPanel optionsPanel = new JPanel();

    optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));
    optionsPanel.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Options"));
    optionsPanel.add(getCaseSensitiveCheckBox());
    optionsPanel.add(getWholeWordCheckBox());
    optionsPanel.setAlignmentY(TOP_ALIGNMENT);

    JPanel usePanel = new JPanel();

    usePanel.setLayout(new BoxLayout(usePanel, BoxLayout.Y_AXIS));
    usePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Use"));
    usePanel.add(getLiteralButton());
    usePanel.add(getWildCardsButton());
    usePanel.add(getRegexButton());
    usePanel.setAlignmentY(TOP_ALIGNMENT);

    ButtonGroup buttonGroup = new ButtonGroup();

    buttonGroup.add(getLiteralButton());
    buttonGroup.add(getWildCardsButton());
    buttonGroup.add(getRegexButton());

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(LEADING)
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getFindLabel())
                            .addComponent(getFindTextField()))
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getReplaceLabel())
                            .addComponent(getReplaceTextField()))
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(optionsPanel)
                            .addComponent(usePanel)))
            .addGroup(
                layout
                    .createParallelGroup(LEADING)
                    .addComponent(getFindNextButton())
                    .addComponent(getReplaceFindButton())
                    .addComponent(getReplaceButton())
                    .addComponent(getReplaceAllButton())
                    .addComponent(getCloseButton())));

    layout.linkSize(SwingConstants.HORIZONTAL, getFindLabel(), getReplaceLabel());
    layout.linkSize(
        SwingConstants.HORIZONTAL,
        getFindNextButton(),
        getReplaceFindButton(),
        getReplaceButton(),
        getReplaceAllButton(),
        getCloseButton());

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(getFindLabel())
                    .addComponent(getFindTextField())
                    .addComponent(getFindNextButton()))
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(getReplaceLabel())
                    .addComponent(getReplaceTextField())
                    .addComponent(getReplaceButton()))
            .addGroup(
                layout
                    .createParallelGroup(BASELINE)
                    .addComponent(optionsPanel)
                    .addComponent(usePanel)
                    .addGroup(
                        layout
                            .createSequentialGroup()
                            .addComponent(getReplaceFindButton())
                            .addComponent(getReplaceAllButton())
                            .addComponent(getCloseButton()))));

    pack();
    setResizable(false);
  }
Ejemplo n.º 6
0
 private void initGUI() {
   /** 北部panel */
   Font font_12 = new Font("微软雅黑", Font.PLAIN, 14);
   /** 设置字体 */
   crackButton.setFont(font_12);
   northPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
   northPane.setBorder(BorderFactory.createTitledBorder("破解地址"));
   GroupLayout layout_north = new GroupLayout(northPane);
   northPane.setLayout(layout_north);
   /** 自动设定组件、组之间的间隙 */
   layout_north.setAutoCreateGaps(true);
   layout_north.setAutoCreateContainerGaps(true);
   /** 垂直一 */
   GroupLayout.ParallelGroup hpg_north_1 =
       layout_north.createParallelGroup(GroupLayout.Alignment.LEADING);
   hpg_north_1.addComponent(label_for_pageUrl);
   /** 垂直二 */
   GroupLayout.ParallelGroup hpg_north_2 =
       layout_north.createParallelGroup(GroupLayout.Alignment.LEADING);
   hpg_north_2.addComponent(pageUrl);
   /** 垂直三 */
   GroupLayout.ParallelGroup hpg_north_3 =
       layout_north.createParallelGroup(GroupLayout.Alignment.LEADING);
   hpg_north_3.addComponent(crackButton);
   /** 垂直 */
   layout_north.setHorizontalGroup(
       layout_north
           .createSequentialGroup()
           .addGroup(hpg_north_1)
           .addGroup(hpg_north_2)
           .addGroup(hpg_north_3));
   /** 水平一 */
   GroupLayout.ParallelGroup vpg_north_1 =
       layout_north.createParallelGroup(GroupLayout.Alignment.CENTER);
   vpg_north_1.addComponent(label_for_pageUrl).addComponent(pageUrl).addComponent(crackButton);
   /** 水平 */
   layout_north.setVerticalGroup(layout_north.createSequentialGroup().addGroup(vpg_north_1));
   this.add(northPane, BorderLayout.NORTH);
   /** 南部panel */
   mCode.setColumns(50);
   regCode.setColumns(50);
   mCode.setEditable(false);
   southPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
   southPane.setBorder(BorderFactory.createTitledBorder("软件注册"));
   southPane.add(label_for_mCode);
   southPane.add(mCode);
   southPane.add(label_for_regCode);
   southPane.add(regCode);
   /** 新增为布局的南部 */
   this.add(southPane, BorderLayout.SOUTH);
   /** 中部panel */
   videoInfo = new JPanel();
   videoInfo.setBorder(BorderFactory.createTitledBorder("视频信息"));
   GroupLayout layout = new GroupLayout(videoInfo);
   videoInfo.setLayout(layout);
   /** 自动设定组件、组之间的间隙 */
   layout.setAutoCreateGaps(true);
   layout.setAutoCreateContainerGaps(true);
   JButton cancelButton = new JButton("Cancel");
   /** LEADING -- 左对齐 BASELINE -- 底部对齐 CENTER -- 中心对齐 */
   /** 垂直一 */
   GroupLayout.ParallelGroup hpg1 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
   hpg1.addComponent(label_for_title)
       .addComponent(label_for_time)
       .addComponent(label_for_addTime)
       .addComponent(label_for_imgPre)
       .addComponent(label_for_crack_video)
       .addComponent(label_for_fileSize);
   /** 垂直二 */
   GroupLayout.ParallelGroup hpg2 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
   hpg2.addComponent(title)
       .addComponent(time)
       .addComponent(addTime)
       .addComponent(image)
       .addComponent(crackVideo)
       .addComponent(fileSize);
   /** 垂直三 */
   GroupLayout.ParallelGroup hpg3 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
   hpg3.addComponent(cancelButton);
   /** 垂直 */
   layout.setHorizontalGroup(
       layout.createSequentialGroup().addGroup(hpg1).addGroup(hpg2).addGroup(hpg3));
   /** 设定两个Button在水平方向一样宽 */
   //        layout.linkSize(SwingConstants.HORIZONTAL, new Component[]{crackButton,
   // cancelButton});
   /** 水平一 */
   GroupLayout.ParallelGroup vpg1 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
   //        vpg1.addComponent(crackButton);
   /** 水平二 */
   GroupLayout.ParallelGroup vpg2 = layout.createParallelGroup(GroupLayout.Alignment.CENTER);
   vpg2.addComponent(label_for_title).addComponent(title).addComponent(cancelButton);
   /** 水平三 */
   GroupLayout.ParallelGroup vpg3 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
   vpg3.addComponent(label_for_time).addComponent(time);
   /** 水平四 */
   GroupLayout.ParallelGroup vpg4 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
   vpg4.addComponent(label_for_addTime).addComponent(addTime);
   /** 水平五 */
   GroupLayout.ParallelGroup vpg5 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
   vpg5.addComponent(label_for_imgPre).addComponent(image);
   /** 水平六 */
   GroupLayout.ParallelGroup vpg6 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
   vpg6.addComponent(label_for_crack_video).addComponent(crackVideo);
   /** 水平七 */
   GroupLayout.ParallelGroup vpg7 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
   vpg7.addComponent(label_for_fileSize).addComponent(fileSize);
   /** 水平 */
   layout.setVerticalGroup(
       layout
           .createSequentialGroup()
           .addGroup(vpg1)
           .addGroup(vpg2)
           .addGroup(vpg3)
           .addGroup(vpg4)
           .addGroup(vpg5)
           .addGroup(vpg6)
           .addGroup(vpg7));
   this.add(videoInfo, BorderLayout.CENTER);
 }
Ejemplo n.º 7
0
  public void createGUI() {

    JButton submitButton = new JButton("Submit");
    submitButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            // get text from input fields
            inputPath = inputField.getText();
            outputPath = outputField.getText();

            buttonPressed = true;
          }
        });

    JPanel inputPanel = new JPanel();
    inputPanel.add(new JLabel("Input Path"));
    inputPanel.add(inputField);

    JLabel inputLabel = new JLabel("Input Path");
    JLabel outputLabel = new JLabel("Output Path");

    JPanel content = new JPanel();
    content.setLayout(new BorderLayout());

    JPanel textFieldsContent = new JPanel();
    GroupLayout layout = new GroupLayout(textFieldsContent);
    textFieldsContent.setLayout(layout);

    // setting to true creates gaps between components
    layout.setAutoCreateGaps(true);
    // setting to true creates gaps between components and edge of container
    layout.setAutoCreateContainerGaps(true);

    // horizontal axis
    GroupLayout.SequentialGroup horizontalGroup = layout.createSequentialGroup();
    // each sequential group contains two parallel groups.
    //  one will contain labels, other will contain text fields
    horizontalGroup.addGroup(
        layout.createParallelGroup().addComponent(inputLabel).addComponent(outputLabel));
    horizontalGroup.addGroup(
        layout.createParallelGroup().addComponent(inputField).addComponent(outputField));
    layout.setHorizontalGroup(horizontalGroup);

    // vertical axis
    GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup();
    verticalGroup.addGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(inputLabel)
            .addComponent(inputField));
    verticalGroup.addGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.BASELINE)
            .addComponent(outputLabel)
            .addComponent(outputField));
    layout.setVerticalGroup(verticalGroup);

    content.add(textFieldsContent, BorderLayout.CENTER);
    content.add(submitButton, BorderLayout.PAGE_END);

    window.setContentPane(content);
    window.setSize(350, 200);
    window.setLocation(100, 100);
    window.setVisible(true);
  }
Ejemplo n.º 8
0
  public fileBackupProgram(JFrame frame) {
    super(new BorderLayout());
    this.frame = frame;

    errorDialog = new CustomDialog(frame, "Please enter a new name for the error log", this);
    errorDialog.pack();

    moveDialog = new CustomDialog(frame, "Please enter a new name for the move log", this);
    moveDialog.pack();

    printer = new FilePrinter();
    timers = new ArrayList<>();
    log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    JScrollPane logScrollPane = new JScrollPane(log);
    Object obj;
    copy = true;
    listModel = new DefaultListModel();
    // destListModel = new DefaultListModel();
    directoryList = new directoryStorage();

    // Create a file chooser
    fc = new JFileChooser();

    // Create the menu bar.
    menuBar = new JMenuBar();

    // Build the first menu.
    menu = new JMenu("File");
    menu.getAccessibleContext()
        .setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    editError = new JMenuItem("Save Error Log As...");
    editError
        .getAccessibleContext()
        .setAccessibleDescription("Change the name of the error log file");
    editError.addActionListener(new ErrorListener());
    menu.add(editError);

    editMove = new JMenuItem("Save Move Log As...");
    editMove
        .getAccessibleContext()
        .setAccessibleDescription("Change the name of the move log file");
    editMove.addActionListener(new MoveListener());
    menu.add(editMove);

    exit = new JMenuItem("Exit");
    exit.getAccessibleContext().setAccessibleDescription("Exit the Program");
    exit.addActionListener(new CloseListener());
    menu.add(exit);
    frame.setJMenuBar(menuBar);
    // Uncomment one of the following lines to try a different
    // file selection mode.  The first allows just directories
    // to be selected (and, at least in the Java look and feel,
    // shown).  The second allows both files and directories
    // to be selected.  If you leave these lines commented out,
    // then the default mode (FILES_ONLY) will be used.
    //
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    openButton = new JButton(openString);
    openButton.setActionCommand(openString);
    openButton.addActionListener(new OpenListener());

    destButton = new JButton(destString);
    destButton.setActionCommand(destString);
    destButton.addActionListener(new DestListener());

    // Create the save button.  We use the image from the JLF
    // Graphics Repository (but we extracted it from the jar).
    saveButton = new JButton(saveString);
    saveButton.setActionCommand(saveString);
    saveButton.addActionListener(new SaveListener());

    URL imageURL = getClass().getResource(greenButtonIcon);
    ImageIcon greenSquare = new ImageIcon(imageURL);
    startButton = new JButton("Start", greenSquare);
    startButton.setSize(60, 20);
    startButton.setHorizontalTextPosition(AbstractButton.LEADING);
    startButton.setActionCommand("Start");
    startButton.addActionListener(new StartListener());

    imageURL = getClass().getResource(redButtonIcon);
    ImageIcon redSquare = new ImageIcon(imageURL);
    stopButton = new JButton("Stop", redSquare);
    stopButton.setSize(60, 20);
    stopButton.setHorizontalTextPosition(AbstractButton.LEADING);
    stopButton.setActionCommand("Stop");
    stopButton.addActionListener(new StopListener());

    copyButton = new JRadioButton("Copy");
    copyButton.setActionCommand("Copy");
    copyButton.setSelected(true);
    copyButton.addActionListener(new RadioListener());

    moveButton = new JRadioButton("Move");
    moveButton.setActionCommand("Move");
    moveButton.addActionListener(new RadioListener());

    ButtonGroup group = new ButtonGroup();
    group.add(copyButton);
    group.add(moveButton);

    // For layout purposes, put the buttons in a separate panel

    JPanel optionPanel = new JPanel();

    GroupLayout layout = new GroupLayout(optionPanel);
    optionPanel.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout.createSequentialGroup().addComponent(copyButton).addComponent(moveButton));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(copyButton)
                    .addComponent(moveButton)));

    JPanel buttonPanel = new JPanel(); // use FlowLayout

    layout = new GroupLayout(buttonPanel);
    buttonPanel.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(openButton)
                    .addComponent(optionPanel))
            .addComponent(destButton)
            .addComponent(startButton)
            .addComponent(stopButton)
        // .addComponent(saveButton)
        );
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(openButton)
                    .addComponent(destButton)
                    .addComponent(startButton)
                    .addComponent(stopButton)
                // .addComponent(saveButton)
                )
            .addComponent(optionPanel));

    buttonPanel.add(optionPanel);
    /*
    buttonPanel.add(openButton);
    buttonPanel.add(destButton);
    buttonPanel.add(startButton);
    buttonPanel.add(stopButton);
    buttonPanel.add(saveButton);
    buttonPanel.add(listLabel);
    buttonPanel.add(copyButton);
    buttonPanel.add(moveButton);
    */
    destButton.setEnabled(false);
    startButton.setEnabled(false);
    stopButton.setEnabled(false);

    // Add the buttons and the log to this panel.

    // add(logScrollPane, BorderLayout.CENTER);

    JLabel listLabel = new JLabel("Monitored Directory:");
    listLabel.setLabelFor(list);

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);
    list.setVisibleRowCount(8);
    JScrollPane listScrollPane = new JScrollPane(list);
    JPanel listPane = new JPanel();
    listPane.setLayout(new BorderLayout());

    listPane.add(listLabel, BorderLayout.PAGE_START);
    listPane.add(listScrollPane, BorderLayout.CENTER);

    listSelectionModel = list.getSelectionModel();
    listSelectionModel.addListSelectionListener(new SharedListSelectionHandler());
    // monitored, destination, waitInt, check

    destination = new JLabel("Destination Directory: ");

    waitField = new JFormattedTextField();
    // waitField.setValue(240);
    waitField.setEditable(false);
    waitField.addPropertyChangeListener(new FormattedTextListener());

    waitInt = new JLabel("Wait Interval (in minutes)");
    // waitInt.setLabelFor(waitField);

    checkField = new JFormattedTextField();
    checkField.setSize(1, 10);
    // checkField.setValue(60);
    checkField.setEditable(false);
    checkField.addPropertyChangeListener(new FormattedTextListener());

    check = new JLabel("Check Interval (in minutes)");
    // check.setLabelFor(checkField);

    fireButton = new JButton(fireString);
    fireButton.setActionCommand(fireString);
    fireButton.addActionListener(new FireListener());

    JPanel fieldPane = new JPanel();
    // fieldPane.add(destField);
    layout = new GroupLayout(fieldPane);
    fieldPane.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(waitInt)
                    .addComponent(check))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(waitField, 60, 60, 60)
                    .addComponent(checkField, 60, 60, 60)));

    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(waitInt)
                    .addComponent(waitField))
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(check)
                    .addComponent(checkField)));

    JPanel labelPane = new JPanel();

    labelPane.setLayout(new BorderLayout());

    labelPane.add(destination, BorderLayout.PAGE_START);
    labelPane.add(fieldPane, BorderLayout.CENTER);

    layout = new GroupLayout(labelPane);
    labelPane.setLayout(layout);

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(destination)
                    .addComponent(fieldPane)));

    layout.setVerticalGroup(
        layout.createSequentialGroup().addComponent(destination).addComponent(fieldPane));
    // labelPane.add(destination);
    // labelPane.add(fieldPane);

    try {
      // Read from disk using FileInputStream
      FileInputStream f_in = new FileInputStream(LOG_DIRECTORY + "\\save.data");

      // Read object using ObjectInputStream
      ObjectInputStream obj_in = new ObjectInputStream(f_in);

      // Read an object
      directoryList = (directoryStorage) obj_in.readObject();
      ERROR_LOG_NAME = (String) obj_in.readObject();
      MOVE_LOG_NAME = (String) obj_in.readObject();

      if (ERROR_LOG_NAME instanceof String) {
        printer.changeErrorLogName(ERROR_LOG_NAME);
      }

      if (MOVE_LOG_NAME instanceof String) {
        printer.changeMoveLogName(MOVE_LOG_NAME);
      }

      if (directoryList instanceof directoryStorage) {
        System.out.println("found object");
        // directoryList = (directoryStorage) obj;

        Iterator<Directory> directories = directoryList.getDirectories();
        Directory d;
        while (directories.hasNext()) {
          d = directories.next();

          try {
            listModel.addElement(d.getDirectory().toRealPath());
          } catch (IOException x) {
            printer.printError(x.toString());
          }

          int index = list.getSelectedIndex();
          if (index == -1) {
            list.setSelectedIndex(0);
          }

          index = list.getSelectedIndex();
          Directory dir = directoryList.getDirectory(index);

          destButton.setEnabled(true);
          checkField.setValue(dir.getInterval());
          waitField.setValue(dir.getWaitInterval());
          checkField.setEditable(true);
          waitField.setEditable(true);

          // directoryList.addNewDirectory(d);
          // try {
          // listModel.addElement(d.getDirectory().toString());
          // } catch (IOException x) {
          // printer.printError(x.toString());
          // }

          // timer = new Timer();
          // timer.schedule(new CopyTask(d.directory, d.destination, d.getWaitInterval(), printer,
          // d.copy), 0, d.getInterval());
        }

      } else {
        System.out.println("did not find object");
      }
      obj_in.close();
    } catch (ClassNotFoundException x) {
      printer.printError(x.getLocalizedMessage());
      System.err.format("Unable to read");
    } catch (IOException y) {
      printer.printError(y.getLocalizedMessage());
    }

    // Layout the text fields in a panel.

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

    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(buttonPanel, BorderLayout.PAGE_START);
    add(listPane, BorderLayout.LINE_START);
    // add(destListScrollPane, BorderLayout.CENTER);

    add(fieldPane, BorderLayout.LINE_END);
    add(labelPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
  }
Ejemplo n.º 9
0
  public void asetaLayout() {

    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    layout.setHorizontalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(jnimi)
                    .addComponent(aloita)
                    .addComponent(maalivahti)
                    .addComponent(puolustaja1)
                    .addComponent(puolustaja2)
                    .addComponent(puolustaja3)
                    .addComponent(keskikentta1)
                    .addComponent(keskikentta2)
                    .addComponent(keskikentta3)
                    .addComponent(keskikentta4)
                    .addComponent(hyokkaaja1)
                    .addComponent(hyokkaaja2)
                    .addComponent(hyokkaaja3)));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addComponent(jnimi)
            .addComponent(aloita)
            .addComponent(maalivahti)
            .addComponent(puolustaja1)
            .addComponent(puolustaja2)
            .addComponent(puolustaja3)
            .addComponent(keskikentta1)
            .addComponent(keskikentta2)
            .addComponent(keskikentta3)
            .addComponent(keskikentta4)
            .addComponent(hyokkaaja1)
            .addComponent(hyokkaaja2)
            .addComponent(hyokkaaja3));

    panelo.add(pisteet, BorderLayout.PAGE_START);
    panelo.add(loki, BorderLayout.CENTER);

    aloita.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String a1 = (String) hyokkaaja1.getSelectedItem();
            String a2 = (String) hyokkaaja2.getSelectedItem();
            String a3 = (String) hyokkaaja3.getSelectedItem();
            String b1 = (String) keskikentta1.getSelectedItem();
            String b2 = (String) keskikentta2.getSelectedItem();
            String b3 = (String) keskikentta3.getSelectedItem();
            String b4 = (String) keskikentta4.getSelectedItem();
            String c1 = (String) puolustaja1.getSelectedItem();
            String c2 = (String) puolustaja2.getSelectedItem();
            String c3 = (String) puolustaja3.getSelectedItem();
            if (a1.equals(a2)
                || a1.equals(a3)
                || a2.equals(a3)
                || b1.equals(b2)
                || b1.equals(b3)
                || b1.equals(b4)
                || b2.equals(b3)
                || b2.equals(b4)
                || b3.equals(b4)
                || c1.equals(c2)
                || c1.equals(c3)
                || c2.equals(c3)) {
              JOptionPane.showMessageDialog(
                  null,
                  "Valitse joka kohtaan eri pelaaja",
                  "Sama pelaaja error",
                  JOptionPane.ERROR_MESSAGE);
            } else {
              aloita.setEnabled(false);
              maalivahti.setEnabled(false);
              hyokkaaja1.setEnabled(false);
              hyokkaaja2.setEnabled(false);
              hyokkaaja3.setEnabled(false);
              keskikentta1.setEnabled(false);
              keskikentta2.setEnabled(false);
              keskikentta3.setEnabled(false);
              keskikentta4.setEnabled(false);
              puolustaja1.setEnabled(false);
              puolustaja2.setEnabled(false);
              puolustaja3.setEnabled(false);
              status = true;
            }
          }
        });
  }
Ejemplo n.º 10
0
  private JPanel createRulesPanel() {
    JPanel panel = new JPanel();

    panel.addAncestorListener(new EventHandler());
    panel.setBorder(BorderFactory.createEtchedBorder());

    GroupLayout layout = new GroupLayout(panel);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    panel.setLayout(layout);

    GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup();

    GroupLayout.ParallelGroup left = layout.createParallelGroup();
    left.addComponent(numberOfRoundsLabel);
    left.addComponent(gunCoolingRateLabel);
    left.addComponent(inactivityTimeLabel);
    left.addComponent(sentryBorderSizeLabel);
    left.addComponent(hideEnemyNamesLabel);
    leftToRight.addGroup(left);

    GroupLayout.ParallelGroup right = layout.createParallelGroup();
    right.addComponent(getNumberOfRoundsTextField());
    right.addComponent(getGunCoolingRateTextField());
    right.addComponent(getInactivityTimeTextField());
    right.addComponent(getSentryBorderSizeTextField());
    right.addComponent(hideEnemyNamesCheckBox);
    leftToRight.addGroup(right);

    GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup();

    GroupLayout.ParallelGroup row0 = layout.createParallelGroup(Alignment.BASELINE);
    row0.addComponent(numberOfRoundsLabel);
    row0.addComponent(numberOfRoundsTextField);
    topToBottom.addGroup(row0);

    GroupLayout.ParallelGroup row1 = layout.createParallelGroup(Alignment.BASELINE);
    row1.addComponent(gunCoolingRateLabel);
    row1.addComponent(getGunCoolingRateTextField());
    topToBottom.addGroup(row1);

    GroupLayout.ParallelGroup row2 = layout.createParallelGroup(Alignment.BASELINE);
    row2.addComponent(inactivityTimeLabel);
    row2.addComponent(inactivityTimeTextField);
    topToBottom.addGroup(row2);

    GroupLayout.ParallelGroup row3 = layout.createParallelGroup(Alignment.BASELINE);
    row3.addComponent(sentryBorderSizeLabel);
    row3.addComponent(sentryBorderSizeTextField);
    topToBottom.addGroup(row3);

    GroupLayout.ParallelGroup row4 = layout.createParallelGroup(Alignment.CENTER);
    row4.addComponent(hideEnemyNamesLabel);
    row4.addComponent(hideEnemyNamesCheckBox);
    topToBottom.addGroup(row4);

    layout.setHorizontalGroup(leftToRight);
    layout.setVerticalGroup(topToBottom);

    return panel;
  }