/** * Create the left panel, containing the movie name list and the performance date list. * * @return The left panel. */ public JComponent createLeftPanel() { nameListModel = new DefaultListModel(); nameList = new JList(nameListModel); nameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); nameList.setPrototypeCellValue("123456789012"); nameList.addListSelectionListener(new NameSelectionListener()); JScrollPane p1 = new JScrollPane(nameList); dateListModel = new DefaultListModel(); dateList = new JList(dateListModel); dateList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dateList.setPrototypeCellValue("123456789012"); dateList.addListSelectionListener(new DateSelectionListener()); JScrollPane p2 = new JScrollPane(dateList); JPanel p = new JPanel(); p.setLayout(new GridLayout(1, 2)); p.add(p1); p.add(p2); return p; }
private JPanel createPanel() { JPanel A = new JPanel() { private static final long serialVersionUID = -6042644671679973897L; public Insets getInsets() { return new Insets(10, 10, 10, 10); } }; A.setLayout(new BorderLayout()); JLabel l = new JLabel(symbolicName); A.add(l, BorderLayout.NORTH); final JList logList = new JList(log); logList.setPrototypeCellValue("9999 99999999 999999"); MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { ISOMsg m = (ISOMsg) logList.getSelectedValue(); if (m != null) { JFrame f = new JFrame(m.toString()); ISOMsgPanel p = new ISOMsgPanel(m); f.getContentPane().add(p); f.pack(); f.show(); } } }; logList.addMouseListener(mouseListener); JScrollPane scrollPane = new JScrollPane(logList); scrollPane.setPreferredSize(new Dimension(170, 200)); A.add(scrollPane, BorderLayout.SOUTH); return A; }
public LongListFrame() { wordList = new JList<String>(new WordListModel(3)); wordList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); wordList.setPrototypeCellValue("www"); JScrollPane scrollPane = new JScrollPane(wordList); JPanel p = new JPanel(); p.add(scrollPane); wordList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { setSubject(wordList.getSelectedValue()); } }); Container contentPane = getContentPane(); contentPane.add(p, BorderLayout.NORTH); label = new JLabel(prefix + suffix); contentPane.add(label, BorderLayout.CENTER); setSubject("fox"); pack(); }
// ----------------------------------------- public JawtList(int rows) { listContents = new JListData(); listWindow = new JList(listContents); listWindow.setPrototypeCellValue("Abcdefg Hijkmnop"); getViewport().add(listWindow); }
private void initLayout() { fieldNameField.setEnabled(false); fieldList.setVisibleRowCount(4); wordList.setVisibleRowCount(10); final String VAL = "Uren luren himmelturen, ja Besseggen."; fieldList.setPrototypeCellValue(VAL); wordList.setPrototypeCellValue(VAL); fieldPan.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), Globals.lang("Field name"))); wordPan.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), Globals.lang("Keyword"))); fieldPan.setLayout(gbl); wordPan.setLayout(gbl); con.insets = new Insets(2, 2, 2, 2); con.fill = GridBagConstraints.BOTH; con.gridwidth = 2; con.weightx = 1; con.weighty = 1; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fPane, con); fieldPan.add(fPane); gbl.setConstraints(wPane, con); wordPan.add(wPane); con.gridwidth = 1; con.gridx = 2; // con.weightx = 0.7; con.gridheight = 2; gbl.setConstraints(fieldNamePan, con); fieldPan.add(fieldNamePan); gbl.setConstraints(wordEditPan, con); wordPan.add(wordEditPan); con.gridx = 0; con.gridy = 1; con.weightx = 0; con.weighty = 0; con.gridwidth = 1; con.gridheight = 1; con.fill = GridBagConstraints.NONE; con.anchor = GridBagConstraints.WEST; gbl.setConstraints(newField, con); fieldPan.add(newField); gbl.setConstraints(newWord, con); wordPan.add(newWord); con.gridx = 1; // con.anchor = GridBagConstraints.EAST; gbl.setConstraints(removeField, con); fieldPan.add(removeField); gbl.setConstraints(removeWord, con); wordPan.add(removeWord); con.anchor = GridBagConstraints.WEST; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fieldNameField, con); fieldNamePan.add(fieldNameField); gbl.setConstraints(wordEditField, con); wordEditPan.add(wordEditField); // Add buttons: ButtonBarBuilder bsb = new ButtonBarBuilder(buttonPan); bsb.addGlue(); bsb.addButton(ok); bsb.addButton(apply); bsb.addButton(cancel); bsb.addRelatedGap(); bsb.addButton(help); bsb.addGlue(); // Add panels to dialog: con.fill = GridBagConstraints.BOTH; getContentPane().setLayout(gbl); con.weightx = 1; con.weighty = 0.5; con.gridwidth = 1; con.gridheight = 1; con.gridx = 0; con.gridy = 0; gbl.setConstraints(fieldPan, con); getContentPane().add(fieldPan); con.gridy = 1; gbl.setConstraints(wordPan, con); getContentPane().add(wordPan); con.weighty = 0; con.gridy = 2; con.insets = new Insets(12, 2, 2, 2); gbl.setConstraints(buttonPan, con); getContentPane().add(buttonPan); }