buttons.add(Box.createRigidArea(new Dimension(5, 0))); buttons.add(previewButton);
    private void init() {        // Create the primitives        JLabel nameLabel = new JLabel(NAME_LABEL);        JLabel tileWidthLabel = new JLabel(TILE_WIDTH_LABEL);        JLabel tileHeightLabel = new JLabel(TILE_HEIGHT_LABEL);        spacingLabel = new JLabel(TILE_SPACING_LABEL);        tilebmpFileLabel = new JLabel(IMAGE_LABEL);        cutterLabel = new JLabel("Tile Cutter: ");        tilesetName = new JTextField(UNTITLED_FILE);        tileWidth = new IntegerSpinner(map.getTileWidth(), 1, 1024);        tileHeight = new IntegerSpinner(map.getTileHeight(), 1, 1024);        tileSpacing = new IntegerSpinner(0, 0);        tilebmpFile = new JTextField(10);        tilebmpFile.setEnabled(false);        nameLabel.setLabelFor(tilesetName);        tileWidthLabel.setLabelFor(tileWidth);        tileHeightLabel.setLabelFor(tileHeight);        spacingLabel.setLabelFor(tileSpacing);        tilebmpFileLabel.setLabelFor(tilebmpFile);        tileWidthLabel.setEnabled(false);        tileWidth.setEnabled(false);        cutterBox = new JComboBox(new String[] {"Basic", "Border"});        cutterBox.setEditable(false);        cutterBox.setEnabled(false);        cutterLabel.setEnabled(false);        tilebmpCheck = new JCheckBox(TILESET_IMG_LABEL, false);        tilebmpCheck.addChangeListener(this);        transCheck = new JCheckBox(USE_TRANS_COLOR_LABEL);        transCheck.addChangeListener(this);        JButton okButton = new JButton(OK_BUTTON);        previewButton = new JButton(PREVIEW_BUTTON);        JButton cancelButton = new JButton(CANCEL_BUTTON);        browseButton = new JButton(BROWSE_BUTTON);        propsButton = new JButton(PROPERTIES_BUTTON);        colorButton = new ColorButton(new Color(255, 0, 255));        // Combine browse button and tile bitmap path text field        JPanel tilebmpPathPanel = new JPanel(new GridBagLayout());        GridBagConstraints c = new GridBagConstraints();        c.gridx = 0;        c.gridy = 0;        c.weightx = 1;        c.fill = GridBagConstraints.HORIZONTAL;        tilebmpPathPanel.add(tilebmpFile, c);        c.gridx = 1;        c.weightx = 0;        c.fill = GridBagConstraints.NONE;        c.insets = new Insets(0, 5, 0, 0);        tilebmpPathPanel.add(browseButton, c);        // Combine transparent color label and button        JPanel tileColorPanel = new JPanel(new GridBagLayout());        c = new GridBagConstraints();        c.gridx = 0;        c.gridy = 0;        c.weightx = 1;        c.fill = GridBagConstraints.HORIZONTAL;        tileColorPanel.add(transCheck, c);        c.gridx = 1;        tileColorPanel.add(colorButton);        // Create the tile bitmap import setting panel        JPanel tilebmpPanel = new VerticalStaticJPanel();        tilebmpPanel.setLayout(new GridBagLayout());        tilebmpPanel.setBorder(BorderFactory.createCompoundBorder(                BorderFactory.createTitledBorder(FROM_TILESET_IMG_TITLE),                BorderFactory.createEmptyBorder(0, 5, 5, 5)));        c.gridx = 0;        c.gridy = 0;        c.weightx = 0;        c.insets = new Insets(5, 0, 0, 0);        c.anchor = GridBagConstraints.EAST;        c.fill = GridBagConstraints.HORIZONTAL;        c.gridwidth = 2;        tilebmpPanel.add(tilebmpCheck, c);        c.gridy = 1;        c.gridwidth = 1;        c.insets = new Insets(5, 0, 0, 5);        c.fill = GridBagConstraints.NONE;        tilebmpPanel.add(tilebmpFileLabel, c);        c.gridy = 2;        tilebmpPanel.add(spacingLabel, c);        /*        c.gridy = 4;        tilebmpPanel.add(cutterLabel, c);        */        c.gridx = 1;        c.gridy = 1;        c.weightx = 1;        c.insets = new Insets(5, 0, 0, 0);        c.fill = GridBagConstraints.HORIZONTAL;        tilebmpPanel.add(tilebmpPathPanel, c);        c.gridy = 2;        tilebmpPanel.add(tileSpacing, c);        /*        c.gridy = 4;        tilebmpPanel.add(cutterBox, c);        */        c.gridx = 0;        c.gridy = 4;        c.gridwidth = 2;        tilebmpPanel.add(tileColorPanel, c);        c.gridx = 1;        c.gridwidth = 1;        // OK and Cancel buttons        JPanel buttons = new VerticalStaticJPanel();        buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));        buttons.add(Box.createGlue());        buttons.add(okButton);        buttons.add(Box.createRigidArea(new Dimension(5, 0)));        buttons.add(previewButton);        buttons.add(Box.createRigidArea(new Dimension(5, 0)));        buttons.add(cancelButton);        // Top part of form        JPanel miscPropPanel = new VerticalStaticJPanel();        miscPropPanel.setLayout(new GridBagLayout());        miscPropPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));        c.gridx = 0;        c.gridy = 0;        c.weightx = 0;        c.fill = GridBagConstraints.NONE;        c.insets = new Insets(5, 0, 0, 5);        miscPropPanel.add(nameLabel, c);        c.gridy = 1;        miscPropPanel.add(tileWidthLabel, c);        c.gridy = 2;        miscPropPanel.add(tileHeightLabel, c);        c.insets = new Insets(5, 0, 0, 0);        c.fill = GridBagConstraints.HORIZONTAL;        c.gridx = 1;        c.gridy = 0;        c.weightx = 1;        miscPropPanel.add(tilesetName, c);        c.gridy = 1;        miscPropPanel.add(tileWidth, c);        c.gridy = 2;        miscPropPanel.add(tileHeight, c);        c.gridy = 3;        miscPropPanel.add(propsButton, c);        // Main panel        JPanel mainPanel = new JPanel();        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));        mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));        mainPanel.add(miscPropPanel);        mainPanel.add(tilebmpPanel);        mainPanel.add(Box.createRigidArea(new Dimension(0, 5)));        mainPanel.add(Box.createGlue());        mainPanel.add(buttons);        getContentPane().add(mainPanel);        getRootPane().setDefaultButton(okButton);        setUseTileBitmap(tilebmpCheck.isSelected());        // Attach the behaviour        okButton.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent actionEvent) {                createSetAndDispose();            }        });        previewButton.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent actionEvent) {                System.out.println("TilesetPreviewDialog");            }        });        cancelButton.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent actionEvent) {                dispose();            }        });        browseButton.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent actionEvent) {                JFileChooser ch = new JFileChooser(path);                int ret = ch.showOpenDialog(NewTilesetDialog.this);                if (ret == JFileChooser.APPROVE_OPTION) {                    path = ch.getSelectedFile().getAbsolutePath();                    tilebmpFile.setText(path);                }            }        });        colorButton.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent actionEvent) {                chooseColorFromImage();            }        });        propsButton.addActionListener(new ActionListener() {        	public void actionPerformed(ActionEvent actionEvent) {        		PropertiesDialog lpd =                    new PropertiesDialog(null, defaultSetProperties);        		lpd.setTitle(PROPERTIES_TITLE);        		lpd.getProps();            }        });    }