示例#1
0
文件: Main.java 项目: Binney/gPLINK
  /** Creates a new Main object. */
  public Main() {
    super("ssh-keygen");

    /* try {
    ConfigurationLoader.setLogfile(ConfigurationLoader.getHomeDirectory()
     + "logs/ssh-keygen.log");
    } catch (IOException ex) {
    }*/
    try {
      ConfigurationLoader.initialize(false);
    } catch (ConfigurationException ex) {
    }

    //  Set the frame icon
    setIconImage(new ResourceIcon(ICON).getImage());

    //
    keygen = new KeygenPanel();

    //  Create the center banner panel
    IconWrapperPanel centerPanel = new IconWrapperPanel(new ResourceIcon(ICON), keygen);
    centerPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

    //  Button panel
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(6, 6, 0, 0);
    gbc.weighty = 1.0;
    generate = new JButton("Generate");
    generate.addActionListener(this);
    generate.setMnemonic('g');
    this.getRootPane().setDefaultButton(generate);
    UIUtil.jGridBagAdd(buttonPanel, generate, gbc, GridBagConstraints.RELATIVE);
    close = new JButton("Close");
    close.addActionListener(this);
    close.setMnemonic('c');
    UIUtil.jGridBagAdd(buttonPanel, close, gbc, GridBagConstraints.REMAINDER);

    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    southPanel.add(buttonPanel);

    //  Wrap the whole thing in an empty border
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPanel.add(centerPanel, BorderLayout.CENTER);
    mainPanel.add(southPanel, BorderLayout.SOUTH);

    //  Build the main panel
    getContentPane().setLayout(new GridLayout(1, 1));
    getContentPane().add(mainPanel);
  }
示例#2
0
文件: Main.java 项目: Binney/gPLINK
  /** @param args */
  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }

    Main main = new Main();
    main.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
    main.pack();
    UIUtil.positionComponent(SwingConstants.CENTER, main);
    main.setVisible(true);
  }