Re: once again, another dumb noob question
Justin wrote:
ok, well, regardless of what layout manager I use (I will be in control
of the hardware that the program is run on) why does the JList not
show up? I've been playing with this for 5-6 hours and cannot get it
to show.
Took me ten minutes to make it show up
using a BorderLayout - most of that time
was spent turning it into an SSCCE and
deciding what to leave the same.
<sscce>
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.*;
public class ORNote extends JPanel{
protected JList assistantsList;
protected DefaultListModel assistantsDLM;
protected JScrollPane assistantsScroller;
protected String sSN;
protected int dxID, prID;
protected int WIDTH = 381;
public ORNote(String stringSSN, int intDxID, int intPrID) {
sSN = stringSSN;
prID = intPrID;
dxID = intDxID;
// layout!
setLayout(new BorderLayout());
Border blackline = BorderFactory.createLineBorder(Color.black);
setBorder(blackline);
addWidgets();
}
protected void addWidgets(){
assistantsDLM = new DefaultListModel();
assistantsDLM.addElement("Testing");
for (int ii=0; ii<20; ii++) {
assistantsDLM.addElement(sSN + ": " + (ii+1));
}
assistantsList = new JList(assistantsDLM);
assistantsScroller = new JScrollPane(assistantsList);
add(assistantsScroller, BorderLayout.CENTER);
}
public static void main(String[] args) {
JFrame f = new JFrame("Layout");
f.add( new ORNote("Hi!",1,2) );
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
}
}
</sscce>
...And I have tried layout managers, and they dont have an
affect.
I think now comes the part where you complain..
'but this is not how I want it set out!'
Andrew T.