I'm having problems trying to add a JButton to a JTextPane with a String. So what I am trying to do is to add each String in a for loop and then add ad JButton after that added String. The code below is what I am trying to accomplish.
ArrayLst<String> data = new ArrayList();
data.add("Data here");
data.add("Data here 2");
data.add("Data here 3");
data.add("Data here 4");
Container cp = getContentPane();
JTextPane pane = new JTextPane();
SimpleAttributeSet set = new SimpleAttributeSet();
StyleConstants.setBold(set, true);
pane.setBackground(Color.BLUE);
pane.setEditable(false);
Document doc = pane.getStyledDocument();
for(int i=0; i<data.size(); i++)
{
doc.insertString(doc.getLength(), data.get(i)+ "\n", set);
pane.insertComponent(new JButton("View Info"));
}
Can anyone tell me how I can add a JButton to each of the Strings on the same line?
Thanks very much appreciated