aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Dynamically displaying the contents Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Dynamically displaying the contents " Watch "Dynamically displaying the contents " New topic
Author

Dynamically displaying the contents

Derek Rodricks
Greenhorn

Joined: Jun 21, 2011
Posts: 2
I have the following frame that is dynamically loaded when the program is run. But none of the components get loaded when I run the program.

FrontEnd.java
-------------
ublic class FrontEnd extends JFrame implements PropertyChangeListener{
/ * Create the frame
*/
public FrontEnd(String title, ArrayList<Parameter> readwriteList, ArrayList<Parameter> disPlayList)
{
super(title);

_displayList = disPlayList;
_readwriteList = readwriteList;

//Specify an action for the close button
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);

//Set the location of the frame
setLocationRelativeTo(null);
setBounds(100, 100, 953, 496);

// Build the menu bar
buildMenuBar();
contentPane.add(display());
pack();
setVisible(true);
}



private JPanel display()
{
//based on the displayList.size - set the widgets and their values.

Parameter pli;
num_parameters = _displayList.size();
parameterArea = new JPanel(new GridLayout(num_parameters, 1));

ListIterator<Parameter> listDisplay = _displayList.listIterator();
Object obj = null;
JPanel dP = new JPanel(new FlowLayout(FlowLayout.LEFT));

while (listDisplay.hasNext())
{
obj = listDisplay.next();

if (obj instanceof DParm)
{
((DParm) obj).displayParm(dP);
}

dP.setVisible(true);
parameterArea.add(dP);
parameterArea.setVisible(true);

}

pack();

return parameterArea;
}

DParm.java
---------------
@Override
public void displayParm(JPanel widget) {
// TODO Auto-generated method stub
widget = new JPanel(new FlowLayout(FlowLayout.LEFT));
JLabel newLabel = new JLabel();
DecimalFormat df = new DecimalFormat("0.00");
JFormattedTextField newTextArea = new JFormattedTextField(df);
newTextArea.addPropertyChangeListener("value", this);
newTextArea.setColumns(10);
widget.add(newLabel, "left");
widget.add(newTextArea, "right");
widget.setVisible(true);

}

I am unable to figure out why the components are NOT being displayed.
Would appreciate any input.
Thanks.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 1788
    
    2
When you post code don't forget to use the "Code" tags to the posted code is formatted and readable.

I see where you create "parameterArea" but I don't see where you add the component to the GUI.

If you need more help then post your SSCCE that demonstrates the problem.
Derek Rodricks
Greenhorn

Joined: Jun 21, 2011
Posts: 2
Thanks alot for pointing it out the problem. I was able to display the components.

Thanks again.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Dynamically displaying the contents
 
Similar Threads
Input Display
JPanels with different content should have the same size
push flowlayout panel to the left.
writing to text files
fixed element in gridbaglayout