textPane = new JTextPane();
		textPane.setBounds(337, 33, 290, 198);
		textPane.setLayout(new GridLayout());
		JScrollPane scrollPane = new JScrollPane(textPane);
		scrollPane.setBounds(337, 33, 290, 198);
searchButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				List<MainManagement> sList = new ArrayList<MainManagement>();
				MainMngDao mmd = new MainMngDao();
				sList = mmd.search();
				for(int i = 0; i < sList.size(); i++) {

this is just part of the codes
i used textpane and it can show everything in the list.why?
please give me a pointer
no matter what way i do it , iterator or for() loop, i can acheive it...

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags


for(int i = 0; i < sList.size(); i++) {

Any previously added text is overwritten by new setText() in your loop.
Simplest workaround put whole list in StringBuilder and get one string that is added to JTextPane.
Advanced, create StyledDocument

PS: This is not 24/7 answer service just for you. We answer when we can and when we have time, not when you demand.

Edited 5 Years Ago by peter_budo: n/a


textPane.setText(textPane.getText() + "\LineSepartor" + sList.get(i).toString());

That is functional, but it is much of get & set for graphical component. I would prefer to provide text pane in this case with single set


now is corresponding with topic

scrollPane.setVerticalScrollBarPolicy(               JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
This article has been dead for over six months. Start a new discussion instead.