示例#1
0
  public ThemeChooseWindow(Frame parent) throws Exception {
    super(parent);

    File dir = new File(GUI.getJarPath() + File.separator + "theme" + File.separator);

    LOG.debug("Theme path: " + dir.getPath());

    File[] files = dir.listFiles();
    if (files != null && dir.exists()) {
      this.setTitle(Settings.lang("choose_theme_window_title"));
      Dimension winDim = new Dimension(550, 230);
      this.setMinimumSize(winDim);
      this.setMaximumSize(winDim);
      this.setSize(winDim);
      this.setResizable(false);
      this.setLayout(null);
      this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      String[] dirNames = new String[files.length];
      for (int i = 0; i < files.length; i++) {
        dirNames[i] = files[i].getName();
      }
      this.themesList = new JList(dirNames);
      this.themesList.setLocation(new Point(10, 10));
      this.themesList.setSize(new Dimension(100, 120));
      this.add(this.themesList);
      this.themesList.setSelectionMode(0);
      this.themesList.addListSelectionListener(this);
      Properties prp = GUI.getConfigFile();

      this.gbl = new GridBagLayout();
      this.gbc = new GridBagConstraints();
      try {
        this.themePreview = new ImageIcon(GUI.loadImage("Preview.png"));
      } catch (NullPointerException exc) {
        LOG.error("NullPointerException: Cannot find preview image: " + exc);
        this.themePreview = new ImageIcon(JChessApp.class.getResource("theme/noPreview.png"));
        return;
      }
      this.result = "";
      this.themePreviewButton = new JButton(this.themePreview);
      this.themePreviewButton.setLocation(new Point(110, 10));
      this.themePreviewButton.setSize(new Dimension(420, 120));
      this.add(this.themePreviewButton);
      this.okButton = new JButton("OK");
      this.okButton.setLocation(new Point(175, 140));
      this.okButton.setSize(new Dimension(200, 50));
      this.add(this.okButton);
      this.okButton.addActionListener(this);
      this.setModal(true);
    } else {
      throw new Exception(Settings.lang("error_when_creating_theme_config_window"));
    }
  }
示例#2
0
  @Override
  public void valueChanged(ListSelectionEvent event) {
    String element =
        this.themesList.getModel().getElementAt(this.themesList.getSelectedIndex()).toString();
    String path = GUI.getJarPath() + File.separator + "theme/";
    // String path  = JChessApp.class.getResource("theme/").getPath().toString();

    LOG.debug(path + element + "/images/Preview.png");

    this.themePreview = new ImageIcon(path + element + "/images/Preview.png");
    this.themePreviewButton.setIcon(this.themePreview);
  }