Hi guys,
I'm stuck on a problem which I can't magae to get around.
Basically, my program demonstrates a working stack, where I have managed to show the stack grow everytime the user clicks push. BUT, I want the value they insert into the textfield to come inside the stack layer, which I use as a jpg file. The following code is what I have so far that makes the stack add only the layers, but not the content inside them. How could I solve this problem?
Much appreciated,
(NOTE: button1 is defined before, I'm only showing the action part of it here)
if(!stack.isFull() && e.getSource() == button1)
{
String textFieldString = text.getText();
//String textFieldString = text.getText();
stack.push(textFieldString);
message.append("You have just entered "+textFieldString+" into the Stack\n");
if (stack.size() >= 0 ) // keeps drawing to the limit of 10 (set in MainStack)
{
JLabel pic1 = new JLabel();
pic1.setIcon(new ImageIcon(getClass().getResource("p1.jpg")));
//pic1.drawString(""+textFieldString);
Insets insets = displayPanel.getInsets();
Dimension size = pic1.getPreferredSize();
pic1.setBounds(90 + insets.left, stackLayer + insets.top,
size.width, size.height);
displayPanel.setLayout(null);
displayPanel.add(pic1);
displayPanel.revalidate();
stackLayer = stackLayer - 30;
}
}