I used JFormDesigner to create a GUI, and now I need to find out how I can export it so that it's a use-able program with just one click. Here's the code (not sure if you'll need it):
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
* Created by JFormDesigner on Wed Jun 15 20:34:16 EDT 2011
*/
/**
* @author RS 2007
*/
public class NPCSpawn extends JFrame {
public NPCSpawn() {
initComponents();
}
private void button1ActionPerformed(ActionEvent e) { //Generate
String tf1 = textField1.getText();
String tf2 = textField2.getText();
String tf3 = textField3.getText();
String tf4 = textField4.getText();
String tf5 = textField5.getText();
String tf6 = textField6.getText();
String tf7 = textField7.getText();
String tf8 = textField8.getText();
String tf9 = textField9.getText();
String tf10 = textField10.getText();
String tf11 = textField11.getText();
String tf12 = textField12.getText();
textArea1.setText("<npcSpawn>" + " <!--" + tf2 + "-->" + "\n\t<npcId>" + tf1 + "</npcId>" + "\n\t<walkingType>" + tf3 + "</walkingType>" + "\n\t<spawnLocation>" + "\n\t\t<x>" + tf4 + "</x>" + "\n\t\t<y>" + tf5 + "</y>" + "\n\t\t<z>" + tf6 + "</z>" + "\n\t</spawnLocation>" + "\n\t<minLocation>" + "\n\t\t<x>" + tf7 + "</x>" + "\n\t\t<y>" + tf8 + "</y>" + "\n\t\t<z>" + tf9 + "</z>\n\t</minLocation>" + "\n\t<maxLocation>" + "\n\t\t<x>" + tf10 + "</x>" + "\n\t\t<y>" + tf11 + "</y>" + "\n\t\t<z>" + tf12 + "</z>" + "\n\t</maxLocation>" + "\n</npcSpawn>");
}
private void button2ActionPerformed(ActionEvent e) { //Reset
textField1.setText("");
textField2.setText("");
textField3.setText("");
textField4.setText("");
textField5.setText("");
textField6.setText("");
textField7.setText("");
textField8.setText("");
textField9.setText("");
textField10.setText("");
textField11.setText("");
textField12.setText("");
}
private void button3ActionPerformed(ActionEvent e) { //Add to XML
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license - RS 2007
menuBar1 = new JMenuBar();
menu2 = new JMenu();
menuItem1 = new JMenuItem();
scrollPane1 = new JScrollPane();
textArea1 = new JTextArea();
textField4 = new JTextField();
label1 = new JLabel();
textField1 = new JTextField();
textField7 = new JTextField();
textField8 = new JTextField();
textField12 = new JTextField();
textField9 = new JTextField();
textField5 = new JTextField();
textField6 = new JTextField();
textField10 = new JTextField();
textField11 = new JTextField();
textField2 = new JTextField();
label2 = new JLabel();
label3 = new JLabel();
textField3 = new JTextField();
label4 = new JLabel();
label5 = new JLabel();
label6 = new JLabel();
label7 = new JLabel();
label8 = new JLabel();
label9 = new JLabel();
label10 = new JLabel();
label11 = new JLabel();
label12 = new JLabel();
label13 = new JLabel();
button1 = new JButton();
button2 = new JButton();
button3 = new JButton();
//======== this ========
setTitle("GUI");
Container contentPane = getContentPane();
contentPane.setLayout(null);
//======== menuBar1 ========
{
//======== menu2 ========
{
menu2.setText("Editors");
//---- menuItem1 ----
menuItem1.setText("NPCSpawner");
menuItem1.setIcon(new ImageIcon("C:\\Users\\Patrick\\Desktop\\JFormDesigner\\monster.png"));
menu2.add(menuItem1);
}
menuBar1.add(menu2);
}
setJMenuBar(menuBar1);
//======== scrollPane1 ========
{
//---- textArea1 ----
textArea1.setToolTipText("The output of the code");
textArea1.setEditable(false);
scrollPane1.setViewportView(textArea1);
}
contentPane.add(scrollPane1);
scrollPane1.setBounds(10, 140, 560, 225);
//---- textField4 ----
textField4.setToolTipText("The X coordinate of the NPC's spawn");
contentPane.add(textField4);
textField4.setBounds(295, 25, 80, 20);
//---- label1 ----
label1.setText("Output");
contentPane.add(label1);
label1.setBounds(10, 120, 65, 20);
//---- textField1 ----
textField1.setToolTipText("ID of the NPC");
contentPane.add(textField1);
textField1.setBounds(10, 25, 80, 20);
//---- textField7 ----
textField7.setToolTipText("The minimum X coordinate of the NPC's spawn");
contentPane.add(textField7);
textField7.setBounds(10, 70, 80, 20);
//---- textField8 ----
textField8.setToolTipText("The minimum Y coordinate of the NPC's spawn");
contentPane.add(textField8);
textField8.setBounds(105, 70, 80, 20);
//---- textField12 ----
textField12.setToolTipText("The maximum Z coordinate of the NPC's spawn");
contentPane.add(textField12);
textField12.setBounds(485, 70, 80, 20);
//---- textField9 ----
textField9.setToolTipText("The minimum Z coordinate of the NPC's spawn");
contentPane.add(textField9);
textField9.setBounds(200, 70, 80, 20);
//---- textField5 ----
textField5.setToolTipText("The Y coordinate of the NPC's spawn");
contentPane.add(textField5);
textField5.setBounds(390, 25, 80, 20);
//---- textField6 ----
textField6.setToolTipText("The Z coordinate of the NPC's spawn");
contentPane.add(textField6);
textField6.setBounds(485, 25, 80, 20);
//---- textField10 ----
textField10.setToolTipText("The maximum X coordinate of the NPC's spawn");
contentPane.add(textField10);
textField10.setBounds(295, 70, 80, 20);
//---- textField11 ----
textField11.setToolTipText("The maximum Y coordinate of the NPC's spawn");
contentPane.add(textField11);
textField11.setBounds(390, 70, 80, 20);
//---- textField2 ----
textField2.setToolTipText("Name of the NPC");
contentPane.add(textField2);
textField2.setBounds(105, 25, 80, 20);
//---- label2 ----
label2.setText("ID");
contentPane.add(label2);
label2.setBounds(45, 10, 15, 15);
//---- label3 ----
label3.setText("Name");
contentPane.add(label3);
label3.setBounds(new Rectangle(new Point(130, 10), label3.getPreferredSize()));
//---- textField3 ----
textField3.setToolTipText("The WalkingType of the NPC");
contentPane.add(textField3);
textField3.setBounds(200, 25, 80, 20);
//---- label4 ----
label4.setText("WalkingType");
contentPane.add(label4);
label4.setBounds(new Rectangle(new Point(210, 10), label4.getPreferredSize()));
//---- label5 ----
label5.setText("SpawnX");
contentPane.add(label5);
label5.setBounds(new Rectangle(new Point(315, 10), label5.getPreferredSize()));
//---- label6 ----
label6.setText("SpawnY");
contentPane.add(label6);
label6.setBounds(new Rectangle(new Point(410, 10), label6.getPreferredSize()));
//---- label7 ----
label7.setText("SpawnZ");
contentPane.add(label7);
label7.setBounds(new Rectangle(new Point(505, 10), label7.getPreferredSize()));
//---- label8 ----
label8.setText("MinX");
contentPane.add(label8);
label8.setBounds(40, 55, label8.getPreferredSize().width, 15);
//---- label9 ----
label9.setText("MinY");
contentPane.add(label9);
label9.setBounds(new Rectangle(new Point(135, 55), label9.getPreferredSize()));
//---- label10 ----
label10.setText("MinZ");
contentPane.add(label10);
label10.setBounds(230, 55, label10.getPreferredSize().width, 14);
//---- label11 ----
label11.setText("MaxX");
contentPane.add(label11);
label11.setBounds(new Rectangle(new Point(320, 55), label11.getPreferredSize()));
//---- label12 ----
label12.setText("MaxY");
contentPane.add(label12);
label12.setBounds(new Rectangle(new Point(415, 55), label12.getPreferredSize()));
//---- label13 ----
label13.setText("MaxZ");
contentPane.add(label13);
label13.setBounds(new Rectangle(new Point(510, 55), label13.getPreferredSize()));
//---- button1 ----
button1.setText("Generate");
button1.setToolTipText("Generate the code");
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
button1ActionPerformed(e);
}
});
contentPane.add(button1);
button1.setBounds(150, 100, 90, 25);
//---- button2 ----
button2.setText("Reset");
button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
button2ActionPerformed(e);
}
});
contentPane.add(button2);
button2.setBounds(245, 100, 90, 25);
//---- button3 ----
button3.setText("Add to XML");
button3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
button3ActionPerformed(e);
}
});
contentPane.add(button3);
button3.setBounds(340, 100, 90, 25);
{ // compute preferred size
Dimension preferredSize = new Dimension();
for(int i = 0; i < contentPane.getComponentCount(); i++) {
Rectangle bounds = contentPane.getComponent(i).getBounds();
preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
}
Insets insets = contentPane.getInsets();
preferredSize.width += insets.right;
preferredSize.height += insets.bottom;
contentPane.setMinimumSize(preferredSize);
contentPane.setPreferredSize(preferredSize);
}
pack();
setLocationRelativeTo(getOwner());
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// Generated using JFormDesigner Evaluation license - RS 2007
private JMenuBar menuBar1;
private JMenu menu2;
private JMenuItem menuItem1;
private JScrollPane scrollPane1;
private JTextArea textArea1;
private JTextField textField4;
private JLabel label1;
private JTextField textField1;
private JTextField textField7;
private JTextField textField8;
private JTextField textField12;
private JTextField textField9;
private JTextField textField5;
private JTextField textField6;
private JTextField textField10;
private JTextField textField11;
private JTextField textField2;
private JLabel label2;
private JLabel label3;
private JTextField textField3;
private JLabel label4;
private JLabel label5;
private JLabel label6;
private JLabel label7;
private JLabel label8;
private JLabel label9;
private JLabel label10;
private JLabel label11;
private JLabel label12;
private JLabel label13;
private JButton button1;
private JButton button2;
private JButton button3;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
Cross-post: http://www.java-forums.org/new-java/45424-turn-jformdesigner-gui-into-use-able-program.html#post215959