Exemplo n.º 1
0
  public ConfigPanel() {
    setLayout(new GridLayout(0, 1));

    Object backgroundObject = MainFrame.getBackgroundObject();
    Color backgroundColor = (backgroundObject instanceof Color) ? (Color) backgroundObject : null;

    okayButton =
        new JButton("Ok") {
          {
            addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent ae) {
                    Window w = SwingUtilities.getWindowAncestor(okayButton);

                    if (w != null) {
                      font1Panel.run();
                      font2Panel.run();
                      backgroundPanel.run();
                      topMarginField.run();
                      leftMarginField.run();
                      bottomMarginField.run();
                      rightMarginField.run();

                      w.setVisible(false);
                    }
                  }
                });
          }
        };

    add(font1Panel = new ChooseFontPanel("Top Font", "font1_file", "font1_size"));
    add(font2Panel = new ChooseFontPanel("Bottom Font", "font2_file", "font2_size"));
    add(backgroundPanel = new ChooseBackgroundPanel("Background", "background"));
    add(
        new PairPanel(
            topMarginField = new ChooseNumberPanel("Top Margin", 0d, 1d, "margin_top"),
            bottomMarginField = new ChooseNumberPanel("Bottom Margin", 0d, 1d, "margin_bottom")));
    add(
        new PairPanel(
            leftMarginField = new ChooseNumberPanel("Left Margin", 0d, 1d, "margin_left"),
            rightMarginField = new ChooseNumberPanel("Right Margin", 0d, 1d, "margin_right")));
  }
Exemplo n.º 2
0
  private MainFrame() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle(Main.APPLICATION_NAME);

    ProgramWindow.getInstance().setGraphicsDevice(MainFrame.getSelectedGraphicsDevice());
    ProgramWindow.getInstance().reloadBackground();

    setContentPane(
        new JPanel() {
          {
            setLayout(new BorderLayout());

            MainSplitPane splitPane = MainSplitPane.getInstance();
            MainTabbedPane tabbedPane = MainTabbedPane.getInstance();
            BottomPanel optionPane = BottomPanel.getInstance();

            add(
                new JPanel() {
                  {
                    setLayout(new BorderLayout());
                    add(SearchField.getInstance(), BorderLayout.CENTER);
                    add(
                        new JPanel() {
                          {
                            setLayout(new GridLayout(1, 2));

                            add(
                                new JButton() {
                                  {
                                    setText("Settings");
                                    addActionListener(
                                        new ActionListener() {
                                          @Override
                                          public void actionPerformed(ActionEvent ae) {
                                            ConfigPanel configPanel = new ConfigPanel();

                                            JOptionPane.showOptionDialog(
                                                MainFrame.this,
                                                configPanel,
                                                "Settings",
                                                JOptionPane.DEFAULT_OPTION,
                                                JOptionPane.PLAIN_MESSAGE,
                                                null,
                                                new JButton[] {configPanel.getOkayButton()},
                                                configPanel.getOkayButton());
                                          }
                                        });
                                  }
                                });

                            add(
                                new JButton() {
                                  {
                                    setText("About");
                                    addActionListener(
                                        new ActionListener() {
                                          @Override
                                          public void actionPerformed(ActionEvent ae) {
                                            JOptionPane.showMessageDialog(
                                                MainFrame.this,
                                                AboutPanel.getInstance(),
                                                "About",
                                                JOptionPane.PLAIN_MESSAGE);
                                          }
                                        });
                                  }
                                });
                          }
                        },
                        BorderLayout.EAST);
                  }
                },
                BorderLayout.NORTH);

            add(splitPane, BorderLayout.CENTER);
            add(optionPane, BorderLayout.SOUTH);
          }
        });

    setFocusTraversalPolicy(
        new DefaultFocusTraversalPolicy() {
          @Override
          protected boolean accept(Component c) {
            return c != SearchField.getInstance();
          }
        });

    setSize(1024, 768);
    setLocationRelativeTo(null);
    // setExtendedState(MAXIMIZED_BOTH);
  }