× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Aaron,

If all you want is a simple dynamic UI there's no need to overcomplicate things... below is a self-contained, executable Swing example of arbitrarily placing some components on a form. Of course some people might say that anything Swing is overcomplicated, but I'm a fan so what the heck. This example may not demonstrate best practices in Swing, but if it's results you're after then this may be right up your alley. (Please disregard the JFormDesigner stuff... that's just me cheating.)

t.

- - -

import java.awt.*;
import javax.swing.*;

public class NullLayoutDemo extends JPanel
{

public NullLayoutDemo()
{
initComponents();
}

private void initComponents()
{
// JFormDesigner - Component initialization - DO NOT MODIFY // GEN-BEGIN:initComponents
label2 = new JLabel();
label3 = new JLabel();
textField1 = new JTextField();
comboBox1 = new JComboBox();
button1 = new JButton();

//======== this ========
setLayout(null);

//---- label2 ----
label2.setText("Field 1");
add(label2);
label2.setBounds(new Rectangle(new Point(15, 20), label2.getPreferredSize()));

//---- label3 ----
label3.setText("Field 2");
add(label3);
label3.setBounds(new Rectangle(new Point(15, 55), label3.getPreferredSize()));
add(textField1);
textField1.setBounds(70, 14, 140, textField1.getPreferredSize().height);
add(comboBox1);
comboBox1.setBounds(70, 50, 140, comboBox1.getPreferredSize().height);

//---- button1 ----
button1.setText("Submit");
add(button1);
button1.setBounds(new Rectangle(new Point(126, 85), button1.getPreferredSize()));

setPreferredSize(new Dimension(225, 125));
// JFormDesigner - End of component initialization //GEN- END:initComponents
}

// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN- BEGIN:variables
private JLabel label2;
private JLabel label3;
private JTextField textField1;
private JComboBox comboBox1;
private JButton button1;
// JFormDesigner - End of variables declaration //GEN-END:variables

public static void main(String[] args)
{
JFrame frame = new JFrame("Null Layout Demo");
frame.setContentPane(new NullLayoutDemo());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}

}


On 20-Feb-2008, at 6:45 PM, Thorbjørn Ravn Andersen wrote:

Aaron Bartell skrev den 20-02-2008 22:38:
Could you elaborate on what you mean by "drawing the screen dynamically"?


I get an XML feed from the server and it will have something like the
following:

<form id="form1">
<button id="btnSubmit" x="12" y="100" value="Submit" />
</form>

Based on that I know I need to display a form with a single button on the
screen which I do by parsing the XML and incrementally "drawing it" by
instantiating AWT objects and adding them to a panel/frame.

The snippet looks very close to something HTML'ish, so perhaps you could
use an XSLT-stylesheet to create HTML you could use in a web page? The
logic for that is very simple.

It all depends on how much functionality and speed you need.

--
Thorbjørn


--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.