0

i am building a program that will create XML for me using a format, however there is 3 differnt types of XML i will be creating and each of these will have 4 templates.

So basically you choose TYPE2 and STYLE 3 in 2 combobox's on the first screen, i then want the Next button to direct you to the next process dependant on the type and style...

I am completely new to SWING programming alot of work remains but i want to get the navigation done before i begin work on the coding on how it creates the information..

current button is just as it comes like so...

JButton btnNext = new JButton("Next");
btnNext.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {                
        }
});
btnNext.setBounds(144, 302, 89, 23);
frame.getContentPane().add(btnNext);

I am just wondering how i even begin to do this, the combo box is as follows

JStyleBox StyleBox = new JStyleBox();
StyleBox.setMaximumRowCount(3);
StyleBox.setModel(new DefaultStyleBoxModel(new String[] {"Transforms", "RTP", "Rules Engine"}));
StyleBox.setBounds(47, 73, 147, 20);
frame.getContentPane().add(StyleBox);

others are TypeBox, BrokBox and AggBox Any help or guidance would be greatly appreciated

  • 1
    Use `CardLayout`: [how to change UI depending on combo box selection](http://stackoverflow.com/questions/6432170/how-to-change-ui-depending-on-combo-box-selection) – trashgod Apr 03 '13 at 15:19
  • +1 for suggesting the CardLayout. -1 for not linking to the Swing tutorial on [How to Use Card Layout](http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html), which has an example that does this. Plus the poster might even take the time to look at other sections of the tutorial for future reference. – camickr Apr 03 '13 at 15:41
  • Don't use setBounds() to position and size components. Use a [Layout Manager](http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html). Also, use standard Java naming conventions. Variable names should NOT start with an upper case character. – camickr Apr 03 '13 at 15:44
  • This doesnt explain (atleast not to me) how this would take the data through to a Second form etc. Maybe i wasn't too clear in my question, I want it so you hit next and depending what value are in the combobox's a form is opened that is populated dependant on those values (will also start to build some XML in the background for the end) – Jonathan Spickernell Apr 04 '13 at 11:40

1 Answers1

0

Here is a simple example that I wrote for you: http://pastebin.com/ZgUsMMfS

It creates a Frame, and you can choose what kind of new component to create in the combobox, then when you press the button, it will create a new component - a JLabel, JButton or JFrame. This is a super-simple example, but it should give you enough to get you going.

Kylar
  • 8,876
  • 8
  • 41
  • 75
  • 1
    Why not post the code here? See also [*Initial Threads*](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html). – trashgod Apr 03 '13 at 15:15
  • It was big, and the code window in comments is small. Pastebin makes it easier to look at, understand and copy. – Kylar Apr 03 '13 at 15:20
  • If it is a "super-simple example" then the code shouldn't be too big. We post SSCCE's here all the time. – camickr Apr 03 '13 at 15:33
  • Super simple doesn't imply small. Whenever it goes over ~50 lines, I choose to put it in a pastebin. Yes, I'm aware that means that it could go away. Yes, I know it partially defeats the purpose. SO needs a better code-viewing widget. – Kylar Apr 03 '13 at 15:35
  • I will check this out later, cant open the link where i am here – Jonathan Spickernell Apr 04 '13 at 11:39