Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamically displaying the contents  RSS feed

 
Derek Rodricks
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot for pointing it out the problem. I was able to display the components.

Thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!