Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static class test implements ListCellRenderer{
- @Override
- public Component getListCellRendererComponent(JList arg0,
- Object arg1, int arg2, boolean arg3, boolean arg4) {
- JLabel text = new JLabel(arg1.toString());
- text.setAlignmentX(Component.RIGHT_ALIGNMENT);
- return text;
- }
- }
- DefaultListModel list = new DefaultListModel();
- list.add(0,"hello");
- JList jlist = new JList(list);
- jlist.setCellRenderer(new test());
- jlist.setBackground(new Color(229,229,255));
- JScrollPane scrollingList = new JScrollPane(jlist);
- frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
- frame.getContentPane().add(scrollingList);
- addComponentsToPane(frame.getContentPane());
Add Comment
Please, Sign In to add comment