List of usage examples for javax.swing ListSelectionModel SINGLE_SELECTION
int SINGLE_SELECTION
To view the source code for javax.swing ListSelectionModel SINGLE_SELECTION.
Click Source Link
From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java
JPanel createMoviehitsList() { /* Movies List panel...*/ JPanel panelMoviesList = new JPanel(); panelMoviesList.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$ BorderFactory.createEmptyBorder(5, 5, 5, 5))); listMovies = new JList() { public String getToolTipText(MouseEvent e) { if (getCellBounds(0, 0) == null) return null; String retVal = null; int row = (int) e.getPoint().getY() / (int) getCellBounds(0, 0).getHeight(); if (row >= 0 && row < getModel().getSize() && getMoviesList().getModel().getElementAt(row) instanceof ModelIMDbSearchHit) { retVal = ((ModelIMDbSearchHit) getMoviesList().getModel().getElementAt(row)).getAka(); if (retVal != null && retVal.trim().equals("")) //$NON-NLS-1$ retVal = null;/* w w w .ja v a 2 s . co m*/ } return retVal; } public JToolTip createToolTip() { JMultiLineToolTip tooltip = new JMultiLineToolTip(); tooltip.setComponent(this); return tooltip; } }; // Unfortunately setting tooltip timeout affects ALL tooltips ToolTipManager ttm = ToolTipManager.sharedInstance(); ttm.registerComponent(listMovies); ttm.setInitialDelay(0); ttm.setReshowDelay(0); listMovies.setFixedCellHeight(18); listMovies.setFont(new Font(listMovies.getFont().getName(), Font.PLAIN, listMovies.getFont().getSize())); listMovies.setLayoutOrientation(JList.VERTICAL); listMovies.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listMovies.setCellRenderer(new MovieHitListCellRenderer()); listMovies.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { // Open we page if (SwingUtilities.isRightMouseButton(event)) { int index = listMovies.locationToIndex(event.getPoint()); if (index >= 0) { ModelIMDbSearchHit hit = (ModelIMDbSearchHit) listMovies.getModel().getElementAt(index); if (hit.getUrlID() != null && !hit.getUrlID().equals("")) { BrowserOpener opener = new BrowserOpener(hit.getCompleteUrl()); opener.executeOpenBrowser(MovieManager.getConfig().getSystemWebBrowser(), MovieManager.getConfig().getBrowserPath()); } } } else if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() >= 2) { buttonSelect.doClick(); } } }); KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true); ActionListener listKeyBoardActionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { log.debug("ActionPerformed: " + "Movielist - ENTER pressed."); //$NON-NLS-1$ buttonSelect.doClick(); } }; listMovies.registerKeyboardAction(listKeyBoardActionListener, enterKeyStroke, JComponent.WHEN_FOCUSED); JScrollPane scrollPaneMovies = new JScrollPane(listMovies); scrollPaneMovies.setAutoscrolls(true); //scrollPaneMovies.registerKeyboardAction(listKeyBoardActionListener,enterKeyStroke, JComponent.WHEN_FOCUSED); panelMoviesList.setLayout(new BorderLayout()); panelMoviesList.add(scrollPaneMovies, BorderLayout.CENTER); return panelMoviesList; }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Hist2DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);//ww w.j ava 2 s .c o m listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:net.sf.keystore_explorer.gui.dialogs.extensions.DViewExtensions.java
private void initComponents() { ExtensionsTableModel extensionsTableModel = new ExtensionsTableModel(); jtExtensions = new JKseTable(extensionsTableModel); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(extensionsTableModel); sorter.setComparator(2, new ObjectIdComparator()); jtExtensions.setRowSorter(sorter);//from w w w. ja v a 2 s . c om jtExtensions.setShowGrid(false); jtExtensions.setRowMargin(0); jtExtensions.getColumnModel().setColumnMargin(0); jtExtensions.getTableHeader().setReorderingAllowed(false); jtExtensions.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS); jtExtensions.setRowHeight(Math.max(18, jtExtensions.getRowHeight())); for (int i = 0; i < jtExtensions.getColumnCount(); i++) { TableColumn column = jtExtensions.getColumnModel().getColumn(i); column.setHeaderRenderer( new ExtensionsTableHeadRend(jtExtensions.getTableHeader().getDefaultRenderer())); column.setCellRenderer(new ExtensionsTableCellRend()); } TableColumn criticalCol = jtExtensions.getColumnModel().getColumn(0); criticalCol.setResizable(false); criticalCol.setMinWidth(28); criticalCol.setMaxWidth(28); criticalCol.setPreferredWidth(28); ListSelectionModel selectionModel = jtExtensions.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { try { CursorUtil.setCursorBusy(DViewExtensions.this); updateExtensionValue(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } } }); jspExtensionsTable = PlatformUtil.createScrollPane(jtExtensions, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jspExtensionsTable.getViewport().setBackground(jtExtensions.getBackground()); jpExtensionsTable = new JPanel(new BorderLayout(5, 5)); jpExtensionsTable.setPreferredSize(new Dimension(500, 200)); jpExtensionsTable.add(jspExtensionsTable, BorderLayout.CENTER); jpExtensionValue = new JPanel(new BorderLayout(5, 5)); jlExtensionValue = new JLabel(res.getString("DViewExtensions.jlExtensionValue.text")); jpExtensionValue.add(jlExtensionValue, BorderLayout.NORTH); jepExtensionValue = new JEditorPane(); jepExtensionValue.setFont(new Font(Font.MONOSPACED, Font.PLAIN, LnfUtil.getDefaultFontSize())); jepExtensionValue.setEditable(false); jepExtensionValue.setToolTipText(res.getString("DViewExtensions.jtaExtensionValue.tooltip")); // JGoodies - keep uneditable color same as editable jepExtensionValue.putClientProperty("JTextArea.infoBackground", Boolean.TRUE); // for displaying URLs in extensions as clickable links jepExtensionValue.setContentType("text/html"); jepExtensionValue.addHyperlinkListener(this); // use default font and foreground color from the component jepExtensionValue.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); jspExtensionValue = PlatformUtil.createScrollPane(jepExtensionValue, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); jpExtensionValueTextArea = new JPanel(new BorderLayout(5, 5)); jpExtensionValueTextArea.setPreferredSize(new Dimension(500, 200)); jpExtensionValueTextArea.add(jspExtensionValue, BorderLayout.CENTER); jpExtensionValue.add(jpExtensionValueTextArea, BorderLayout.CENTER); jbAsn1 = new JButton(res.getString("DViewExtensions.jbAsn1.text")); PlatformUtil.setMnemonic(jbAsn1, res.getString("DViewExtensions.jbAsn1.mnemonic").charAt(0)); jbAsn1.setToolTipText(res.getString("DViewExtensions.jbAsn1.tooltip")); jbAsn1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DViewExtensions.this); asn1DumpPressed(); } finally { CursorUtil.setCursorFree(DViewExtensions.this); } } }); jpExtensionValueAsn1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); jpExtensionValueAsn1.add(jbAsn1); jpExtensionValue.add(jpExtensionValueAsn1, BorderLayout.SOUTH); jpExtensions = new JPanel(new GridLayout(2, 1, 5, 5)); jpExtensions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5)))); jpExtensions.add(jpExtensionsTable); jpExtensions.add(jpExtensionValue); jbOK = new JButton(res.getString("DViewExtensions.jbOK.text")); jbOK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okPressed(); } }); jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false); extensionsTableModel.load(extensions); if (extensionsTableModel.getRowCount() > 0) { jtExtensions.changeSelection(0, 0, false, false); } getContentPane().add(jpExtensions, BorderLayout.CENTER); getContentPane().add(jpOK, BorderLayout.SOUTH); setResizable(false); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); getRootPane().setDefaultButton(jbOK); pack(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jbOK.requestFocus(); } }); }
From source file:com.openbravo.pos.sales.JTicketLines.java
/** Creates new form JLinesTicket */ public JTicketLines(AppView app, String propertyRowHeight, String propertyFontsize, String ticketline) { this.m_App = app; initComponents();// ww w .java 2s . co m m_jTicketTable.m_App = app; m_jTicketTable.propertyRowHeight = propertyRowHeight; ColumnTicket[] acolumns = new ColumnTicket[0]; if (ticketline != null) { try { if (m_sp == null) { SAXParserFactory spf = SAXParserFactory.newInstance(); m_sp = spf.newSAXParser(); } ColumnsHandler columnshandler = new ColumnsHandler(); m_sp.parse(new InputSource(new StringReader(ticketline)), columnshandler); acolumns = columnshandler.getColumns(); } catch (ParserConfigurationException ePC) { logger.log(Level.WARNING, LocalRes.getIntString("exception.parserconfig"), ePC); } catch (SAXException eSAX) { logger.log(Level.WARNING, LocalRes.getIntString("exception.xmlfile"), eSAX); } catch (IOException eIO) { logger.log(Level.WARNING, LocalRes.getIntString("exception.iofile"), eIO); } } Map<String, Integer> widths = PropertyUtil.getTicketLineWidths(m_App); for (ColumnTicket acolumn : acolumns) { Integer width = widths.get(acolumn.name); if (width == null) { continue; } acolumn.width = width; } m_jTableModel = new TicketTableModel(acolumns); m_jTicketTable.setModel(m_jTableModel); m_jTicketTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); TableColumnModel jColumns = m_jTicketTable.getColumnModel(); for (int i = 0; i < acolumns.length; i++) { jColumns.getColumn(i).setPreferredWidth(acolumns[i].width); jColumns.getColumn(i).setResizable(true); } PropertyUtil.ScaleScrollbar(m_App, m_jScrollTableTicket); m_jTicketTable.getTableHeader().setReorderingAllowed(false); // m_jTicketTable.setDefaultRenderer(Object.class, new // TicketCellRenderer(app, acolumns, propertyFontsize)); m_jTicketTable.setDefaultRenderer(Object.class, new RowHeightCellRenderer(app, acolumns, propertyFontsize, propertyRowHeight)); PropertyUtil.ScaleTableColumnFontsize(m_App, m_jTicketTable, "sales-tablecolumn-fontsize", "14"); m_jTicketTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m_jTicketTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); int row = table.rowAtPoint(p); if (me.getClickCount() == 2) { // your valueChanged overridden method listDoubleClickListener.valueChanged(new ListSelectionEvent(m_jTicketTable, row, row, false)); } } }); // reseteo la tabla... m_jTableModel.clear(); }
From source file:com.funambol.email.admin.user.ResultSearchUserPanel.java
/** * Set up graphic elements for this panel. * * @throws Exception if error occures during creation of the panel *//* ww w . ja v a 2 s . c om*/ private void init() throws Exception { // create objects to display this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); // create a model for the user table and pass it to the JTable object model = new UserTableModel(); table = new JTable(model); table.setShowGrid(true); table.setAutoscrolls(true); table.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); JScrollPane scrollpane = new JScrollPane(table); table.setPreferredScrollableViewportSize(new Dimension(800, 200)); table.setFont(GuiFactory.defaultTableFont); table.getTableHeader().setFont(GuiFactory.defaultTableHeaderFont); this.add(scrollpane, BorderLayout.CENTER); // // Select user. // table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ListSelectionModel rowSM = table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting()) { return; } ListSelectionModel lsm = (ListSelectionModel) event.getSource(); if (lsm.isSelectionEmpty()) { selectedUser = null; } else { int selectedRow = lsm.getMinSelectionIndex(); selectedUser = users[selectedRow]; } } }); rowSM.clearSelection(); table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { if (event.getClickCount() < 2) { return; } // // If the selected user is already associated to an account // then insertion process can't go on. // String userName = selectedUser.getUsername(); String value[] = new String[] { userName }; WhereClause wc = new WhereClause("username", value, WhereClause.OPT_EQ, true); MailServerAccount[] tmp = null; try { tmp = WSDao.getAccounts(wc); } catch (Exception e) { } if (tmp.length > 0) { StringBuilder sb = new StringBuilder("The user "); sb.append(userName).append(" is already associated to an account"); Object[] options = { "OK" }; JOptionPane.showOptionDialog(null, sb.toString(), "Warning", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); } else { // // Go to next step. // step.goToNextStep(); } } }); }
From source file:com.floreantpos.customer.DefaultCustomerListView.java
public void initUI() { setLayout(new MigLayout("fill", "[grow]", "[grow][grow][grow]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ JPanel searchPanel = new JPanel(new MigLayout()); JLabel lblByPhone = new JLabel(Messages.getString("CustomerSelectionDialog.1")); //$NON-NLS-1$ JLabel lblByLoyality = new JLabel(Messages.getString("CustomerSelectionDialog.16")); //$NON-NLS-1$ JLabel lblByName = new JLabel(Messages.getString("CustomerSelectionDialog.19")); //$NON-NLS-1$ tfMobile = new POSTextField(16); tfLoyaltyNo = new POSTextField(16); tfName = new POSTextField(16); tfName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearchCustomer();// w w w.j a v a 2 s.c om } }); tfLoyaltyNo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearchCustomer(); } }); tfMobile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearchCustomer(); } }); PosButton btnSearch = new PosButton(Messages.getString("CustomerSelectionDialog.15")); //$NON-NLS-1$ btnSearch.setFocusable(false); btnSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSearchCustomer(); } }); PosButton btnKeyboard = new PosButton(IconFactory.getIcon("/images/", "keyboard.png")); //$NON-NLS-1$ //$NON-NLS-2$ btnKeyboard.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { qwertyKeyPad.setCollapsed(!qwertyKeyPad.isCollapsed()); } }); searchPanel.add(lblByPhone, "growy"); //$NON-NLS-1$ searchPanel.add(tfMobile, "growy"); //$NON-NLS-1$ searchPanel.add(lblByLoyality, "growy"); //$NON-NLS-1$ searchPanel.add(tfLoyaltyNo, "growy"); //$NON-NLS-1$ searchPanel.add(lblByName, "growy"); //$NON-NLS-1$ searchPanel.add(tfName, "growy"); //$NON-NLS-1$ searchPanel.add(btnKeyboard, "growy,w " + PosUIManager.getSize(80) + "!,h " + PosUIManager.getSize(35) + "!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ searchPanel.add(btnSearch, ",growy,h " + PosUIManager.getSize(35) + "!"); //$NON-NLS-1$ //$NON-NLS-2$ add(searchPanel, "cell 0 1"); //$NON-NLS-1$ JPanel centerPanel = new JPanel(new BorderLayout()); centerPanel.setBorder(new TitledBorder(null, POSConstants.SELECT_CUSTOMER.toUpperCase(), TitledBorder.LEADING, TitledBorder.TOP, null, null)); //$NON-NLS-1$ JPanel customerListPanel = new JPanel(new BorderLayout(0, 0)); customerListPanel.setBorder(new EmptyBorder(5, 5, 0, 5)); customerTable = new CustomerTable(); customerTable.setModel(new CustomerListTableModel()); customerTable.setFocusable(false); customerTable.setRowHeight(60); customerTable.getTableHeader().setPreferredSize(new Dimension(100, 35)); customerTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); customerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { selectedCustomer = customerTable.getSelectedCustomer(); if (selectedCustomer != null) { //btnInfo.setEnabled(true); } else { btnInfo.setEnabled(false); } } }); JScrollPane scrollPane = new JScrollPane(); scrollPane.setFocusable(false); scrollPane.setViewportView(customerTable); customerListPanel.add(scrollPane, BorderLayout.CENTER); JPanel panel = new JPanel(new MigLayout("hidemode 3,al center", "sg", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ btnInfo = new PosButton(Messages.getString("CustomerSelectionDialog.23")); //$NON-NLS-1$ btnInfo.setFocusable(false); panel.add(btnInfo, "grow"); //$NON-NLS-1$ btnInfo.setEnabled(false); PosButton btnHistory = new PosButton(Messages.getString("CustomerSelectionDialog.24")); //$NON-NLS-1$ btnHistory.setEnabled(false); panel.add(btnHistory, "grow"); //$NON-NLS-1$ btnCreateNewCustomer = new PosButton(Messages.getString("CustomerSelectionDialog.25")); //$NON-NLS-1$ btnCreateNewCustomer.setFocusable(false); panel.add(btnCreateNewCustomer, "grow"); //$NON-NLS-1$ btnCreateNewCustomer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doCreateNewCustomer(); } }); btnRemoveCustomer = new PosButton(Messages.getString("CustomerSelectionDialog.26")); //$NON-NLS-1$ btnRemoveCustomer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doRemoveCustomerFromTicket(); } }); panel.add(btnRemoveCustomer, "grow"); //$NON-NLS-1$ PosButton btnSelect = new PosButton(Messages.getString("CustomerSelectionDialog.28")); //$NON-NLS-1$ btnSelect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (isCreateNewTicket()) { doCreateNewTicket(); } else { closeDialog(false); } } }); panel.add(btnSelect, "grow"); //$NON-NLS-1$ btnCancel = new PosButton(Messages.getString("CustomerSelectionDialog.29")); //$NON-NLS-1$ btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(true); } }); panel.add(btnCancel, "grow"); //$NON-NLS-1$ customerListPanel.add(panel, BorderLayout.SOUTH); centerPanel.add(customerListPanel, BorderLayout.CENTER); //$NON-NLS-1$ add(centerPanel, "cell 0 2,grow"); //$NON-NLS-1$ qwertyKeyPad = new com.floreantpos.swing.QwertyKeyPad(); qwertyKeyPad.setCollapsed(false); add(qwertyKeyPad, "cell 0 3,grow"); //$NON-NLS-1$ }
From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterListEdtDlg.java
@Override public void createUI() { super.createUI(); CellConstraints cc = new CellConstraints(); // get formatters for field List<UIFieldFormatterIFace> fmtrs = new Vector<UIFieldFormatterIFace>(uiFieldFormatterMgrCache .getFormatterList(fieldInfo.getTableInfo().getClassObj(), fieldInfo.getName())); Collections.sort(fmtrs, new Comparator<UIFieldFormatterIFace>() { public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) { return o1.getName().compareTo(o2.getName()); }//ww w.java 2s . c o m }); // table and field titles PanelBuilder tblInfoPB = new PanelBuilder( new FormLayout("r:p,2px,f:p:g", "p,2px,p,2px,p,10px")/*, new FormDebugPanel()*/); String typeStr = fieldInfo.getType(); typeStr = typeStr.indexOf('.') > -1 ? StringUtils.substringAfterLast(fieldInfo.getType(), ".") : typeStr; JLabel tableTitleLbl = createLabel(getResourceString("FFE_TABLE") + ":"); JLabel tableTitleValueLbl = createLabel(fieldInfo.getTableInfo().getTitle()); tableTitleValueLbl.setBackground(Color.WHITE); tableTitleValueLbl.setOpaque(true); JLabel fieldTitleLbl = createLabel(getResourceString("FFE_FIELD") + ":"); JLabel fieldTitleValueLbl = createLabel(fieldInfo.getTitle()); fieldTitleValueLbl.setBackground(Color.WHITE); fieldTitleValueLbl.setOpaque(true); //JLabel fieldTypeLbl = createLabel(getResourceString("FFE_TYPE") + ":"); //JLabel fieldTypeValueLbl = createLabel(typeStr); //fieldTypeValueLbl.setBackground(Color.WHITE); //fieldTypeValueLbl.setOpaque(true); JLabel fieldLengthLbl = createLabel(getResourceString("FFE_LENGTH") + ":"); JLabel fieldLengthValueLbl = createLabel(Integer.toString(fieldInfo.getLength())); fieldLengthValueLbl.setBackground(Color.WHITE); fieldLengthValueLbl.setOpaque(true); int y = 1; tblInfoPB.add(tableTitleLbl, cc.xy(1, y)); tblInfoPB.add(tableTitleValueLbl, cc.xy(3, y)); y += 2; tblInfoPB.add(fieldTitleLbl, cc.xy(1, y)); tblInfoPB.add(fieldTitleValueLbl, cc.xy(3, y)); y += 2; //tblInfoPB.add(fieldTypeLbl, cc.xy(1, y)); //tblInfoPB.add(fieldTypeValueLbl, cc.xy(3, y)); y += 2; tblInfoPB.add(fieldLengthLbl, cc.xy(1, y)); tblInfoPB.add(fieldLengthValueLbl, cc.xy(3, y)); y += 2; DefaultListModel listModel = new DefaultListModel(); // add available formatters for (UIFieldFormatterIFace format : fmtrs) { listModel.addElement(format); } formatList = createList(listModel); formatList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //formatList.setCellRenderer(new FmtListRenderer()); hookFormatListSelectionListener(); hookFormatListMouseListener(); ActionListener deleteListener = new ActionListener() { public void actionPerformed(ActionEvent e) { deleteFormatter(); } }; ActionListener editListener = new ActionListener() { public void actionPerformed(ActionEvent e) { editFormatter((UIFieldFormatter) formatList.getSelectedValue(), false); } }; ActionListener addListener = new ActionListener() { public void actionPerformed(ActionEvent e) { addFormatter(); } }; ActionListener defListener = new ActionListener() { public void actionPerformed(ActionEvent e) { setAsDefFormatter(); } }; dedaPanel = new DefEditDeleteAddPanel(defListener, editListener, deleteListener, addListener, "FFE_DEF", "FFE_EDT", "FFE_DEL", "FFE_ADD"); dedaPanel.getAddBtn().setEnabled(true); PanelBuilder pb = new PanelBuilder(new FormLayout("f:max(250px;p):g", "p,4px,p,2px,f:p:g,4px,p")); y = 1; pb.add(tblInfoPB.getPanel(), cc.xy(1, y)); y += 2; pb.add(createI18NLabel("FFE_AVAILABLE_FORMATS", SwingConstants.LEFT), cc.xy(1, y)); y += 2; pb.add(createScrollPane(formatList), cc.xy(1, y)); y += 2; pb.add(dedaPanel, cc.xy(1, y)); y += 2; pb.setDefaultDialogBorder(); //pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); okBtn.setEnabled(false); pack(); }
From source file:net.mariottini.swing.JFontChooser.java
/** * Construct a font chooser with the specified fonts, optionally showing a sample to the user. The * sample text is a default text, you can change it by calling <code>setSampleText</code>. * // w w w .j a va 2 s.co m * @param fontNames * the font family names to show to the user. * @param showSample * true to show a sample of the selected font to the user. * @see #setSampleText */ public JFontChooser(String[] fontNames, boolean showSample) { setLayout(new BorderLayout()); JPanel centerPanel = new JPanel(new BorderLayout()); // Uncomment one of the two lines below to use a standard layout manager // instead of my MeshLayout manager. The result is ugly. // JPanel listsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));/* // JPanel listsPanel = new JPanel(new GridLayout(0, 3));/* net.mariottini.layout.MeshLayout mesh = new net.mariottini.layout.MeshLayout(0, 3, 0); mesh.setExpandColumn(0); JPanel listsPanel = new JPanel(mesh);// */ JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); panel.add(new JLabel("Family name:"), BorderLayout.NORTH); fontList = new JList<>(fontNames); fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fontList.setVisibleRowCount(7); fontList.setSelectedIndex(0); panel.add(new JScrollPane(fontList), BorderLayout.CENTER); listsPanel.add(panel); panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 8)); panel.add(new JLabel("Style:"), BorderLayout.NORTH); styleList = new JList<>(STYLE_NAMES); styleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); styleList.setVisibleRowCount(7); styleList.setSelectedIndex(0); panel.add(new JScrollPane(styleList), BorderLayout.CENTER); listsPanel.add(panel); panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 8)); panel.add(new JLabel("Size:"), BorderLayout.NORTH); JPanel sizePanel = new JPanel(new BorderLayout()); sizeText = new JTextField(String.valueOf(SIZES[0]), 4); sizePanel.add(sizeText, BorderLayout.NORTH); sizeList = new JList<>(ArrayUtils.toObject(SIZES)); sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); sizeList.setVisibleRowCount(6); sizePanel.add(new JScrollPane(sizeList), BorderLayout.CENTER); panel.add(sizePanel, BorderLayout.CENTER); listsPanel.add(panel); centerPanel.add(listsPanel, BorderLayout.NORTH); samplePanel = new JPanel(new BorderLayout()); samplePanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 4, 8)); samplePanel.add(new JLabel("Sample:"), BorderLayout.NORTH); sampleLabel = new JLabel(DEFAULT_SAMPLE_TEXT, JLabel.CENTER); sampleLabel.setMinimumSize(new Dimension(64, 48)); sampleLabel.setOpaque(true); sampleLabel.setBackground(sizeList.getBackground()); sampleLabel.setBorder(sizeText.getBorder()); samplePanel.add(sampleLabel, BorderLayout.CENTER); samplePanel.setVisible(showSample); centerPanel.add(samplePanel, BorderLayout.CENTER); add(centerPanel, BorderLayout.CENTER); accessoryPanel = new JPanel(new BorderLayout()); accessoryPanel.setBorder(BorderFactory.createEmptyBorder(8, 0, 4, 8)); accessoryComponent = new JLabel("Accessory"); accessoryComponent.setOpaque(true); accessoryComponent.setBackground(sizeList.getBackground()); accessoryPanel.add(accessoryComponent, BorderLayout.CENTER); accessoryPanel.setVisible(false); add(accessoryPanel, BorderLayout.EAST); JPanel southPanel = new JPanel(new BorderLayout()); southPanel.add(new JLabel(), BorderLayout.CENTER); JPanel buttonsPanel = new JPanel(); ActionListener actionListener = new ButtonActionListener(); JButton button = new JButton("OK"); button.addActionListener(actionListener); button.setActionCommand(APPROVE_SELECTION); buttonsPanel.add(button); button = new JButton("Cancel"); button.addActionListener(actionListener); button.setActionCommand(CANCEL_SELECTION); buttonsPanel.add(button); southPanel.add(buttonsPanel, BorderLayout.EAST); add(southPanel, BorderLayout.SOUTH); // * Fix list size (optional) Dimension d = fontList.getPreferredSize(); d.width += 6; fontList.setPreferredSize(d); d = styleList.getPreferredSize(); d.width += 6; styleList.setPreferredSize(d); d = sizeList.getPreferredSize(); d.width += 6; sizeList.setPreferredSize(d); // */ // Fix sample size Dimension pref = sampleLabel.getPreferredSize(); Dimension min = sampleLabel.getMinimumSize(); pref.width += 16; pref.height += 12; if (pref.width < min.width) { pref.width = min.width; } if (pref.height < min.height) { pref.height = min.height; } sampleLabel.setPreferredSize(pref); // set listener SampleListener pl = new SampleListener(); fontList.addListSelectionListener(pl); styleList.addListSelectionListener(pl); sizeList.addListSelectionListener(pl); sizeList.addListSelectionListener(new SizeListListener()); sizeText.getDocument().addDocumentListener(new SizeTextListener()); sizeText.addFocusListener(new SizeTextFocusListener()); sizeList.setSelectedIndex(5); }
From source file:ca.uhn.hl7v2.testpanel.ui.AddMessageDialog.java
/** * Create the dialog./*from www. j a va 2s.com*/ */ public AddMessageDialog(Controller theController) { myController = theController; setMinimumSize(new Dimension(450, 400)); setPreferredSize(new Dimension(450, 400)); setSize(new Dimension(450, 400)); setResizable(false); setMaximumSize(new Dimension(450, 400)); setTitle("Add Message"); setBounds(100, 100, 450, 401); getContentPane().setLayout(new BorderLayout()); mycontentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(mycontentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[] { 0, 0 }; gbl_contentPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_contentPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_contentPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; mycontentPanel.setLayout(gbl_contentPanel); { JPanel panel = new JPanel(); panel.setBorder( new TitledBorder(null, "Message Type", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.weighty = 1.0; gbc_panel.insets = new Insets(0, 0, 5, 0); gbc_panel.fill = GridBagConstraints.BOTH; gbc_panel.gridx = 0; gbc_panel.gridy = 0; mycontentPanel.add(panel, gbc_panel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 0, 0, 0 }; gbl_panel.rowHeights = new int[] { 0, 0, 0 }; gbl_panel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); { JLabel lblVersion = new JLabel("Version"); GridBagConstraints gbc_lblVersion = new GridBagConstraints(); gbc_lblVersion.insets = new Insets(0, 0, 5, 5); gbc_lblVersion.gridx = 0; gbc_lblVersion.gridy = 0; panel.add(lblVersion, gbc_lblVersion); } { JLabel lblType = new JLabel("Type"); GridBagConstraints gbc_lblType = new GridBagConstraints(); gbc_lblType.insets = new Insets(0, 0, 5, 0); gbc_lblType.gridx = 1; gbc_lblType.gridy = 0; panel.add(lblType, gbc_lblType); } { JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportBorder(null); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.weighty = 1.0; gbc_scrollPane.insets = new Insets(0, 0, 0, 5); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 1; panel.add(scrollPane, gbc_scrollPane); { myVersionList = new JList(); myVersionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(myVersionList); } } { JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportBorder(null); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.weighty = 1.0; gbc_scrollPane.weightx = 1.0; gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 1; panel.add(scrollPane, gbc_scrollPane); { myMessageTypeList = new JList(); myMessageTypeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(myMessageTypeList); } } } { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, "Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.fill = GridBagConstraints.BOTH; gbc_panel.gridx = 0; gbc_panel.gridy = 1; mycontentPanel.add(panel, gbc_panel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 0, 0, 0 }; gbl_panel.rowHeights = new int[] { 0, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); { JLabel lblEncoding = new JLabel("Encoding"); GridBagConstraints gbc_lblEncoding = new GridBagConstraints(); gbc_lblEncoding.insets = new Insets(0, 0, 0, 5); gbc_lblEncoding.gridx = 0; gbc_lblEncoding.gridy = 0; panel.add(lblEncoding, gbc_lblEncoding); } { JPanel panel_1 = new JPanel(); panel_1.setBorder(null); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.anchor = GridBagConstraints.WEST; gbc_panel_1.fill = GridBagConstraints.VERTICAL; gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; panel.add(panel_1, gbc_panel_1); { myEr7Radio = new JRadioButton("ER7"); myEr7Radio.setSelected(true); encodingButtonGroup.add(myEr7Radio); panel_1.add(myEr7Radio); } { JRadioButton myXmlRadio = new JRadioButton("XML"); encodingButtonGroup.add(myXmlRadio); panel_1.add(myXmlRadio); } } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { String version = (String) myVersionList.getSelectedValue(); String fullType = (String) myMessageTypeList.getSelectedValue(); String structure = myTypesToStructures.get(fullType); String[] fullTypeBits = fullType.split("\\^"); String type = fullTypeBits[0]; String trigger = fullTypeBits[1]; Hl7V2EncodingTypeEnum encoding = myEr7Radio.isSelected() ? Hl7V2EncodingTypeEnum.ER_7 : Hl7V2EncodingTypeEnum.XML; myController.addMessage(version, type, trigger, structure, encoding); } finally { setVisible(false); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AddMessageDialog.this.setVisible(false); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } initLocal(); }
From source file:fr.eurecom.hybris.demogui.HybrisDemoGui.java
private void initializeGUI() { frame = new JFrame("Hybris Demo GUI"); frame.setIconImage(new ImageIcon(getClass().getResource("/clouds.png")).getImage()); frame.setBounds(100, 100, 650, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new GridBagLayout()); JPanel cloudParentPanel = new JPanel(new GridLayout(1, 2, 10, 10)); JPanel hybrisPanel = new JPanel(new GridBagLayout()); JPanel cloudsPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.weightx = 1.0;/*from w ww . j ava2 s.c om*/ gbc.weighty = 1.0; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = 3; gbc.gridheight = 1; gbc.gridx = 0; gbc.gridy = 0; hybrisPanel.add(new JLabel("<html><b>Hybris</b></html>"), gbc); gbc.gridwidth = 3; gbc.gridheight = 3; gbc.gridx = 0; gbc.gridy = 1; lstHybris = new JList<String>(lmHybris); lstHybris.setPreferredSize(new java.awt.Dimension(100, 500)); lstHybris.setMinimumSize(new java.awt.Dimension(100, 440)); hybrisPanel.add(lstHybris, gbc); gbc.anchor = GridBagConstraints.SOUTH; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = 1; gbc.gridx = 0; gbc.gridy = 4; btnPut = new JButton("Put"); hybrisPanel.add(btnPut, gbc); gbc.gridx = 1; gbc.gridy = 4; btnGet = new JButton("Get"); hybrisPanel.add(btnGet, gbc); gbc.gridx = 2; gbc.gridy = 4; btnDelete = new JButton("Delete"); hybrisPanel.add(btnDelete, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; cloudsPanel.add(new JLabel("<html><b>Amazon S3</b></html>"), gbc); gbc.gridheight = 2; gbc.gridy = 1; lstAmazon = new JList<String>(lmAmazon); lstAmazon.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstAmazon.setPreferredSize(new java.awt.Dimension(100, 100)); cloudsPanel.add(lstAmazon, gbc); gbc.gridy = 3; gbc.gridheight = 1; cloudsPanel.add(new JLabel("<html><b>Microsoft Azure</b></html>"), gbc); gbc.gridheight = 2; gbc.gridy = 4; lstAzure = new JList<String>(lmAzure); lstAzure.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstAzure.setPreferredSize(new java.awt.Dimension(100, 100)); cloudsPanel.add(lstAzure, gbc); gbc.gridy = 6; gbc.gridheight = 1; cloudsPanel.add(new JLabel("<html><b>Google Cloud Storage</b></html>"), gbc); gbc.gridheight = 2; gbc.gridy = 7; lstGoogle = new JList<String>(lmGoogle); lstGoogle.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstGoogle.setPreferredSize(new java.awt.Dimension(100, 100)); cloudsPanel.add(lstGoogle, gbc); gbc.gridy = 9; gbc.gridheight = 1; cloudsPanel.add(new JLabel("<html><b>Rackspace Cloud Files</b></html>"), gbc); gbc.gridheight = 2; gbc.gridy = 10; lstRackspace = new JList<String>(lmRackspace); lstRackspace.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstRackspace.setPreferredSize(new java.awt.Dimension(100, 100)); cloudsPanel.add(lstRackspace, gbc); cloudParentPanel.add(hybrisPanel); cloudParentPanel.add(cloudsPanel); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; frame.add(cloudParentPanel, gbc); gbc.gridx = 0; gbc.gridy = 1; JTextArea jt = new JTextArea(10, 30); JScrollPane scrollPane = new JScrollPane(jt); frame.add(scrollPane, gbc); PrintStream printStream = new PrintStream(new CustomOutputStream(jt)); System.setOut(printStream); System.setErr(printStream); frame.pack(); frame.setSize(550, 800); frame.setResizable(false); lstAmazon.addKeyListener(this); lstAzure.addKeyListener(this); lstGoogle.addKeyListener(this); lstRackspace.addKeyListener(this); lstHybris.addKeyListener(this); lstAmazon.setCellRenderer(this.new MyListRenderer("amazon")); lstGoogle.setCellRenderer(this.new MyListRenderer("google")); lstAzure.setCellRenderer(this.new MyListRenderer("azure")); lstRackspace.setCellRenderer(this.new MyListRenderer("rackspace")); btnGet.addActionListener(this); btnPut.addActionListener(this); btnDelete.addActionListener(this); }