예제 #1
1
  public BrowserFrame(Browser b) {
    super("Cavity Nesting DB Browser");
    browser = b;

    JPanel content = new JPanel(new BorderLayout());
    content.setOpaque(true);
    setContentPane(content);

    content.add(browser, BorderLayout.CENTER);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosed(WindowEvent e) {
            browser.closeBrowser();
          }
        });

    createJMenuBar();
    setJMenuBar(menubar);

    setVisible(true);
    pack();
  }
예제 #2
0
  /** Description of the Method */
  public void init() {
    // super.init();
    size = new Dimension(570, 570);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);

    Dimension d = messagePanel.getSize();
    d.height += 20;
    messagePanel.setPreferredSize(d);
    contentPane.add(messagePanel, BorderLayout.SOUTH);

    contentPane.setOpaque(true);
    userPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);

    messagePanel.setLayout(borderLayout5);
    contentPane.setOpaque(true);
    contentPane.setBackground(Color.white);
    this.setSize(size);

    messagePanel.add(labelMessage, BorderLayout.NORTH);
    // Logg.logg("MhClient: Före XttTree-skapande", 6);
    this.mhTable = new MhTable(root, false, this.labelMessage);
    // Logg.logg("MhClient: mhTable-skapande klart", 6);
    this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER);
  }
  private JPanel readSplitter(
      JPanel panel, Element splitterElement, Ref<EditorWindow> currentWindow) {
    final boolean orientation =
        "vertical".equals(splitterElement.getAttributeValue("split-orientation"));
    final float proportion =
        Float.valueOf(splitterElement.getAttributeValue("split-proportion")).floatValue();
    final Element first = splitterElement.getChild("split-first");
    final Element second = splitterElement.getChild("split-second");

    Splitter splitter;
    if (panel == null) {
      panel = new JPanel(new BorderLayout());
      panel.setOpaque(false);
      splitter = new Splitter(orientation, proportion, 0.1f, 0.9f);
      panel.add(splitter, BorderLayout.CENTER);
      splitter.setFirstComponent(readExternalPanel(first, null, currentWindow));
      splitter.setSecondComponent(readExternalPanel(second, null, currentWindow));
    } else if (panel.getComponent(0) instanceof Splitter) {
      splitter = (Splitter) panel.getComponent(0);
      readExternalPanel(first, (JPanel) splitter.getFirstComponent(), currentWindow);
      readExternalPanel(second, (JPanel) splitter.getSecondComponent(), currentWindow);
    } else {
      readExternalPanel(first, panel, currentWindow);
      readExternalPanel(second, panel, currentWindow);
    }
    return panel;
  }
  private void createProgressPanel() {
    myProgressIcon = new AsyncProcessIcon("Designer progress");
    myProgressMessage = new JLabel();

    JPanel progressBlock = new JPanel();
    progressBlock.add(myProgressIcon);
    progressBlock.add(myProgressMessage);
    progressBlock.setBorder(IdeBorderFactory.createRoundedBorder());

    myProgressPanel = new JPanel(new GridBagLayout());
    myProgressPanel.add(
        progressBlock,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    myProgressPanel.setOpaque(false);
  }
예제 #5
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == ctl) {
     this.menu();
   } else if (e.getSource() == exit) {
     exitPerform();
   } else if (e.getSource() == rank) {
     if (count != 0) {
       card.show(mainPanel, "four");
       rankPanel.setMemory(memory, count - 1);
       buttonPanel.removeAll();
       buttonPanel.setBounds(width - 200, height - 80, 190, 50);
       buttonPanel.add(exit);
       check = 4;
       count--;
     }
   } else if (e.getSource() == back) {
     if (secondPanel.clip != null) {
       secondPanel.clip.stop();
       System.out.printf("test");
     }
     check = 0;
     card.previous(mainPanel);
     buttonPanel.removeAll();
     ctl.setText("- Play -");
     buttonPanel.add(ctl);
     buttonPanel.add(rank);
     buttonPanel.add(exit);
     buttonPanel.setOpaque(false);
     buttonPanel.setBounds(width / 2 - 50, height / 2 - 50, 80, 100);
   }
 }
예제 #6
0
 public void changePanel() {
   card.next(mainPanel);
   buttonPanel.removeAll();
   ctl.setText("- Play -");
   buttonPanel.add(ctl);
   buttonPanel.add(rank);
   buttonPanel.add(exit);
   buttonPanel.setOpaque(false);
   buttonPanel.setBounds(width / 2 - 50, height / 2 - 50, 80, 100);
   count++;
   memory[count] = new Memory();
   menuPanel.setMemory(memory[count]);
   secondPanel.setMemory(memory[count]);
   gamePanel.setMemory(memory[count]);
   rankPanel.setMemory(memory, count);
   check = 0;
   System.out.println(
       count
           + " "
           + memory[count - 1].name
           + " "
           + memory[count - 1].song
           + " "
           + memory[count - 1].score);
 }
예제 #7
0
  /** Initialize the panel containing the node. */
  public PluginListCellRenderer() {
    super(new BorderLayout(8, 8));

    JPanel mainPanel = new JPanel(new BorderLayout());

    this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    this.setBackground(Color.WHITE);

    this.setOpaque(true);

    mainPanel.setOpaque(false);
    this.nameVersionPanel.setOpaque(false);

    this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    this.nameLabel.setIconTextGap(2);

    this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD));
    this.systemLabel.setFont(this.getFont().deriveFont(Font.BOLD));

    this.nameVersionPanel.add(nameLabel);
    this.nameVersionPanel.add(versionLabel);

    mainPanel.add(nameVersionPanel, BorderLayout.NORTH);
    mainPanel.add(descriptionLabel, BorderLayout.CENTER);

    this.add(iconLabel, BorderLayout.WEST);

    this.add(mainPanel, BorderLayout.CENTER);
    this.add(stateLabel, BorderLayout.WEST);
  }
예제 #8
0
  public InfoAndProgressPanel() {

    setOpaque(false);

    myRefreshIcon = new RefreshFileSystemIcon();
    //  new AsyncProcessIcon("Refreshing filesystem") {
    //  protected Icon getPassiveIcon() {
    //    return myEmptyRefreshIcon;
    //  }
    //
    //  @Override
    //  public Dimension getPreferredSize() {
    //    if (!isRunning()) return new Dimension(0, 0);
    //    return super.getPreferredSize();
    //  }
    //
    //  @Override
    //  public void paint(Graphics g) {
    //    g.translate(0, -1);
    //    super.paint(g);
    //    g.translate(0, 1);
    //  }
    // };

    myRefreshIcon.setPaintPassiveIcon(false);

    myRefreshAndInfoPanel.setLayout(new BorderLayout());
    myRefreshAndInfoPanel.setOpaque(false);
    myRefreshAndInfoPanel.add(myRefreshIcon, BorderLayout.WEST);
    myRefreshAndInfoPanel.add(myInfoPanel, BorderLayout.CENTER);

    myProgressIcon = new AsyncProcessIcon("Background process");
    myProgressIcon.setOpaque(false);

    myProgressIcon.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            handle(e);
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            handle(e);
          }
        });

    myProgressIcon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    myProgressIcon.setBorder(StatusBarWidget.WidgetBorder.INSTANCE);
    myProgressIcon.setToolTipText(ActionsBundle.message("action.ShowProcessWindow.double.click"));

    myUpdateQueue =
        new MergingUpdateQueue("Progress indicator", 50, true, MergingUpdateQueue.ANY_COMPONENT);
    myPopup = new ProcessPopup(this);

    setRefreshVisible(false);

    restoreEmptyStatus();
  }
예제 #9
0
 private JPanel getPlayerNamePanel() {
   JPanel p = new JPanel(new MigLayout("insets 0, gap 0!"));
   p.setOpaque(false);
   FLabel lbl =
       new FLabel.Builder().text("Player Name: ").fontSize(12).fontStyle(Font.BOLD).build();
   p.add(lbl, "aligny top, h 100%");
   p.add(btnPlayerName, "aligny top, h 100%, w 200px!");
   return p;
 }
  private JPanel getRow(int gap, Component comp1, Component comp2) {
    JPanel panel = new JPanel(new BorderLayout(gap, 0));
    panel.setOpaque(false);

    panel.add(comp1, BorderLayout.CENTER);
    panel.add(comp2, BorderLayout.EAST);

    return panel;
  }
예제 #11
0
  public UserDirectoryDialog(int nBuild) {
    super("View Directories");
    initBlink();
    try {
      // UIManager.setLookAndFeel( "javax.swing.plaf.metal.MetalLookAndFeel" );
    } catch (Exception exc) {
      System.out.println("Error loading L&F: " + exc);
    }

    AppIF appIf = Util.getAppIF();
    if (appIf instanceof VAdminIF) m_adminIF = (VAdminIF) appIf;

    if (nBuild == BUILD_ALL) {
      JPanel left = new JPanel();
      left.setOpaque(true);
      left.setLayout(new BorderLayout());
      left.add(new ConstraintsPanel(), BorderLayout.CENTER);

      JPanel right = new JPanel();
      right.setLayout(new BorderLayout());
      right.setOpaque(true);
      // right.setBackground( Color.white );

      JTreeTableAdmin treeTable = new JTreeTableAdmin(new FileSystemModelAdmin());
      right.add(new JScrollPane(treeTable), BorderLayout.CENTER);

      JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
      pane.setContinuousLayout(true);
      pane.setOneTouchExpandable(true);
      getContentPane().add(pane, BorderLayout.CENTER);
    }

    m_mlTxf =
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (timer != null) timer.cancel();
            if (e.getSource() instanceof JTextField) {
              JTextField txf2 = (JTextField) e.getSource();
              String strTxt = txf2.getText();
              if (strTxt != null && strTxt.equals(INFOSTR)) txf2.setText("");
            }
          }
        };
  }
예제 #12
0
 /**
  * This method initializes highlightBorder
  *
  * @return JPanel
  */
 private JPanel getHighlightBorder() {
   if (highlightBorder == null) {
     highlightBorder = new JPanel();
     highlightBorder.setOpaque(false);
     highlightBorder.setBorder(
         javax.swing.BorderFactory.createLineBorder(java.awt.Color.black, 2));
     highlightBorder.setBackground(java.awt.Color.white);
     highlightBorder.setVisible(false);
   }
   return highlightBorder;
 }
예제 #13
0
  public JPanel makeFileTable() {
    JPanel right = new JPanel();
    right.setLayout(new BorderLayout());
    right.setOpaque(true);
    // right.setBackground( Color.white );

    JTreeTableAdmin treeTable = new JTreeTableAdmin(new FileSystemModelAdmin());
    right.add(new JScrollPane(treeTable), BorderLayout.CENTER);

    return right;
  }
  private void addErrorMessage(final FixableMessageInfo message, Icon icon) {
    if (message.myLinkText.length() > 0 || message.myAfterLinkText.length() > 0) {
      HyperlinkLabel warnLabel = new HyperlinkLabel();
      warnLabel.setOpaque(false);
      warnLabel.setHyperlinkText(
          message.myBeforeLinkText, message.myLinkText, message.myAfterLinkText);
      warnLabel.setIcon(icon);

      if (message.myQuickFix != null) {
        warnLabel.addHyperlinkListener(
            new HyperlinkListener() {
              public void hyperlinkUpdate(final HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                  message.myQuickFix.run();
                }
              }
            });
      }
      myErrorMessages.add(warnLabel);
    } else {
      JBLabel warnLabel = new JBLabel();
      warnLabel.setOpaque(false);
      warnLabel.setText(
          "<html><body>" + message.myBeforeLinkText.replace("\n", "<br>") + "</body></html>");
      warnLabel.setIcon(icon);
      myErrorMessages.add(warnLabel);
    }
    if (message.myAdditionalFixes != null && message.myAdditionalFixes.size() > 0) {
      JPanel fixesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
      fixesPanel.setBorder(IdeBorderFactory.createEmptyBorder(3, 0, 10, 0));
      fixesPanel.setOpaque(false);
      fixesPanel.add(Box.createHorizontalStrut(icon.getIconWidth()));

      for (Pair<String, Runnable> pair : message.myAdditionalFixes) {
        HyperlinkLabel fixLabel = new HyperlinkLabel();
        fixLabel.setOpaque(false);
        fixLabel.setHyperlinkText(pair.getFirst());
        final Runnable fix = pair.getSecond();

        fixLabel.addHyperlinkListener(
            new HyperlinkListener() {
              @Override
              public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                  fix.run();
                }
              }
            });
        fixesPanel.add(fixLabel);
      }
      myErrorMessages.add(fixesPanel);
    }
  }
 public ColorPanel(Component invoker) {
   super();
   setTarget(invoker);
   setLayout(new BorderLayout());
   JPanel topLabel = new JPanel();
   topLabel.setOpaque(true);
   topLabel.setBackground(Color.darkGray);
   // topLabel.setPreferredSize( new Dimension(getWidth() - 10, 15) );
   add(topLabel, BorderLayout.NORTH);
   createColorArray();
   createColorPanel();
 }
  /**
   * Creates an instance of <tt>ChatRoomConfigurationWindow</tt> and initializes the configuration
   * form.
   *
   * @param chatRoomName the name of the room
   * @param configForm the configuration form to load in this configuration window
   */
  public ChatRoomConfigurationWindow(String chatRoomName, ChatRoomConfigurationForm configForm) {
    super(false);

    this.configForm = configForm;

    this.setTitle(
        GuiActivator.getResources()
            .getI18NString("service.gui.CHAT_ROOM_CONFIGURATION", new String[] {chatRoomName}));

    titlePanel.setTitleText(
        GuiActivator.getResources().getI18NString("service.gui.CHAT_ROOM_OPTIONS"));

    this.generalScrollPane.setPreferredSize(new Dimension(820, 520));
    this.generalScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    this.generalScrollPane.setOpaque(false);
    this.generalScrollPane.getViewport().setOpaque(false);

    this.mainPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));

    this.mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    this.saveButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.buttonsPanel.add(saveButton);
    this.buttonsPanel.add(cancelButton);

    this.generalScrollPane.getViewport().add(mainPanel);

    this.getContentPane().add(titlePanel, BorderLayout.NORTH);
    this.getContentPane().add(generalScrollPane, BorderLayout.CENTER);
    this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);

    titlePanel.setOpaque(false);
    buttonsPanel.setOpaque(false);
    mainPanel.setOpaque(false);
    generalScrollPane.setOpaque(false);

    this.loadConfigurationForm();
  }
예제 #17
0
  public GameFrame(int height, int width) {
    super("--- Tempo Game ---");

    this.height = height;
    this.width = width;

    card = new CardLayout();

    mainPanel = new JPanel();

    mainPanel.setLayout(card);

    memory[0] = new Memory();

    menuPanel = new MenuPanel(memory[count]);
    secondPanel = new SecondPanel(memory[count]);
    gamePanel = new GamePanel(memory[count]);
    rankPanel = new RankPanel(memory, count);

    mainPanel.add(menuPanel, "one");
    mainPanel.add(secondPanel, "two");
    mainPanel.add(gamePanel, "three");
    mainPanel.add(rankPanel, "four");

    buttonPanel = new JPanel();

    ctl = new JButton("- Play -");
    ctl.addActionListener(this);

    exit = new JButton("- Exit -");
    exit.addActionListener(this);

    rank = new JButton("- Rank -");
    rank.addActionListener(this);

    back = new JButton("- Back -");
    back.addActionListener(this);

    buttonPanel.add(ctl);
    buttonPanel.add(rank);
    buttonPanel.add(exit);
    buttonPanel.setOpaque(false);
    buttonPanel.setBounds(width / 2 - 50, height / 2 - 50, 80, 100);

    gamePanel.setFocusable(true);
    gamePanel.addKeyListener(this);

    add(buttonPanel);
    add(mainPanel);

    System.out.println(count);
  }
예제 #18
0
  public Container CreateContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // the log panel
    log = new JTextPane();
    log.setEditable(false);
    log.setBackground(Color.BLACK);
    logPane = new JScrollPane(log);
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    log.setEditorKit(kit);
    log.setDocument(doc);
    DefaultCaret c = (DefaultCaret) log.getCaret();
    c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ClearLog();

    // the preview panel
    previewPane = new DrawPanel();
    previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right);

    // status bar
    statusBar = new StatusBar();
    Font f = statusBar.getFont();
    statusBar.setFont(f.deriveFont(Font.BOLD, 15));
    Dimension d = statusBar.getMinimumSize();
    d.setSize(d.getWidth(), d.getHeight() + 30);
    statusBar.setMinimumSize(d);

    // layout
    Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT);
    split.add(previewPane);
    split.add(logPane);
    split.setDividerSize(8);

    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(split, BorderLayout.CENTER);

    // open the file
    if (recentFiles[0].length() > 0) {
      OpenFileOnDemand(recentFiles[0]);
    }

    // connect to the last port
    ListSerialPorts();
    if (Arrays.asList(portsDetected).contains(recentPort)) {
      OpenPort(recentPort);
    }

    return contentPane;
  }
예제 #19
0
    public ButtonCellEditor(CharacterFacade character) {
      this.character = character;

      button.addActionListener(this);
      button.setMargin(new Insets(0, 0, 0, 0));

      container.setOpaque(true);
      container.setLayout(new GridBagLayout());
      GridBagConstraints gbc = new GridBagConstraints();
      gbc.weightx = 1;
      gbc.weighty = 1;
      gbc.anchor = GridBagConstraints.EAST;
      gbc.fill = GridBagConstraints.VERTICAL;
      container.add(button, gbc);
    }
예제 #20
0
  private void buildInProcessCount() {
    removeAll();
    setLayout(new BorderLayout());

    final JPanel progressCountPanel = new JPanel(new BorderLayout(0, 0));
    progressCountPanel.setOpaque(false);
    String processWord = myOriginals.size() == 1 ? " process" : " processes";
    final LinkLabel label =
        new LinkLabel(
            myOriginals.size() + processWord + " running...",
            null,
            new LinkListener() {
              @Override
              public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
                triggerPopupShowing();
              }
            });

    if (SystemInfo.isMac) label.setFont(UIUtil.getLabelFont().deriveFont(11.0f));

    label.setOpaque(false);

    final Wrapper labelComp = new Wrapper(label);
    labelComp.setOpaque(false);
    progressCountPanel.add(labelComp, BorderLayout.CENTER);

    // myProgressIcon.setBorder(new IdeStatusBarImpl.MacStatusBarWidgetBorder());
    progressCountPanel.add(myProgressIcon, BorderLayout.WEST);

    add(myRefreshAndInfoPanel, BorderLayout.CENTER);

    progressCountPanel.setBorder(new EmptyBorder(0, 0, 0, 4));
    add(progressCountPanel, BorderLayout.EAST);

    revalidate();
    repaint();
  }
  /** This method is called from within the constructor to initialize the form. */
  public void initComponents() {
    /** *************** The main frame ************************************** */
    // width, height
    this.setSize(560, 370);
    Container container = this.getContentPane();
    container.setLayout(new BoxLayout(getContentPane(), 1));
    container.setBackground(containerBackGroundColor);
    this.setLocation(0, 0);
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            new AlertInstantMessaging(
                "Your changes will not be checked: use the Submit button!!!",
                JOptionPane.WARNING_MESSAGE);
            hideFrame();
          }
        });

    /** **************** The components ********************************* */
    firstPanel = new JPanel();
    firstPanel.setBorder(BorderFactory.createEmptyBorder(15, 4, 15, 4));
    // If put to False: we see the container's background
    firstPanel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    firstPanel.setLayout(new GridLayout(11, 2, 2, 2));
    container.add(firstPanel);

    outboundProxyAddressLabel = new JLabel("Outbound proxy IP address:");
    outboundProxyAddressLabel.setForeground(Color.black);
    outboundProxyAddressTextField = new JTextField(20);
    outboundProxyAddressLabel.setBorder(labelBorder);
    outboundProxyAddressLabel.setOpaque(true);
    outboundProxyAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outboundProxyAddressLabel);
    firstPanel.add(outboundProxyAddressTextField);

    outboundProxyPortLabel = new JLabel("Outbound proxy port:");
    outboundProxyPortLabel.setForeground(Color.black);
    outboundProxyPortTextField = new JTextField(20);
    outboundProxyPortLabel.setBorder(labelBorder);
    outboundProxyPortLabel.setOpaque(true);
    outboundProxyPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outboundProxyPortLabel);
    firstPanel.add(outboundProxyPortTextField);

    registrarAddressLabel = new JLabel("Registrar IP address:");
    registrarAddressLabel.setForeground(Color.black);
    registrarAddressTextField = new JTextField(20);
    registrarAddressLabel.setBorder(labelBorder);
    registrarAddressLabel.setOpaque(true);
    registrarAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(registrarAddressLabel);
    firstPanel.add(registrarAddressTextField);

    registrarPortLabel = new JLabel("Registrar port:");
    registrarPortLabel.setForeground(Color.black);
    registrarPortTextField = new JTextField(20);
    registrarPortLabel.setBorder(labelBorder);
    registrarPortLabel.setOpaque(true);
    registrarPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(registrarPortLabel);
    firstPanel.add(registrarPortTextField);

    imAddressLabel = new JLabel("Contact IP address:");
    imAddressLabel.setForeground(Color.black);
    imAddressTextField = new JTextField(20);
    imAddressLabel.setBorder(labelBorder);
    imAddressLabel.setOpaque(true);
    imAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imAddressLabel);
    firstPanel.add(imAddressTextField);

    imPortLabel = new JLabel("Contact port:");
    imPortLabel.setForeground(Color.black);
    imPortTextField = new JTextField(20);
    imPortLabel.setBorder(labelBorder);
    imPortLabel.setOpaque(true);
    imPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imPortLabel);
    firstPanel.add(imPortTextField);

    imProtocolLabel = new JLabel("Contact transport:");
    imProtocolLabel.setForeground(Color.black);
    imProtocolTextField = new JTextField(20);
    imProtocolLabel.setBorder(labelBorder);
    imProtocolLabel.setOpaque(true);
    imProtocolLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imProtocolLabel);
    firstPanel.add(imProtocolTextField);

    outputFileLabel = new JLabel("Output file:");
    outputFileLabel.setForeground(Color.black);
    outputFileTextField = new JTextField(20);
    outputFileLabel.setBorder(labelBorder);
    outputFileLabel.setOpaque(true);
    outputFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outputFileLabel);
    firstPanel.add(outputFileTextField);

    buddiesFileLabel = new JLabel("Buddies file:");
    buddiesFileLabel.setForeground(Color.black);
    buddiesFileTextField = new JTextField(20);
    buddiesFileLabel.setBorder(labelBorder);
    buddiesFileLabel.setOpaque(true);
    buddiesFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(buddiesFileLabel);
    firstPanel.add(buddiesFileTextField);

    authenticationFileLabel = new JLabel("Authentication file:");
    authenticationFileLabel.setForeground(Color.black);
    authenticationFileTextField = new JTextField(20);
    authenticationFileLabel.setBorder(labelBorder);
    authenticationFileLabel.setOpaque(true);
    authenticationFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(authenticationFileLabel);
    firstPanel.add(authenticationFileTextField);

    defaultRouterLabel = new JLabel("Default router class name:");
    defaultRouterLabel.setForeground(Color.black);
    defaultRouterTextField = new JTextField(20);
    defaultRouterLabel.setBorder(labelBorder);
    defaultRouterLabel.setOpaque(true);
    defaultRouterLabel.setBackground(labelBackGroundColor);
    firstPanel.add(defaultRouterLabel);
    firstPanel.add(defaultRouterTextField);

    thirdPanel = new JPanel();
    thirdPanel.setOpaque(false);
    // top, left, bottom, right
    thirdPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

    submitButton = new JButton(" Submit ");
    submitButton.setToolTipText("Submit your changes!");
    submitButton.setFocusPainted(false);
    submitButton.setFont(new Font("Dialog", 1, 16));
    submitButton.setBackground(buttonBackGroundColor);
    submitButton.setBorder(buttonBorder);
    submitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            submitButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(submitButton);
    container.add(thirdPanel);
  }
  private JPanel createForm() {
    JCheckBox enabledCheckBox = new JCheckBox(Finder.getString("vhost.ssl.edit.enable"));

    new CheckBoxPropertySynchronizer(enabledProperty, enabledCheckBox);
    ChangeIndicator enabledChange = new ChangeIndicator();
    enabledProperty.addChangeListener(enabledChange);

    JLabel iPLabel = new JLabel(Finder.getString("vhost.ssl.edit.ip"));
    JTextField iPField = GUIUtil.createTextField();
    new TextComponentPropertySynchronizer<String, JTextComponent>(ipProperty, iPField);
    ChangeIndicator iPChange = new ChangeIndicator();
    ipProperty.addChangeListener(iPChange);

    JLabel portLabel = new JLabel(Finder.getString("vhost.ssl.edit.port"));

    SpinnerNumberModel portModel = new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1);
    JSpinner portSpinner = new JSpinner(portModel);

    JComponent editor = portSpinner.getEditor();
    if (editor instanceof JSpinner.DefaultEditor) {
      JTextField field = ((JSpinner.DefaultEditor) editor).getTextField();
      field.setColumns(5);
      field.setHorizontalAlignment(JTextField.RIGHT);
    }

    new SpinnerNumberModelPropertySynchronizer(portProperty, portModel, false);
    portProperty.save();

    ChangeIndicator portChange = new ChangeIndicator();
    portProperty.addChangeListener(portChange);

    JLabel certLabel = new JLabel(Finder.getString("vhost.ssl.edit.certificate"));

    BrowsableFilePanel certPanel = new BrowsableFilePanel();
    certPanel.setOpaque(false);
    fileChoosers.add(certPanel.getFileChooser());

    new TextComponentPropertySynchronizer<String, JTextComponent>(
        certProperty, certPanel.getField());
    ChangeIndicator certChange = new ChangeIndicator();
    certProperty.addChangeListener(certChange);

    JLabel keyLabel = new JLabel(Finder.getString("vhost.ssl.edit.key"));

    BrowsableFilePanel keyPanel = new BrowsableFilePanel();
    keyPanel.setOpaque(false);
    fileChoosers.add(keyPanel.getFileChooser());

    new TextComponentPropertySynchronizer<String, JTextComponent>(keyProperty, keyPanel.getField());
    ChangeIndicator keyChange = new ChangeIndicator();
    keyProperty.addChangeListener(keyChange);

    JPanel formPanel = new JPanel();
    formPanel.setOpaque(false);

    Form form = new Form(formPanel, VerticalAnchor.TOP);

    int hGap = GUIUtil.getHalfGap();
    int sGap = 3 * hGap;
    int indent = GUIUtil.getTextXOffset(enabledCheckBox);

    ColumnLayoutConstraint c = new ColumnLayoutConstraint(HorizontalAnchor.FILL, hGap);

    RowLayoutConstraint r = new RowLayoutConstraint(VerticalAnchor.CENTER, hGap);

    HasAnchors a = new SimpleHasAnchors(HorizontalAnchor.LEFT, VerticalAnchor.CENTER);

    form.addRow(HorizontalAnchor.LEFT, c);
    form.add(enabledCheckBox, r);
    form.add(enabledChange, r);

    form.addTable(2, hGap, hGap, HorizontalAnchor.LEFT, c.setGap(sGap));
    form.add(iPLabel, a);
    form.add(getRow(hGap, iPField, iPChange), a);
    form.add(portLabel, a);
    form.add(getRow(hGap, portSpinner, portChange), a);
    form.add(certLabel, a);
    form.add(getRow(hGap, certPanel, certChange), a);
    form.add(keyLabel, a);
    form.add(getRow(hGap, keyPanel, keyChange), a);

    return formPanel;
  }
예제 #23
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);
  }
예제 #24
0
  private void buildInInlineIndicator(@NotNull final InlineProgressIndicator inline) {
    removeAll();
    setLayout(new InlineLayout());
    add(myRefreshAndInfoPanel);

    final JPanel inlinePanel = new JPanel(new BorderLayout());

    inline.getComponent().setBorder(new EmptyBorder(1, 0, 0, 2));
    final JComponent inlineComponent = inline.getComponent();
    inlineComponent.setOpaque(false);
    inlinePanel.add(inlineComponent, BorderLayout.CENTER);

    // myProgressIcon.setBorder(new IdeStatusBarImpl.MacStatusBarWidgetBorder());
    inlinePanel.add(myProgressIcon, BorderLayout.WEST);

    inline.updateProgressNow();
    inlinePanel.setOpaque(false);

    add(inlinePanel);

    myRefreshAndInfoPanel.revalidate();
    myRefreshAndInfoPanel.repaint();

    if (UISettings.getInstance().PRESENTATION_MODE) {
      final JRootPane pane = myInfoPanel.getRootPane();
      final RelativePoint point = new RelativePoint(pane, new Point(pane.getWidth() - 250, 60));
      final PresentationModeProgressPanel panel = new PresentationModeProgressPanel(inline);
      final MyInlineProgressIndicator delegate =
          new MyInlineProgressIndicator(true, inline.getInfo(), inline) {
            @Override
            protected void updateProgress() {
              super.updateProgress();
              panel.update();
            }
          };

      Disposer.register(inline, delegate);

      JBPopupFactory.getInstance()
          .createBalloonBuilder(panel.getRootPanel())
          .setFadeoutTime(0)
          .setFillColor(Gray.TRANSPARENT)
          .setShowCallout(false)
          .setBorderColor(Gray.TRANSPARENT)
          .setBorderInsets(new Insets(0, 0, 0, 0))
          .setAnimationCycle(0)
          .setCloseButtonEnabled(false)
          .setHideOnClickOutside(false)
          .setDisposable(inline)
          .setHideOnFrameResize(false)
          .setHideOnKeyOutside(false)
          .setBlockClicksThroughBalloon(true)
          .setHideOnAction(false)
          .createBalloon()
          .show(
              new PositionTracker<Balloon>(pane) {
                @Override
                public RelativePoint recalculateLocation(Balloon object) {
                  final EditorComponentImpl editorComponent =
                      UIUtil.findComponentOfType(pane, EditorComponentImpl.class);
                  if (editorComponent != null) {
                    return new RelativePoint(
                        editorComponent.getParent().getParent(),
                        new Point(
                            editorComponent.getParent().getParent().getWidth() - 150,
                            editorComponent.getParent().getParent().getHeight() - 70));
                  }
                  return point;
                }
              },
              Balloon.Position.above);
    }
  }
예제 #25
0
  /** Creates the GUI. */
  public void majorLayout() {
    //
    // Setup Menu
    //
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu(ResourceHandler.getMessage("menu.file"));
    file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file"));

    file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit")));
    exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit"));
    exitMenuItem.addActionListener(this);
    menuBar.add(file);

    JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit"));
    edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit"));

    edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option")));
    optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option"));
    optionMenuItem.addActionListener(this);
    menuBar.add(edit);

    JMenu help = new JMenu(ResourceHandler.getMessage("menu.help"));
    help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help")));
    helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help"));

    help.add(new JSeparator());
    help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about")));
    aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about"));
    helpMenuItem.addActionListener(this);
    aboutMenuItem.addActionListener(this);
    menuBar.add(help);

    setJMenuBar(menuBar);

    //
    // Setup main GUI
    //

    dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0"));
    dirTF = new JTextField();
    dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir"));
    dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir"));

    matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1"));
    matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2"));
    recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3"));
    recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3"));

    backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5"));
    backupTF = new JTextField();
    backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup"));
    backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup"));

    templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7"));
    templateCh = new TemplateFileChoice();

    staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label"));
    String version = System.getProperty("java.version");
    if (version.indexOf("-") > 0) {
      version = version.substring(0, version.indexOf("-"));
    }
    int dotIndex = version.indexOf(".");
    dotIndex = version.indexOf(".", dotIndex + 1);
    String familyVersion = version.substring(0, dotIndex);

    MessageFormat formatter =
        new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button"));
    staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version}));
    staticVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("static.versioning.radio.button"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button"));
    dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion}));
    dynamicVersioningRadioButton.setMnemonic(
        ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button"));

    staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text"));

    formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text"));
    dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion}));

    ButtonGroup versioningButtonGroup = new ButtonGroup();
    versioningButtonGroup.add(staticVersioningRadioButton);
    versioningButtonGroup.add(dynamicVersioningRadioButton);

    runBttn = new JButton(ResourceHandler.getMessage("button.convert"));
    runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert"));

    recursiveCheckBox.setOpaque(false);
    staticVersioningRadioButton.setOpaque(false);
    dynamicVersioningRadioButton.setOpaque(false);

    staticVersioningTextArea.setEditable(false);
    staticVersioningTextArea.setLineWrap(true);
    staticVersioningTextArea.setWrapStyleWord(true);
    dynamicVersioningTextArea.setEditable(false);
    dynamicVersioningTextArea.setLineWrap(true);
    dynamicVersioningTextArea.setWrapStyleWord(true);

    staticVersioningPanel.setLayout(new BorderLayout());
    staticVersioningPanel.add(staticVersioningTextArea, "Center");
    staticVersioningPanel.setBorder(new LineBorder(Color.black));

    dynamicVersioningPanel.setLayout(new BorderLayout());
    dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center");
    dynamicVersioningPanel.setBorder(new LineBorder(Color.black));

    if (converter.isStaticVersioning()) {
      staticVersioningRadioButton.setSelected(true);
    } else {
      dynamicVersioningRadioButton.setSelected(true);
    }

    addListeners();

    final int buf = 10, // Buffer (between components and form)
        sp = 10, // Space between components
        vsp = 5, // Vertical space
        indent = 20; // Indent between form (left edge) and component

    GridBagConstraints gbc = new GridBagConstraints();
    GridBagLayout gbl = new GridBagLayout();
    getContentPane().setLayout(gbl);

    //
    // Setup top panel
    //
    GridBagLayout topLayout = new GridBagLayout();
    JPanel topPanel = new JPanel();
    topPanel.setOpaque(false);
    topPanel.setLayout(topLayout);

    topLayout.setConstraints(
        dirLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirTF,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dirBttn,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingLabel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        matchingTF,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        recursiveCheckBox,
        new GridBagConstraints(
            2,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupLabel,
        new GridBagConstraints(
            0,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupTF,
        new GridBagConstraints(
            1,
            3,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        backupBttn,
        new GridBagConstraints(
            2,
            3,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(10, sp, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateLabel,
        new GridBagConstraints(
            0,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        templateCh,
        new GridBagConstraints(
            1,
            4,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(vsp, 2, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep1,
        new GridBagConstraints(
            0,
            5,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 10, 10),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningLabel,
        new GridBagConstraints(
            0,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(10, 0, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningRadioButton,
        new GridBagConstraints(
            0,
            7,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        staticVersioningPanel,
        new GridBagConstraints(
            0,
            8,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 10, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningRadioButton,
        new GridBagConstraints(
            0,
            9,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(vsp, 10, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        dynamicVersioningPanel,
        new GridBagConstraints(
            0,
            10,
            GridBagConstraints.REMAINDER,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(vsp, 25, 0, 0),
            0,
            0));
    topLayout.setConstraints(
        sep2,
        new GridBagConstraints(
            0,
            11,
            GridBagConstraints.REMAINDER,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(10, 10, 0, 10),
            0,
            0));

    invisibleBttn = new JButton();
    invisibleBttn.setVisible(false);
    topLayout.setConstraints(
        invisibleBttn,
        new GridBagConstraints(
            2,
            6,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.CENTER,
            new Insets(indent, sp, 0, 0),
            0,
            0));

    topPanel.add(dirLabel);
    topPanel.add(dirTF);
    topPanel.add(dirBttn);
    topPanel.add(matchingLabel);
    topPanel.add(matchingTF);
    topPanel.add(recursiveCheckBox);
    topPanel.add(backupLabel);
    topPanel.add(backupTF);
    topPanel.add(backupBttn);
    topPanel.add(templateLabel);
    topPanel.add(templateCh);
    topPanel.add(sep1);
    topPanel.add(staticVersioningLabel);
    topPanel.add(staticVersioningRadioButton);
    topPanel.add(staticVersioningPanel);
    topPanel.add(dynamicVersioningRadioButton);
    topPanel.add(dynamicVersioningPanel);
    topPanel.add(sep2);
    topPanel.add(invisibleBttn);

    //
    // Setup bottom panel
    //
    GridBagLayout buttomLayout = new GridBagLayout();
    JPanel buttomPanel = new JPanel();
    buttomPanel.setOpaque(false);
    buttomPanel.setLayout(buttomLayout);

    buttomLayout.setConstraints(
        runBttn,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(sp, 0, 0, 0),
            0,
            0));
    buttomPanel.add(runBttn);

    //
    // Setup main panel
    //
    GridBagLayout mainLayout = new GridBagLayout();
    JPanel mainPanel = new JPanel();

    mainPanel.setOpaque(false);
    mainPanel.setLayout(mainLayout);

    mainLayout.setConstraints(
        topPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(buf, buf, 0, buf),
            0,
            0));
    mainLayout.setConstraints(
        buttomPanel,
        new GridBagConstraints(
            0,
            1,
            1,
            1,
            1,
            1,
            GridBagConstraints.SOUTH,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, buf, buf, buf),
            0,
            0));
    mainPanel.add(topPanel);
    mainPanel.add(buttomPanel);

    Border border = BorderFactory.createEtchedBorder();
    mainPanel.setBorder(border);

    GridBagLayout layout = new GridBagLayout();
    getContentPane().setLayout(layout);

    layout.setConstraints(
        mainPanel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    getContentPane().add(mainPanel);

    pack();
    setResizable(false);
  }
예제 #26
0
  /** This method is called from within the constructor to initialize the form. */
  public void initComponents() {

    /** **************** The components ********************************* */
    firstPanel = new JPanel();
    firstPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 2));
    // If put to False: we see the container's background
    firstPanel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    firstPanel.setLayout(new GridLayout(4, 2, 3, 3));
    this.setLayout(new GridLayout(2, 1, 3, 3));
    this.add(firstPanel);

    proxyStackNameLabel = new JLabel("Proxy stack name:");
    proxyStackNameLabel.setToolTipText("The name of the stack to set");
    // Alignment of the text
    proxyStackNameLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    proxyStackNameLabel.setForeground(Color.black);
    // Size of the text
    proxyStackNameLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    proxyStackNameLabel.setOpaque(true);
    proxyStackNameLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    proxyStackNameLabel.setBorder(ProxyLauncher.labelBorder);
    proxyStackNameTextField = new JTextField(20);
    proxyStackNameTextField.setHorizontalAlignment(AbstractButton.CENTER);
    proxyStackNameTextField.setFont(new Font("Dialog", 0, 14));
    proxyStackNameTextField.setBackground(ProxyLauncher.textBackGroundColor);
    proxyStackNameTextField.setForeground(Color.black);
    proxyStackNameTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(proxyStackNameLabel);
    firstPanel.add(proxyStackNameTextField);

    proxyIPAddressLabel = new JLabel("Proxy IP address:");
    proxyIPAddressLabel.setToolTipText("The address of the proxy to set");
    // Alignment of the text
    proxyIPAddressLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    proxyIPAddressLabel.setForeground(Color.black);
    // Size of the text
    proxyIPAddressLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    proxyIPAddressLabel.setOpaque(true);
    proxyIPAddressLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    proxyIPAddressLabel.setBorder(ProxyLauncher.labelBorder);
    proxyIPAddressTextField = new JTextField(20);
    proxyIPAddressTextField.setHorizontalAlignment(AbstractButton.CENTER);
    proxyIPAddressTextField.setFont(new Font("Dialog", 0, 14));
    proxyIPAddressTextField.setBackground(ProxyLauncher.textBackGroundColor);
    proxyIPAddressTextField.setForeground(Color.black);
    proxyIPAddressTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(proxyIPAddressLabel);
    firstPanel.add(proxyIPAddressTextField);

    outboundProxyLabel = new JLabel("Next hop (IP:port/protocol):");
    outboundProxyLabel.setToolTipText(
        "Location where the message will be sent "
            + "if all the resolutions (DNS, router,...) fail. If not set: 404 will be replied");
    // Alignment of the text
    outboundProxyLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    outboundProxyLabel.setForeground(Color.black);
    // Size of the text
    outboundProxyLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    outboundProxyLabel.setOpaque(true);
    outboundProxyLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    outboundProxyLabel.setBorder(ProxyLauncher.labelBorder);
    outboundProxyTextField = new JTextField(20);
    outboundProxyTextField.setHorizontalAlignment(AbstractButton.CENTER);
    outboundProxyTextField.setFont(new Font("Dialog", 0, 14));
    outboundProxyTextField.setBackground(ProxyLauncher.textBackGroundColor);
    outboundProxyTextField.setForeground(Color.black);
    outboundProxyTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(outboundProxyLabel);
    firstPanel.add(outboundProxyTextField);

    routerClassLabel = new JLabel("The Router class name:");
    routerClassLabel.setToolTipText(
        "The class name (full java package name) of the router" + " used to forward the messages");
    // Alignment of the text
    routerClassLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    routerClassLabel.setForeground(Color.black);
    // Size of the text
    routerClassLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    routerClassLabel.setOpaque(true);
    routerClassLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    routerClassLabel.setBorder(ProxyLauncher.labelBorder);
    routerClassTextField = new JTextField(20);
    routerClassTextField.setHorizontalAlignment(AbstractButton.CENTER);
    routerClassTextField.setFont(new Font("Dialog", 0, 12));
    routerClassTextField.setBackground(ProxyLauncher.textBackGroundColor);
    routerClassTextField.setForeground(Color.black);
    routerClassTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(routerClassLabel);
    firstPanel.add(routerClassTextField);

    JPanel panel = new JPanel();
    // top, left, bottom, right
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 2));
    // If put to False: we see the container's background
    panel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    panel.setLayout(new BorderLayout());
    this.add(panel);

    JLabel lpLabel = new JLabel("Listening points list:");
    lpLabel.setVisible(true);
    lpLabel.setToolTipText("The listening points of the proxy");
    lpLabel.setHorizontalAlignment(AbstractButton.CENTER);
    lpLabel.setForeground(Color.black);
    lpLabel.setFont(new Font("Dialog", 1, 12));
    lpLabel.setOpaque(true);
    lpLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    lpLabel.setBorder(ProxyLauncher.labelBorder);
    panel.add(lpLabel, BorderLayout.NORTH);

    // this.add(listeningPointsList);
    JScrollPane scrollPane =
        new JScrollPane(
            listeningPointsList,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    panel.add(scrollPane, BorderLayout.CENTER);

    thirdPanel = new JPanel();
    thirdPanel.setOpaque(false);
    // top, left, bottom, right
    thirdPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 5, 0));
    thirdPanel.setLayout(new GridLayout(1, 2, 3, 3));

    JButton addLPButton = new JButton(" Add ");
    addLPButton.setToolTipText("Add a listening point");
    addLPButton.setFocusPainted(false);
    addLPButton.setFont(new Font("Dialog", 1, 16));
    addLPButton.setBackground(ProxyLauncher.buttonBackGroundColor);
    addLPButton.setBorder(ProxyLauncher.buttonBorder);
    addLPButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            addLPButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(addLPButton);

    JButton removeLPButton = new JButton(" Remove ");
    removeLPButton.setToolTipText("Remove a listening point");
    removeLPButton.setFocusPainted(false);
    removeLPButton.setFont(new Font("Dialog", 1, 16));
    removeLPButton.setBackground(ProxyLauncher.buttonBackGroundColor);
    removeLPButton.setBorder(ProxyLauncher.buttonBorder);
    removeLPButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            removeLPButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(removeLPButton);

    panel.add(thirdPanel, BorderLayout.SOUTH);
  }
예제 #27
0
  public SyntaxTab() {
    super(new BorderLayout(), "Syntax highlighting");
    /*
     * upper checkboxes
     */
    JPanel upper = new JPanel(new GridLayout(2, 1, 0, 0));
    upper.setOpaque(false);
    upper.add(MyPanel.wrap(highlightSyntax));
    upper.add(MyPanel.wrap(matchBracket));
    highlightSyntax.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ev) {
            SyntaxTab.this.updateComponentStatus();
          }
        });
    this.add(upper, BorderLayout.PAGE_START);
    /*
     * upper panel (painters)
     */
    painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getCurrentInstance());
    painterComboBox.setFont(f13);
    if (isMetal) painterComboBox.setBackground(Color.WHITE);
    painterComboBox.addItemListener(this.painterChangeListener);
    JButton addPainter =
        new MyButton("+") {
          {
            if (isMetal) {
              this.setPreferredSize(new Dimension(28, 28));
            }
          }

          @Override
          public void actionPerformed(ActionEvent ev) {
            String name;
            do {
              name =
                  JOptionPane.showInputDialog(
                      SyntaxTab.this, "Enter a name:", "Name", JOptionPane.QUESTION_MESSAGE);
            } while (!myjava.gui.syntax.Painter.isValidPrompt(name, SyntaxTab.this));
            if ((name != null) && (!name.isEmpty())) {
              // name is valid, neither cancelled nor pressed enter directly
              myjava.gui.syntax.Painter newPainter =
                  ((myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem()))
                      .newInstance(name);
              addPainter(newPainter);
              System.out.println("now set, should call listener");
              painterComboBox.setSelectedItem(newPainter); // auto-call ItemListener(s)
            }
          }
        };
    JButton removePainter =
        new MyButton("-") {
          {
            if (isMetal) {
              this.setPreferredSize(new Dimension(28, 28));
            }
          }

          @Override
          public void actionPerformed(ActionEvent ev) {
            myjava.gui.syntax.Painter painter =
                (myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem());
            if (painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) {
              JOptionPane.showMessageDialog(
                  SyntaxTab.this,
                  "The default painter cannot be removed.",
                  "Error",
                  JOptionPane.ERROR_MESSAGE);
            } else {
              int option =
                  JOptionPane.showConfirmDialog(
                      SyntaxTab.this,
                      "Remove painter \"" + painter.getName() + "\"?",
                      "Confirm",
                      JOptionPane.YES_NO_OPTION);
              if (option == JOptionPane.YES_OPTION) {
                // remove "painter"
                removedPainters.add(painter);
                painterComboBox.removeItemListener(painterChangeListener);
                painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getDefaultInstance());
                painterComboBox.removeItem(painter);
                for (Iterator<EntryListPanel> it = listPanelSet.iterator(); it.hasNext(); ) {
                  EntryListPanel panel = it.next();
                  if (panel.getPainter().getName().equals(painter.getName())) {
                    System.out.println("removing, then break");
                    it.remove();
                    centerPanel.remove(panel);
                    break;
                  }
                }
                painterComboBox.addItemListener(painterChangeListener);
                cardLayout.show(
                    centerPanel, myjava.gui.syntax.Painter.getDefaultInstance().getName());
              }
            }
          }
        };
    // lower part
    JPanel center = new JPanel(new BorderLayout());
    JLabel selectLabel = new MyLabel("Selected painter:");
    center.add(
        MyPanel.wrap(MyPanel.CENTER, selectLabel, painterComboBox, addPainter, removePainter),
        BorderLayout.PAGE_START);
    componentSet.addAll(Arrays.asList(selectLabel, addPainter, removePainter));
    center.add(centerPanel, BorderLayout.CENTER);
    this.add(center, BorderLayout.CENTER);
    cardLayout.show(centerPanel, myjava.gui.syntax.Painter.getCurrentInstance().getName());
  }
예제 #28
0
  /** Constructor. */
  VSubmenuPreferences() {

    pnlPrefs.setOpaque(false);
    pnlPrefs.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));

    // Spacing between components is defined here.
    final String sectionConstraints = "w 80%!, h 42px!, gap 10% 0 10px 10px, span 2 1";
    final String regularConstraints = "w 80%!, h 22px!, gap 10% 0 0 10px, span 2 1";

    // Troubleshooting
    pnlPrefs.add(new SectionLabel("Troubleshooting"), sectionConstraints);

    // Reset buttons
    final String twoButtonConstraints1 = "w 38%!, h 30px!, gap 10% 0 0 10px";
    final String twoButtonConstraints2 = "w 38%!, h 30px!, gap 0 0 0 10px";
    pnlPrefs.add(btnReset, twoButtonConstraints1);
    pnlPrefs.add(btnDeleteMatchUI, twoButtonConstraints2);
    pnlPrefs.add(btnDeleteEditorUI, twoButtonConstraints1);
    pnlPrefs.add(btnDeleteWorkshopUI, twoButtonConstraints2);
    pnlPrefs.add(btnUserProfileUI, twoButtonConstraints1);
    pnlPrefs.add(btnContentDirectoryUI, twoButtonConstraints2);

    // General Configuration
    pnlPrefs.add(new SectionLabel("General Configuration"), sectionConstraints + ", gaptop 2%");

    pnlPrefs.add(getPlayerNamePanel(), regularConstraints + ", h 26px!");
    pnlPrefs.add(
        new NoteLabel("Sets the name that you will be referred to by Forge during gameplay."),
        regularConstraints);

    pnlPrefs.add(cbCompactMainMenu, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Enable for a space efficient sidebar that displays only one menu group at a time (RESTART REQUIRED)."),
        regularConstraints);

    // Gameplay Options
    pnlPrefs.add(new SectionLabel("Gameplay"), sectionConstraints + ", gaptop 2%");

    pnlPrefs.add(cbpAiProfiles, "w 80%!, gap 10% 0 0 10px, span 2 1");
    pnlPrefs.add(new NoteLabel("Choose your AI opponent."), regularConstraints);

    pnlPrefs.add(cbAnte, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Determines whether or not the game is played for ante."),
        regularConstraints);

    pnlPrefs.add(cbAnteMatchRarity, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Attempts to make antes the same rarity for all players."),
        regularConstraints);

    pnlPrefs.add(cbEnableAICheats, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Allow the AI to cheat to gain advantage (for personalities that have cheat shuffling options set)."),
        regularConstraints);

    pnlPrefs.add(cbManaBurn, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Play with mana burn (from pre-Magic 2010 rules)."), regularConstraints);

    pnlPrefs.add(cbManaLostPrompt, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "When enabled, you get a warning if passing priority would cause you to lose mana in your mana pool."),
        regularConstraints);

    pnlPrefs.add(cbEnforceDeckLegality, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Enforces deck legality relevant to each environment (minimum deck sizes, max card count etc)."),
        regularConstraints);

    pnlPrefs.add(cbCloneImgSource, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "When enabled clones will use their original art instead of the cloned card's art."),
        regularConstraints);

    pnlPrefs.add(cbPromptFreeBlocks, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "When enabled, if you would have to pay 0 to block, pay automatically without prompt."),
        regularConstraints);

    pnlPrefs.add(cbPauseWhileMinimized, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("When enabled, Forge pauses when minimized (primarily for AI vs AI)."),
        regularConstraints);

    // Deck building options
    pnlPrefs.add(new SectionLabel("Random Deck Generation"), sectionConstraints);

    pnlPrefs.add(cbRemoveSmall, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Disables 1/1 and 0/X creatures in generated decks."), regularConstraints);

    pnlPrefs.add(cbSingletons, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Disables non-land duplicates in generated decks."), regularConstraints);

    pnlPrefs.add(cbRemoveArtifacts, regularConstraints);
    pnlPrefs.add(new NoteLabel("Disables artifact cards in generated decks."), regularConstraints);

    // Deck building options
    pnlPrefs.add(new SectionLabel("Deck Editor Options"), sectionConstraints);

    pnlPrefs.add(cbFilterLandsByColorId, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "When using card color filters, filter lands in a way to make it easier to find relevant mana producing lands."),
        regularConstraints);

    // Advanced
    pnlPrefs.add(new SectionLabel("Advanced Settings"), sectionConstraints);

    pnlPrefs.add(cbDevMode, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Enables menu with functions for testing during development."),
        regularConstraints);

    pnlPrefs.add(cbWorkshopSyntax, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Enables syntax checking of card scripts in the Workshop. Note: functionality still in testing phase!"),
        regularConstraints);

    pnlPrefs.add(cbpGameLogEntryType, "w 80%!, gap 10% 0 0 10px, span 2 1");
    pnlPrefs.add(
        new NoteLabel(
            "Changes how much information is displayed in the game log. Sorted by least to most verbose."),
        regularConstraints);

    pnlPrefs.add(cbpCloseAction, "w 80%!, gap 10% 0 0 10px, span 2 1");
    pnlPrefs.add(
        new NoteLabel("Changes what happens when clicking the X button in the upper right."),
        regularConstraints);

    // Graphic Options
    pnlPrefs.add(new SectionLabel("Graphic Options"), sectionConstraints + ", gaptop 2%");

    pnlPrefs.add(cbImageFetcher, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Enables live fetching of missing card images from an online resource."),
        regularConstraints);

    pnlPrefs.add(cbDisplayFoil, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Displays foil cards with the visual foil overlay effect."),
        regularConstraints);

    pnlPrefs.add(cbRandomFoil, regularConstraints);
    pnlPrefs.add(new NoteLabel("Adds foil effect to random cards."), regularConstraints);

    pnlPrefs.add(cbScaleLarger, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Allows card pictures to be expanded larger than their original size."),
        regularConstraints);

    pnlPrefs.add(cbLargeCardViewers, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Makes all card viewers much larger for use with high resolution images. Will not fit on smaller screens."),
        regularConstraints);

    pnlPrefs.add(cbRandomArtInPools, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Generates cards with random art in generated limited mode card pools."),
        regularConstraints);

    pnlPrefs.add(cbUiForTouchScreen, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Increases some UI elements to provide a better experience on touchscreen devices. (Needs restart)"),
        regularConstraints);

    pnlPrefs.add(cbCompactPrompt, regularConstraints);
    pnlPrefs.add(
        new NoteLabel("Hide header and use smaller font in Prompt pane to make it more compact."),
        regularConstraints);

    /*pnlPrefs.add(cbStackCardView, regularConstraints); TODO: Show this checkbox when setting can support being enabled
    pnlPrefs.add(new NoteLabel("Show cards and abilities on Stack in card view rather than list view."), regularConstraints);*/

    pnlPrefs.add(cbHideReminderText, regularConstraints);
    pnlPrefs.add(new NoteLabel("Hide reminder text in Card Detail pane."), regularConstraints);

    pnlPrefs.add(cbOpenPacksIndiv, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "When opening Fat Packs and Booster Boxes, booster packs will be opened and displayed one at a time."),
        regularConstraints);

    pnlPrefs.add(cbTokensInSeparateRow, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Displays tokens in a separate row on the battlefield below the non-token creatures."),
        regularConstraints);

    pnlPrefs.add(cbStackCreatures, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Stacks identical creatures on the battlefield like lands, artifacts, and enchantments."),
        regularConstraints);

    pnlPrefs.add(cbpDisplayCurrentCardColors, "w 80%!, gap 10% 0 0 10px, span 2 1");
    pnlPrefs.add(
        new NoteLabel(
            "Displays the breakdown of the current color of cards in the card detail information panel."),
        regularConstraints);

    // Sound options
    pnlPrefs.add(new SectionLabel("Sound Options"), sectionConstraints + ", gaptop 2%");

    pnlPrefs.add(cbEnableSounds, regularConstraints);
    pnlPrefs.add(new NoteLabel("Enable sound effects during the game."), regularConstraints);

    pnlPrefs.add(cbEnableMusic, regularConstraints);
    pnlPrefs.add(new NoteLabel("Enable background music during the game."), regularConstraints);

    pnlPrefs.add(cbAltSoundSystem, regularConstraints);
    pnlPrefs.add(
        new NoteLabel(
            "Use the alternate sound system (only use if you have issues with sound not playing or disappearing)."),
        regularConstraints);

    // Keyboard shortcuts
    final JLabel lblShortcuts = new SectionLabel("Keyboard Shortcuts");
    pnlPrefs.add(lblShortcuts, sectionConstraints + ", gaptop 2%");

    final List<Shortcut> shortcuts = KeyboardShortcuts.getKeyboardShortcuts();

    for (final Shortcut s : shortcuts) {
      pnlPrefs.add(
          new FLabel.Builder().text(s.getDescription()).fontAlign(SwingConstants.RIGHT).build(),
          "w 50%!, h 22px!, gap 0 2% 0 1%");
      KeyboardShortcutField field = new KeyboardShortcutField(s);
      pnlPrefs.add(field, "w 25%!");
      shortcutFields.put(s.getPrefKey(), field);
    }
  }
  private void makeAndSetTabComponents() {
    final String[] tabTitles = {"Libraries", "Modes", "Tools", "Examples", "Updates"};
    tabLabels = new JLabel[4];

    for (int i = 0; i < 4; i++) {
      final int temp = i;
      tabLabels[i] =
          new JLabel(tabTitles[i]) {
            @Override
            protected void paintComponent(Graphics g) {
              g.setClip(
                  Toolkit.createRoundRect(
                      0, 0, getWidth(), getHeight(), temp == 0 ? 6 : 0, temp == 3 ? 6 : 0, 0, 0));
              super.paintComponent(g);
            }
          };
      tabLabels[i].setForeground(Color.WHITE);
      tabLabels[i].setBackground(new Color(0x2d4251));
      tabLabels[i].setOpaque(true);
      tabLabels[i].setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
      tabLabels[i].setPreferredSize(new Dimension(TAB_WIDTH, TAB_HEIGHT));
      tabLabels[i].setHorizontalAlignment(SwingConstants.CENTER);
      tabLabels[i].setFont(Toolkit.getSansFont(14, Font.BOLD));
      tabbedPane.setTabComponentAt(i, tabLabels[i]);
    }

    updateTabPanel =
        new JPanel() {
          @Override
          protected void paintComponent(Graphics g) {
            g.setClip(Toolkit.createRoundRect(0, 0, getWidth(), getHeight(), 6, 6, 0, 0));
            super.paintComponent(g);
          }
        };
    ;
    updateTabLabel = new JLabel("Updates");
    updateTabLabel.setFont(Toolkit.getSansFont(14, Font.BOLD));
    numberLabel.setVerticalTextPosition(SwingConstants.CENTER);
    numberLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    numberLabel.setFont(Toolkit.getSansFont(14, Font.BOLD));
    numberLabel.setForeground(Color.WHITE);
    updateTabPanel.setOpaque(true);
    updateTabPanel.setBackground(new Color(0x2d4251));
    updateTabLabel.setForeground(Color.WHITE);
    updateTabPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    updateTabPanel.setPreferredSize(new Dimension(TAB_WIDTH, TAB_HEIGHT));
    tabbedPane.setTabComponentAt(4, updateTabPanel);

    GroupLayout tabLayout = new GroupLayout(updateTabPanel);
    tabLayout.setAutoCreateGaps(true);
    updateTabPanel.setLayout(tabLayout);
    tabLayout.setHorizontalGroup(
        tabLayout
            .createSequentialGroup()
            .addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addComponent(updateTabLabel)
            .addComponent(numberLabel)
            .addPreferredGap(
                LayoutStyle.ComponentPlacement.RELATED,
                GroupLayout.PREFERRED_SIZE,
                Short.MAX_VALUE));
    tabLayout.setVerticalGroup(
        tabLayout
            .createParallelGroup(GroupLayout.Alignment.CENTER)
            .addComponent(numberLabel)
            .addComponent(updateTabLabel));

    numberLabel.setVisible(false);
  }
예제 #30
0
  /** Instantiates a new game panel. */
  public GamePanel() {
    super();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    CARD_BACK.add(new CardPanel("img/cards/BACK.png"));

    // The code below is just for reference
    //        dealerCards = new ArrayList<>();
    //        for (int i = 0; i < dealerInHand.size(); i++)
    //        {
    //            dealerCards.add(new CardPanel("img/cards/" + dealerInHand.get(i) + ".png"));
    //        }
    //
    //        playerCardsOne = new ArrayList<>();
    //        for (int i = 0; i < playerInHandOne.size(); i++)
    //        {
    //            playerCardsOne.add(new CardPanel("img/cards/" + playerInHandOne.get(i) + ".png"));
    //        }
    //
    //        playerCardsTwo = new ArrayList<>();
    //        for (int i = 0; i < playerInHandTwo.size(); i++)
    //        {
    //            playerCardsTwo.add(new CardPanel("img/cards/" + playerInHandTwo.get(i) + ".png"));
    //        }
    // The code above is just for reference

    dealerDeckContainer = new CardDeckContainer();
    dealerStatContainer = new JPanel(new BorderLayout());
    dealerStatContainer.setOpaque(false);
    JLabel dealerStatTitle = new JLabel("Dealer in Hand");
    dealerStatTitle.setForeground(Color.WHITE);
    dealerStatTitle.setHorizontalAlignment(JLabel.CENTER);
    dealerStatTitle.setFont(new Font("", Font.PLAIN, 12));
    dealerStatPoint.setForeground(Color.WHITE);
    dealerStatPoint.setHorizontalAlignment(JLabel.CENTER);
    dealerStatPoint.setFont(new Font("", Font.PLAIN, 12));
    dealerStatContainer.add(dealerStatTitle, BorderLayout.NORTH);
    dealerStatContainer.add(dealerStatPoint, BorderLayout.CENTER);

    playerDeckOneContainer = new CardDeckContainer();
    playerStatOneContainer = new JPanel(new BorderLayout());
    playerStatOneContainer.setOpaque(false);
    JLabel playerStatOneTitle = new JLabel("Player in Hand");
    playerStatOneTitle.setForeground(Color.WHITE);
    playerStatOneTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatOnePoint.setForeground(Color.WHITE);
    playerStatOnePoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatOnePoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatOneDescription.setForeground(Color.WHITE);
    playerStatOneDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatOneContainer.add(playerStatOneTitle, BorderLayout.NORTH);
    playerStatOneContainer.add(playerStatOnePoint, BorderLayout.CENTER);
    playerStatOneContainer.add(playerStatOneDescription, BorderLayout.SOUTH);

    playerDeckTwoContainer = new CardDeckContainer(new CardDeckPanel(CARD_BACK));
    playerStatTwoContainer = new JPanel(new BorderLayout());
    playerStatTwoContainer.setOpaque(false);
    JLabel playerStatTwoTitle = new JLabel("Player Hand 2");
    playerStatTwoTitle.setForeground(Color.WHITE);
    playerStatTwoTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoPoint.setForeground(Color.WHITE);
    playerStatTwoPoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoPoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoDescription.setForeground(Color.WHITE);
    playerStatTwoDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatTwoContainer.add(playerStatTwoTitle, BorderLayout.NORTH);
    playerStatTwoContainer.add(playerStatTwoPoint, BorderLayout.CENTER);
    playerStatTwoContainer.add(playerStatTwoDescription, BorderLayout.SOUTH);

    gameStatPanel = new JPanel();
    gameStatPanelPlayerName = new JLabel();
    gameStatPanelCurrentChips = new JLabel();
    gameStatPanelCurrentBet = new JLabel();
    gameStatPanelPlayerName.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelPlayerName.setForeground(Color.WHITE);
    gameStatPanelPlayerName.setBorder(new EmptyBorder(0, 0, 0, 5));
    gameStatPanelCurrentChips.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentChips.setForeground(Color.WHITE);
    gameStatPanelCurrentChips.setBorder(new EmptyBorder(0, 5, 0, 5));
    gameStatPanelCurrentBet.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentBet.setForeground(Color.WHITE);
    gameStatPanelCurrentBet.setBorder(new EmptyBorder(0, 5, 0, 0));
    gameStatPanel.add(gameStatPanelPlayerName);
    gameStatPanel.add(gameStatPanelCurrentChips);
    gameStatPanel.add(gameStatPanelCurrentBet);
    gameStatPanel.setOpaque(false);

    gameButtonPanel = new JPanel(cardLayout);
    betButtonPanel = new JPanel();
    playButtonPanel = new JPanel();
    JLabel pleaseBet = new JLabel("Please bet: ");
    pleaseBet.setFont(new Font("", Font.PLAIN, 14));
    pleaseBet.setForeground(Color.WHITE);
    betButtonPanel.add(pleaseBet);
    betField = new JTextField();
    betField.setFont(new Font("", Font.PLAIN, 14));
    betField.setPreferredSize(new Dimension(80, 28));
    betButtonPanel.add(betField);
    JButton betButton = new JButton("Bet");
    JButton backButton = new JButton("Back");
    betButtonPanel.add(betButton);
    betButtonPanel.add(backButton);
    betButtonPanel.setOpaque(false);

    hitButton = new JButton("Hit");
    standButton = new JButton("Stand");
    doubleButton = new JButton("Double");
    // JButton splitButton = new JButton("Split");
    // splitButton.setEnabled(false);
    playButtonPanel.add(hitButton);
    playButtonPanel.add(standButton);
    playButtonPanel.add(doubleButton);
    // playButtonPanel.add(splitButton);
    playButtonPanel.setOpaque(false);
    gameButtonPanel.add("betbutton", betButtonPanel);
    gameButtonPanel.add("playbutton", playButtonPanel);
    gameButtonPanel.setOpaque(false);

    add(gameStatPanel);
    add(dealerDeckContainer);
    add(playerDeckTwoContainer);
    add(playerDeckOneContainer);
    add(gameButtonPanel);

    this.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            Game.initGame();
          }
        });

    betButtonPanel.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            betField.setText("");
            if (BlackJack.player.getChip() <= 0) {
              JOptionPane.showMessageDialog(
                  null, "You are penniless!", "Information", JOptionPane.INFORMATION_MESSAGE);
              User.deleteUserByName(BlackJack.player.getName());
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
            hitButton.setEnabled(true);
            standButton.setEnabled(true);
            doubleButton.setEnabled(true);
            BlackJack.player.setBet(0);
            BlackJack.player.getHandOne().clear();
            BlackJack.player.getHandTwo().clear();
            BlackJack.dealer.getHandOne().clear();
            GamePanel.gameStatPanelPlayerName.setText("Player: " + BlackJack.player.getName());
            GamePanel.gameStatPanelCurrentChips.setText("Chips: " + BlackJack.player.getChip());
            GamePanel.gameStatPanelCurrentBet.setText("Bet: 0");
            GamePanel.gameStatPanel.repaint();
          }
        });

    betField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent e) {
            int keyChar = e.getKeyChar();
            if (keyChar < KeyEvent.VK_0 || keyChar > KeyEvent.VK_9) {
              e.consume();
            }
          }
        });

    betButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Game.bet(Integer.parseInt(betField.getText()));
          }
        });

    backButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int choice =
                JOptionPane.showConfirmDialog(
                    null,
                    "Do you want to go back to main menu?\nYour record will be saved.",
                    "Go Back",
                    JOptionPane.YES_NO_OPTION);
            if (choice == JOptionPane.YES_OPTION) {
              User.updateUser();
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
          }
        });

    hitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            doubleButton.setEnabled(false);
            Game.hit();
          }
        });

    standButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            playerStatOneDescription.setText("Stand");
            playerStatOneDescription.repaint();
            Game.dealerGame();
          }
        });

    doubleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            if (!Game.doubleDown()) {
              hitButton.setEnabled(true);
              standButton.setEnabled(true);
              doubleButton.setEnabled(false);
            }
          }
        });
  }