Details
I have a JScrollPane. Inside it I have a JList. Each element of JList is a JPanel.
Inside JPanel I have JLabel and JTextField.
The problem is JTextField is not editable.
I want to be able focus and write text in this jtextfields.
Sample of code:
// -------------------
package testapp;
import java.awt.*;
import javax.swing.*;
public class NewJFrame extends [login to view URL] {
public NewJFrame() {
DefaultListModel<JPanel> _listModel = new DefaultListModel<>();
JList<JPanel> _listbox = new JList<>(_listModel);
[login to view URL](new MessageRenderer());
JScrollPane _historyScrollPane = new JScrollPane(_listbox);
JPanel p = new JPanel();
[login to view URL](new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
JTextField userField = new JTextField();
[login to view URL]([login to view URL]);
[login to view URL](true);
[login to view URL](true);
[login to view URL](true);
[login to view URL] = new [login to view URL](2,0,2,5); // (top, left, bottom, right)
[login to view URL] = [login to view URL];
[login to view URL] = 1;
[login to view URL] = 1;
[login to view URL] = 0;
[login to view URL] = 1;
[login to view URL] = [login to view URL];
[login to view URL](userField, c);
[login to view URL](p);
[login to view URL] layout = new [login to view URL](getContentPane());
getContentPane().setLayout(layout);
[login to view URL](
[login to view URL]([login to view URL])
.addGroup([login to view URL], [login to view URL]()
.addComponent(_historyScrollPane, 261, 261, 261))
);
[login to view URL](
[login to view URL]([login to view URL])
.addGroup([login to view URL]()
.addComponent(_historyScrollPane, 238, 238, 238))
);
pack();
}
public static void main(String args[]) {
[login to view URL](new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
}
// -----------------------
package testapp;
import [login to view URL];
import [login to view URL];
import [login to view URL];
public class MessageRenderer implements ListCellRenderer<Object>{
public Component getListCellRendererComponent(JList<?> list, Object value,int index, boolean isSelected, boolean cellHasFocus) {
return (Component)value;
}
}
Hello
My name is Ahmed, i'm a top rated freelancer.
i worked over 250 projects and over 1000 hours doing java projects.
plus i passed freelancer java exam with top 15%
plus i got 2 java certificate 1Z0-803 and 1Z0-804 with 3+ years experience.
small overview of feedback on my profile
"you want to get your projects completed with quality? Hire Ahmed. Highly recommended."
"Thoroughly satisfied with Ahmed, and would recommend him to anyone looking for an excellent java developer!"
"Highly recommended. Very smart and well experience"
looking forward to work with you
Regards