List of usage examples for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED
int VERTICAL_SCROLLBAR_AS_NEEDED
To view the source code for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED.
Click Source Link
From source file:com.haulmont.cuba.desktop.gui.components.DesktopScrollBoxLayout.java
private void applyScrollBarPolicy(ScrollBarPolicy scrollBarPolicy) { switch (scrollBarPolicy) { case BOTH:/* ww w . j a v a 2s . c om*/ impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); content.setWidth("-1px"); content.setHeight("-1px"); break; case HORIZONTAL: impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); content.setWidth("-1px"); content.setHeight("100%"); break; case VERTICAL: impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); content.setWidth("100%"); content.setHeight("-1px"); break; case NONE: impl.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); impl.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); content.setWidth("100%"); content.setHeight("100%"); break; } }
From source file:edu.ku.brc.stats.StatGroupTable.java
/** * Constructor with the localized name of the Group * @param name name of the group (already been localized) * @param useSeparator use non-border separator titles *//*from w w w . j av a 2s. c om*/ public StatGroupTable(final String name, final String[] columnNames, final boolean useSeparator, final int numRows) { this.name = name; this.useSeparator = useSeparator; this.skinItem = SkinsMgr.getSkinItem("StatGroup"); if (progressIcon == null) { progressIcon = IconManager.getIcon("Progress", IconManager.IconSize.Std16); } setLayout(new BorderLayout()); setBackground(Color.WHITE); model = new StatGroupTableModel(this, columnNames); //table = numRows > SCROLLPANE_THRESOLD ? (new SortableJTable(new SortableTableModel(model))) : (new JTable(model)); if (numRows > SCROLLPANE_THRESOLD) { table = new SortableJTable(new SortableTableModel(model)) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } else { table = new JTable(model) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } table.setShowVerticalLines(false); table.setShowHorizontalLines(false); if (SkinsMgr.shouldBeOpaque(skinItem)) { table.setOpaque(false); setOpaque(false); } else { table.setOpaque(true); setOpaque(true); } table.addMouseMotionListener(new TableMouseMotion()); table.addMouseListener(new LinkListener()); if (table.getColumnModel().getColumnCount() == 1) { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.CENTER, 1)); } else { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.LEFT, 2)); table.getColumnModel().getColumn(1) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.RIGHT, 2)); } //table.setRowSelectionAllowed(true); if (numRows > SCROLLPANE_THRESOLD) { scrollPane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); if (table instanceof SortableJTable) { ((SortableJTable) table).installColumnHeaderListeners(); } scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.setBorder(BorderFactory.createEmptyBorder()); //scrollPane.getViewport().setBorder(BorderFactory.createEmptyBorder()); } if (useSeparator) { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); CellConstraints cc = new CellConstraints(); if (StringUtils.isNotEmpty(name)) { builder.addSeparator(name, cc.xy(1, 1)); } builder.add(scrollPane != null ? scrollPane : table, cc.xy(1, 2)); builder.getPanel().setOpaque(false); add(builder.getPanel()); } else { setBorder(BorderFactory.createEmptyBorder(15, 2, 2, 2)); setBorder(BorderFactory.createCompoundBorder(new CurvedBorder(new Color(160, 160, 160)), getBorder())); add(scrollPane != null ? scrollPane : table, BorderLayout.CENTER); } }
From source file:com.hp.alm.ali.idea.ui.editor.field.HTMLAreaField.java
@Override public Component getComponent() { if (pane == null) { pane = new JBScrollPane(super.getComponent(), ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); pane.setPreferredSize(new Dimension(600, 30)); pane.setMinimumSize(new Dimension(300, 30)); }/*from ww w .j a va 2 s . c o m*/ return pane; }
From source file:edu.ku.brc.specify.ui.LoanReturnDlg.java
/** * @return//from ww w . j a v a2s .c o m */ public boolean createUI() { DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); loan = session.merge(loan); setTitle(getResourceString("LOANRET_TITLE")); validator.addValidationListener(new ValidationListener() { public void wasValidated(UIValidator val) { doEnableOKBtn(); } }); JPanel contentPanel = new JPanel(new BorderLayout()); JPanel mainPanel = new JPanel(); System.out.println("Num Loan Preps for Loan: " + loan.getLoanPreparations()); HashMap<Integer, Pair<CollectionObject, Vector<LoanPreparation>>> colObjHash = new HashMap<Integer, Pair<CollectionObject, Vector<LoanPreparation>>>(); for (LoanPreparation loanPrep : loan.getLoanPreparations()) { CollectionObject colObj = loanPrep.getPreparation().getCollectionObject(); System.out.println("For LoanPrep ColObj Is: " + colObj.getIdentityTitle()); Vector<LoanPreparation> list = null; Pair<CollectionObject, Vector<LoanPreparation>> pair = colObjHash.get(colObj.getId()); if (pair == null) { list = new Vector<LoanPreparation>(); colObjHash.put(colObj.getId(), new Pair<CollectionObject, Vector<LoanPreparation>>(colObj, list)); } else { list = pair.second; } list.add(loanPrep); } int colObjCnt = colObjHash.size(); String rowDef = UIHelper.createDuplicateJGoodiesDef("p", "1px,p,4px", (colObjCnt * 2) - 1); PanelBuilder pbuilder = new PanelBuilder(new FormLayout("f:p:g", rowDef), mainPanel); CellConstraints cc = new CellConstraints(); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent ae) { doEnableOKBtn(); } }; ChangeListener cl = new ChangeListener() { public void stateChanged(ChangeEvent ae) { doEnableOKBtn(); } }; int i = 0; int y = 1; Vector<Pair<CollectionObject, Vector<LoanPreparation>>> pairList = new Vector<Pair<CollectionObject, Vector<LoanPreparation>>>( colObjHash.values()); Collections.sort(pairList, new Comparator<Pair<CollectionObject, Vector<LoanPreparation>>>() { @Override public int compare(Pair<CollectionObject, Vector<LoanPreparation>> o1, Pair<CollectionObject, Vector<LoanPreparation>> o2) { return o1.first.getIdentityTitle().compareTo(o2.first.getIdentityTitle()); } }); for (Pair<CollectionObject, Vector<LoanPreparation>> pair : pairList) { CollectionObject co = pair.first; if (i > 0) { pbuilder.addSeparator("", cc.xy(1, y)); y += 2; } ColObjPanel panel = new ColObjPanel(session, this, co, colObjHash.get(co.getId()).second); colObjPanels.add(panel); panel.addActionListener(al, cl); pbuilder.add(panel, cc.xy(1, y)); y += 2; i++; } JButton selectAllBtn = createButton(getResourceString("SELECTALL")); okBtn = createButton(getResourceString("SAVE")); JButton cancel = createButton(getResourceString("CANCEL")); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,2px,p,2px,p,2px,p,2px,p", "p")); dateClosed = new ValFormattedTextFieldSingle("Date", false, false, 10); dateClosed.setNew(true); dateClosed.setValue(null, ""); dateClosed.setRequired(true); validator.hookupTextField(dateClosed, "2", true, UIValidator.Type.Changed, "", false); summaryLabel = createLabel(""); pb.add(summaryLabel, cc.xy(1, 1)); pb.add(createI18NLabel("LOANRET_AGENT"), cc.xy(3, 1)); pb.add(agentCBX = createAgentCombobox(), cc.xy(5, 1)); pb.add(createI18NLabel("ON"), cc.xy(7, 1)); pb.add(dateClosed, cc.xy(9, 1)); contentPanel.add(pb.getPanel(), BorderLayout.NORTH); contentPanel.add(new JScrollPane(mainPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(5, 0, 2, 0)); p.add(ButtonBarFactory.buildOKCancelApplyBar(okBtn, cancel, selectAllBtn), BorderLayout.CENTER); contentPanel.add(p, BorderLayout.SOUTH); contentPanel.setBorder(BorderFactory.createEmptyBorder(4, 12, 2, 12)); setContentPane(contentPanel); doEnableOKBtn(); //setIconImage(IconManager.getIcon("Preparation", IconManager.IconSize.Std16).getImage()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); doEnableOKBtn(); okBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setVisible(false); isCancelled = false; } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setVisible(false); } }); selectAllBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { selectAllItems(); } }); pack(); Dimension size = getPreferredSize(); size.width += 20; size.height = size.height > 500 ? 500 : size.height; setSize(size); return true; } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LoanReturnDlg.class, ex); // Error Dialog ex.printStackTrace(); } finally { if (session != null) { session.close(); } } return false; }
From source file:edu.ku.brc.specify.config.ResourceImportExportDlg.java
@Override public void createUI() { this.setHelpContext("Import"); super.createUI(); CellConstraints cc = new CellConstraints(); levelCBX = createComboBox();//w w w . j a v a 2 s. co m DataProviderSessionIFace session = null; try { session = DataProviderFactory.getInstance().createSession(); for (SpAppResourceDir curDir : contextMgr.getSpAppResourceList()) { SpAppResourceDir dir; if (curDir.getId() != null) { dir = session.get(SpAppResourceDir.class, curDir.getId()); dir.setTitle(curDir.getTitle()); // Force Load dir.getSpAppResources().size(); dir.getSpPersistedAppResources().size(); dir.getSpPersistedViewSets().size(); for (SpAppResource appRes : curDir.getSpAppResources()) { if (appRes.getId() == null) { dir.getSpAppResources().add(appRes); } } for (SpViewSetObj vso : curDir.getSpViewSets()) { if (vso.getId() == null) { dir.getSpViewSets().add(vso); } } } else { dir = (SpAppResourceDir) curDir.clone(); } dirs.add(dir); levelCBX.addItem(dir); } } catch (Exception ex) { ex.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ResourceImportExportDlg.class, ex); } finally { if (session != null) { session.close(); } } PanelBuilder centerPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "p,10px,p")); centerPB.add(createLabel(UIRegistry.getLocalizedMessage("RIE_USR_LBL", userName)), cc.xy(2, 1)); centerPB.add(levelCBX, cc.xy(2, 3)); tabbedPane = new JTabbedPane(); PanelBuilder viewPanel = new PanelBuilder(new FormLayout("f:p:g,10px,f:p:g", "p,2px,f:p:g")); viewPanel.add(createLabel(getResourceString("RIE_VIEWSETS"), SwingConstants.CENTER), cc.xy(1, 1)); viewSetsList = new JList(viewSetsModel); viewSetsList.setCellRenderer(new ARListRenderer()); JScrollPane sp = new JScrollPane(viewSetsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); viewPanel.add(sp, cc.xy(1, 3)); viewPanel.add(createLabel(getResourceString("RIE_VIEWS"), SwingConstants.CENTER), cc.xy(3, 1)); viewsList = new JList(viewsModel); viewsList.setCellRenderer(new ViewRenderer()); sp = new JScrollPane(viewsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); viewPanel.add(sp, cc.xy(3, 3)); viewsList.setEnabled(false); PanelBuilder resPane = new PanelBuilder(new FormLayout("f:p:g", "p,2px,p")); resPane.add(createLabel(getResourceString("RIE_OTHER_RES"), SwingConstants.CENTER), cc.xy(1, 1)); resList = new JList(resModel); resList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resList.setCellRenderer(new ARListRenderer()); sp = new JScrollPane(resList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); resPane.add(sp, cc.xy(1, 3)); PanelBuilder repPane = new PanelBuilder(new FormLayout("f:p:g", "p,2px,f:p:g")); repPane.add(createLabel(getResourceString("RIE_REPORT_RES"), SwingConstants.CENTER), cc.xy(1, 1)); repList = new JList(repModel); repList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); repList.setCellRenderer(new ARListRenderer()); sp = new JScrollPane(repList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); repPane.add(sp, cc.xy(1, 3)); boolean addResourcesPanel = AppPreferences.getLocalPrefs().getBoolean("ADD_IMP_RES", false); viewsPanel = viewPanel.getPanel(); tabbedPane.addTab(getResourceString("RIE_VIEWSETS"), viewsPanel); if (addResourcesPanel) { resPanel = resPane.getPanel(); tabbedPane.addTab(getResourceString("RIE_OTHER_RES"), resPanel); } repPanel = repPane.getPanel(); tabbedPane.addTab(getResourceString("RIE_REPORT_RES"), repPanel); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,2px,p")); pb.add(centerPB.getPanel(), cc.xy(1, 1)); pb.add(tabbedPane, cc.xy(1, 3)); exportBtn = createButton(getResourceString("RIE_EXPORT")); importBtn = createButton(getResourceString("RIE_IMPORT")); revertBtn = createButton(getResourceString("RIE_REVERT")); PanelBuilder btnPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g,p,f:p:g,p,f:p:g", "p,10px")); btnPB.add(exportBtn, cc.xy(2, 1)); btnPB.add(importBtn, cc.xy(4, 1)); btnPB.add(revertBtn, cc.xy(6, 1)); pb.add(btnPB.getPanel(), cc.xy(1, 5)); pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Component selectedComp = tabbedPane.getSelectedComponent(); if (selectedComp != null) { if (selectedComp == viewsPanel) { viewSetsList.setSelectedIndex(-1); } else if (selectedComp == resPanel) { resList.setSelectedIndex(-1); } else { repList.setSelectedIndex(-1); } //revertBtn.setVisible(selectedComp != repPanel); } enableUI(); // JGoodies Resizes the panel in the Dialog and // partially hides the buttons, this fixes that. Dimension size = ResourceImportExportDlg.this.getSize(); //ResourceImportExportDlg.this.pack(); //Dimension newSize = ResourceImportExportDlg.this.getSize(); Dimension newSize = ResourceImportExportDlg.this.getPreferredSize(); size.height = newSize.height; ResourceImportExportDlg.this.setSize(size); } }); levelCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { levelSelected(); } }); } }); levelCBX.setSelectedIndex(0); pack(); exportBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exportResource(); } }); importBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importResource(); } }); revertBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { revertResource(); } }); viewSetsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (viewSetsList.getSelectedIndex() > -1) { resList.clearSelection(); repList.clearSelection(); } fillViewsList(); enableUI(); } } }); resList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (resList.getSelectedIndex() > -1) { viewSetsList.clearSelection(); repList.clearSelection(); } enableUI(); } } }); repList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (resList.getSelectedIndex() > -1) { viewSetsList.clearSelection(); resList.clearSelection(); } enableUI(); } } }); pack(); }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * /* w w w .ja v a2 s . c o m*/ */ public void buildUI() { setIgnoreChanges(true); fieldsList = createList(fieldsModel); fieldsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { getAllDataFromUI(); fieldSelected(); } } }); fieldsList.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { super.focusLost(e); //lastIndex = fieldsList.getSelectedIndex(); } }); fieldDescText.addKeyListener(new LengthWatcher(255)); // setting min and pref sizes to some bogus values so that textarea shrinks with dialog fieldNameText.addKeyListener(new LengthWatcher(64)); CellConstraints cc = new CellConstraints(); int y = 1; JScrollPane fldsp = UIHelper.createScrollPane(fieldsList); // LocalizableNameDescIFace PanelBuilder pb = new PanelBuilder(new FormLayout("max(200px;p),4px,p,2px,p,10px,p,2px,p,f:p:g", (includeHiddenUI ? "p,2px," : "") + (isDBSchema ? "p,2px,p,2px," : "") + (includeFormatAndAutoNumUI ? "p,2px,p,2px," : "") + "p,2px,p,2px,p,2px,p,2px,p,2px,p,2px,f:p:g"), this); pb.add(fldsp, cc.xywh(1, y, 1, 7 + (isDBSchema ? 4 : 0))); pb.add(fieldNameLbl = createI18NFormLabel("SL_LABEL", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldNameText, cc.xywh(5, y, 6, 1)); y += 2; if (includeHiddenUI) { pb.add(fieldHideChk, cc.xy(5, y)); y += 2; } pb.add(fieldDescLbl = createI18NFormLabel("SL_DESC", SwingConstants.RIGHT), cc.xy(3, y)); JScrollPane sp = new JScrollPane(fieldDescText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); pb.add(sp, cc.xywh(5, y, 6, 1)); y += 2; fieldDescText.setLineWrap(true); fieldDescText.setWrapStyleWord(true); if (isDBSchema) { fieldTypeTxt = createLabel(""); fieldLengthTxt = createLabel(""); pb.add(fieldTypeLbl = createI18NFormLabel("SL_TYPE", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldTypeTxt, cc.xy(5, y)); pb.add(fieldReqChk = createCheckBox(getResourceString("SL_REQ")), cc.xy(9, y)); y += 2; pb.add(fieldLengthLbl = createI18NFormLabel("SL_LENGTH", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldLengthTxt, cc.xy(5, y)); y += 2; fieldTypeTxt.setBackground(Color.WHITE); fieldLengthTxt.setBackground(Color.WHITE); fieldTypeTxt.setOpaque(true); fieldLengthTxt.setOpaque(true); } if (includeFormatAndAutoNumUI) { PanelBuilder inner = new PanelBuilder(new FormLayout("p,2px,p", "p")); formatSwitcherCombo = createComboBox(); fmtCardLayout = new CardLayout(); formatterPanel = new JPanel(fmtCardLayout); pb.add(formatLbl = createI18NFormLabel("SL_FMTTYPE", SwingConstants.RIGHT), cc.xy(3, y)); inner.add(formatSwitcherCombo, cc.xy(1, 1)); inner.add(formatterPanel, cc.xy(3, 1)); pb.add(inner.getPanel(), cc.xywh(5, y, 6, 1)); y += 2; ActionListener switchAL = new ActionListener() { public void actionPerformed(ActionEvent e) { String item = (String) formatSwitcherCombo.getSelectedItem(); if (item != null) { fmtCardLayout.show(formatterPanel, item); webLinkCombo.setEnabled(item.equals(SL_WEBLINK)); if (formatSwitcherCombo.getSelectedIndex() == 0) { if (webLinkCombo.getModel().getSize() > 0) { webLinkCombo.setSelectedIndex(0); } if (formatCombo.getModel().getSize() > 0) { formatCombo.setSelectedIndex(0); } if (pickListCBX.getModel().getSize() > 0) { pickListCBX.setSelectedIndex(0); } } } } }; formatSwitcherCombo.addActionListener(switchAL); formatterPanel.add(SL_NONE, new JPanel()); //-------------------------- // UIFieldFormatter //-------------------------- inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); formatCombo = createComboBox(new DefaultComboBoxModel()); formatMoreBtn = createButton(ELIPSES); inner.add(formatCombo, cc.xy(1, 1)); inner.add(formatMoreBtn, cc.xy(3, 1)); formatMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UIFormatterListEdtDlg dlg = new UIFormatterListEdtDlg((Frame) UIRegistry.getTopWindow(), fieldInfo, true, schemaPanel.getUiFieldFormatterMgrCache()); dlg.setVisible(true); if (!dlg.isCancelled() && dlg.hasChanged()) { //schemaPanel.setHasChanged(true); formHasChanged(); //fillFormatBox(dlg.getSelectedFormat()); setSelectedFieldFormatter(dlg.getSelectedFormat()); } } }); formatterPanel.add(SL_FORMAT, inner.getPanel()); ActionListener changed = new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); boolean hasFormat = formatCombo.getSelectedIndex() > 0; webLinkCombo.setEnabled(!hasFormat); if (hasFormat) { webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1); } } }; formatCombo.addActionListener(changed); //-------------------------- // WebLinks //-------------------------- webLinkMoreBtn = createButton(ELIPSES); webLinkMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { WebLinkDef selectedWL = (WebLinkDef) webLinkCombo.getSelectedItem(); WebLinkConfigDlg dlg = webLinkMgrCache.editWebLinks(tableInfo, false); if (dlg.getBtnPressed() == CustomDialog.OK_BTN) { fillWebLinkBox(); formHasChanged(); if (selectedWL != null && !selectedWL.getName().equals(SL_WEBLINK)) { dlg.setWebLink(selectedWL.getName()); } if (dlg.getBtnPressed() == CustomDialog.OK_BTN) { setSelectedWebLink(dlg.getSelectedItem()); } } } }); inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); webLinkCombo = createComboBox(); DefaultComboBoxModel model = (DefaultComboBoxModel) webLinkCombo.getModel(); model.addElement(webLinkDefNone); webLinkCombo.setSelectedIndex(0); inner.add(webLinkCombo, cc.xy(1, 1)); inner.add(webLinkMoreBtn, cc.xy(3, 1)); ActionListener wlchanged = new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); boolean hasWL = webLinkCombo.getSelectedIndex() > 0; webLinkCombo.setEnabled(hasWL); if (hasWL) { formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1); } } }; webLinkCombo.addActionListener(wlchanged); formatterPanel.add(SL_WEBLINK, inner.getPanel()); } //-------------------------- // PickList //-------------------------- pickListCBX = createComboBox(new DefaultComboBoxModel()); pickListCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); if (formatCombo != null && pickListCBX.getSelectedIndex() > 0) { formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1); webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1); } } }); pickListMoreBtn = createButton(ELIPSES); pickListMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LocalizableItemIFace currentField = prevField; prevField = getSelectedFieldItem(); PickList selectedItem = (PickList) pickListCBX.getSelectedItem(); PickListEditorDlg dlg = new PickListEditorDlg( localizableIO.hasUpdatablePickLists() ? null : localizableIO, true, true); dlg.setTableInfo(tableInfo); dlg.setFieldInfo(fieldInfo); dlg.createUI(); dlg.setSize(400, 500); dlg.setVisible(true); if (!dlg.isCancelled()) { if (dlg.hasChanged()) { hasChanged = true; Vector<PickList> list = dlg.getNewPickLists(); DefaultComboBoxModel plCbxModel = (DefaultComboBoxModel) pickListCBX.getModel(); for (int i = 0; i < plCbxModel.getSize(); i++) { list.add((PickList) plCbxModel.getElementAt(i)); } Collections.sort(list); plCbxModel.removeAllElements(); plCbxModel.addElement(pickListNone); int inx = -1; int i = 0; for (PickList pl : list) { plCbxModel.addElement(pl); if (inx == -1 && selectedItem != null && ((selectedItem.getId() != null && pl.getId() != null && selectedItem.getId().equals(pl.getId())) || (selectedItem.getName() != null && pl.getName() != null && selectedItem.getName().equals(pl.getName())))) { inx = i; } i++; } pickListCBX.setSelectedIndex(inx + 1); } } prevField = currentField; } }); if (includeFormatAndAutoNumUI) { PanelBuilder inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); inner.add(pickListCBX, cc.xy(1, 1)); inner.add(pickListMoreBtn, cc.xy(3, 1)); formatterPanel.add(SL_PICKLIST, inner.getPanel()); } else { pb.add(pickListLbl = createI18NFormLabel(SL_PICKLIST, SwingConstants.RIGHT), cc.xy(3, y)); pb.add(pickListCBX, cc.xy(5, y)); pb.add(pickListMoreBtn, cc.xy(7, y)); y += 2; } nxtBtn = createI18NButton("SL_NEXT"); nxtEmptyBtn = createI18NButton("SL_NEXT_EMPTY"); fldSpellChkBtn = createI18NButton("SL_SPELL_CHECK"); //JPanel bbp = ButtonBarFactory.buildCenteredBar(adjustButtonArray(new JButton[] {nxtEmptyBtn, nxtBtn, fldSpellChkBtn})); //bbp.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); //pb.add(bbp, cc.xywh(3, y, 8, 1)); nxtBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { next(); } }); nxtEmptyBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextEmpty(); } }); fldSpellChkBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (checker != null) { checker.spellCheck(fieldDescText); checker.spellCheck(fieldNameText); } } }); fieldHideChk.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { formHasChanged(); } }); fieldReqChk.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { formHasChanged(); } }); DocumentListener dl = new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { formHasChanged(); } }; fieldNameText.getDocument().addDocumentListener(dl); fieldDescText.getDocument().addDocumentListener(dl); /* if (formatTxt != null) { formatTxt.getDocument().addDocumentListener(dl); } */ SchemaI18NService.getInstance().checkCurrentLocaleMenu(); enableUIControls(false); setIgnoreChanges(false); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.TemplateEditor.java
@Override public void createUI() { super.createUI(); databaseSchema = WorkbenchTask.getDatabaseSchema(); int disciplineeId = AppContextMgr.getInstance().getClassObject(Discipline.class).getDisciplineId(); SchemaI18NService.getInstance().loadWithLocale(SpLocaleContainer.WORKBENCH_SCHEMA, disciplineeId, databaseSchema, SchemaI18NService.getCurrentLocale()); // Create the Table List Vector<TableInfo> tableInfoList = new Vector<TableInfo>(); for (DBTableInfo ti : databaseSchema.getTables()) { if (StringUtils.isNotEmpty(ti.toString())) { TableInfo tableInfo = new TableInfo(ti, IconManager.STD_ICON_SIZE); tableInfoList.add(tableInfo); Vector<FieldInfo> fldList = new Vector<FieldInfo>(); for (DBFieldInfo fi : ti.getFields()) { String fldTitle = fi.getTitle().replace(" ", ""); if (fldTitle.equalsIgnoreCase(fi.getName())) { //get title from mapped field UploadInfo upInfo = getUploadInfo(fi); DBFieldInfo mInfo = getMappedFieldInfo(fi); if (mInfo != null) { String title = mInfo.getTitle(); if (upInfo != null && upInfo.getSequence() != -1) { title += " " + (upInfo.getSequence() + 1); }/*from w ww . j a va2 s .com*/ //if mapped-to table is different than the container table used // in the wb, add the mapped-to table's title if (mInfo.getTableInfo().getTableId() != ti.getTableId()) { title = mInfo.getTableInfo().getTitle() + " " + title; } fi.setTitle(title); } } fldList.add(new FieldInfo(ti, fi)); } //Collections.sort(fldList); tableInfo.setFieldItems(fldList); } } Collections.sort(tableInfoList); fieldModel = new DefaultModifiableListModel<FieldInfo>(); tableModel = new DefaultModifiableListModel<TableInfo>(); for (TableInfo ti : tableInfoList) { tableModel.add(ti); // only added for layout for (FieldInfo fi : ti.getFieldItems()) { fieldModel.add(fi); } } tableList = new JList(tableModel); tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tableList.setCellRenderer(tableInfoListRenderer = new TableInfoListRenderer(IconManager.STD_ICON_SIZE)); JScrollPane tableScrollPane = new JScrollPane(tableList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); tableList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object selObj = tableList.getSelectedValue(); if (selObj != null) { fillFieldList((TableInfo) selObj); } updateEnabledState(); } } }); fieldList = new JList(fieldModel); fieldList.setCellRenderer(tableInfoListRenderer = new TableInfoListRenderer(IconManager.STD_ICON_SIZE)); fieldList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); JScrollPane fieldScrollPane = new JScrollPane(fieldList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); fieldList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateEnabledState(); updateFieldDescription(); } } }); mapModel = new DefaultModifiableListModel<FieldMappingPanel>(); mapList = new JList(mapModel); mapList.setCellRenderer(new MapCellRenderer()); mapList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mapScrollPane = new JScrollPane(mapList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); mapList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { FieldMappingPanel fmp = (FieldMappingPanel) mapList.getSelectedValue(); if (fmp != null) { ignoreMapListUpdate = true; FieldInfo fldInfo = fmp.getFieldInfo(); if (fldInfo != null) { for (int i = 0; i < tableModel.size(); i++) { TableInfo tblInfo = (TableInfo) tableModel.get(i); if (fldInfo.getTableinfo() == tblInfo.getTableInfo()) { tableList.setSelectedValue(tblInfo, true); fillFieldList(tblInfo); //System.out.println(fldInfo.hashCode()+" "+fldInfo.getFieldInfo().hashCode()); fieldList.setSelectedValue(fldInfo, true); updateFieldDescription(); break; } } } ignoreMapListUpdate = false; updateEnabledState(); } } } }); upBtn = createIconBtn("ReorderUp", "WB_MOVE_UP", new ActionListener() { public void actionPerformed(ActionEvent ae) { int inx = mapList.getSelectedIndex(); FieldMappingPanel fmp = mapModel.getElementAt(inx); mapModel.remove(fmp); mapModel.insertElementAt(fmp, inx - 1); mapList.setSelectedIndex(inx - 1); updateEnabledState(); setChanged(true); } }); downBtn = createIconBtn("ReorderDown", "WB_MOVE_DOWN", new ActionListener() { public void actionPerformed(ActionEvent ae) { int inx = mapList.getSelectedIndex(); FieldMappingPanel fmp = mapModel.getElementAt(inx); mapModel.remove(fmp); mapModel.insertElementAt(fmp, inx + 1); mapList.setSelectedIndex(inx + 1); updateEnabledState(); setChanged(true); } }); JButton dumpMappingBtn = createIconBtn("BlankIcon", IconManager.IconSize.Std16, "WB_MAPPING_DUMP", new ActionListener() { public void actionPerformed(ActionEvent ae) { dumpMapping(); } }); dumpMappingBtn.setEnabled(true); dumpMappingBtn.setFocusable(false); dumpMappingBtn.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { ((JButton) e.getSource()).setIcon(IconManager.getIcon("Save", IconManager.IconSize.Std16)); super.mouseEntered(e); } @Override public void mouseExited(MouseEvent e) { ((JButton) e.getSource()).setIcon(IconManager.getIcon("BlankIcon", IconManager.IconSize.Std16)); super.mouseExited(e); } }); mapToBtn = createIconBtn("Map", "WB_ADD_MAPPING_ITEM", new ActionListener() { public void actionPerformed(ActionEvent ae) { map(); } }); unmapBtn = createIconBtn("Unmap", "WB_REMOVE_MAPPING_ITEM", new ActionListener() { public void actionPerformed(ActionEvent ae) { unmap(); } }); // Adjust all Labels depending on whether we are creating a new template or not // and whether it is from a file or not String mapListLeftLabel; String mapListRightLabel; // Note: if workbenchTemplate is null then it is String dataTypeLabel = getResourceString("WB_DATA_TYPE"); String fieldsLabel = getResourceString("WB_FIELDS"); mapListLeftLabel = fieldsLabel; mapListRightLabel = getResourceString("WB_COLUMNS"); CellConstraints cc = new CellConstraints(); JPanel mainLayoutPanel = new JPanel(); PanelBuilder labelsBldr = new PanelBuilder(new FormLayout("p, f:p:g, p", "p")); labelsBldr.add(createLabel(mapListLeftLabel, SwingConstants.LEFT), cc.xy(1, 1)); labelsBldr.add(createLabel(mapListRightLabel, SwingConstants.RIGHT), cc.xy(3, 1)); PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p,f:p:g, p, 2px, p, f:p:g")); upDownPanel.add(dumpMappingBtn, cc.xy(1, 1)); upDownPanel.add(upBtn, cc.xy(1, 3)); upDownPanel.add(downBtn, cc.xy(1, 5)); PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "p, 2px, p")); middlePanel.add(mapToBtn, cc.xy(1, 1)); middlePanel.add(unmapBtn, cc.xy(1, 3)); btnPanel = middlePanel.getPanel(); btnPanel.setOpaque(false); PanelBuilder outerMiddlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, f:p:g")); outerMiddlePanel.add(btnPanel, cc.xy(1, 2)); outerMiddlePanel.getPanel().setOpaque(false); // Main Pane Layout PanelBuilder builder = new PanelBuilder( new FormLayout("f:max(200px;p):g, 5px, max(200px;p), 5px, p:g, 5px, f:max(250px;p):g, 2px, p", "p, 2px, f:max(350px;p):g"), mainLayoutPanel); builder.add(createLabel(dataTypeLabel, SwingConstants.CENTER), cc.xy(1, 1)); builder.add(createLabel(fieldsLabel, SwingConstants.CENTER), cc.xy(3, 1)); builder.add(labelsBldr.getPanel(), cc.xy(7, 1)); builder.add(tableScrollPane, cc.xy(1, 3)); builder.add(fieldScrollPane, cc.xy(3, 3)); builder.add(outerMiddlePanel.getPanel(), cc.xy(5, 3)); builder.add(mapScrollPane, cc.xy(7, 3)); builder.add(upDownPanel.getPanel(), cc.xy(9, 3)); mainLayoutPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JPanel megaPanel = new JPanel(new BorderLayout()); megaPanel.add(mainLayoutPanel, BorderLayout.CENTER); descriptionLbl = createLabel(" ", SwingConstants.LEFT); //PanelBuilder descBuilder = new PanelBuilder(new FormLayout("f:p:g, 3dlu","p")); //descBuilder.add(descriptionLbl, cc.xy(1, 1)); //megaPanel.add(descBuilder.getPanel(), BorderLayout.SOUTH); megaPanel.add(descriptionLbl, BorderLayout.SOUTH); //contentPanel = mainLayoutPanel; contentPanel = megaPanel; Color bgColor = btnPanel.getBackground(); int inc = 16; btnPanelColor = new Color(Math.min(255, bgColor.getRed() + inc), Math.min(255, bgColor.getGreen() + inc), Math.min(255, bgColor.getBlue() + inc)); btnPanel.setBackground(btnPanelColor); btnPanel.setBorder(BorderFactory.createEmptyBorder(4, 6, 4, 6)); okBtn.setEnabled(false); HelpMgr.registerComponent(helpBtn, helpContext); if (dataFileInfo != null) { autoMapFromDataFile(dataFileInfo.getColInfo()); } if (workbenchTemplate != null) { fillFromTemplate(); setChanged(false); } mainPanel.add(contentPanel, BorderLayout.CENTER); if (dataFileInfo == null) //can't add new mappings when importing. { FieldMappingPanel fmp = addMappingItem(null, IconManager.getIcon("BlankIcon", IconManager.STD_ICON_SIZE), null); fmp.setAdded(true); fmp.setNew(true); } pack(); SwingUtilities.invokeLater(new Runnable() { @SuppressWarnings("synthetic-access") public void run() { cancelBtn.requestFocus(); fieldModel.clear(); fieldList.clearSelection(); updateFieldDescription(); updateEnabledState(); if (mapModel.size() > 1) { mapList.clearSelection(); } } }); }
From source file:net.sf.firemox.DeckBuilder.java
/** * Creates new form DeckBuilder/*from w w w . ja v a 2 s .c om*/ */ private DeckBuilder() { super("DeckBuilder"); form = this; timerPanel = new TimerGlassPane(); cardLoader = new CardLoader(timerPanel); timer = new Timer(200, cardLoader); setGlassPane(timerPanel); try { setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif")); } catch (Exception e) { // IGNORING } // Load settings loadSettings(); // Initialize components final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this); newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this); loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this); saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0)); final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this); quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK)); final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this); deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this); aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK)); final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this); final JMenu mainMenu = UIHelper.buildMenu("menu_file"); mainMenu.add(newItem); mainMenu.add(loadItem); mainMenu.add(saveAsItem); mainMenu.add(saveItem); mainMenu.add(new JSeparator()); mainMenu.add(quitItem); super.optionMenu = new JMenu("Options"); final JMenu convertMenu = UIHelper.buildMenu("menu_convert"); convertMenu.add(convertDCK); final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this); helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); final JMenu helpMenu = new JMenu("?"); helpMenu.add(helpItem); helpMenu.add(deckConstraintsItem); helpMenu.add(aboutItem); final JMenuBar menuBar = new JMenuBar(); menuBar.add(mainMenu); initAbstractMenu(); menuBar.add(optionMenu); menuBar.add(convertMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); addWindowListener(this); // Build the panel containing amount of available cards final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT); // Build the left list allListModel = new MListModel<MCardCompare>(amountLeft, false); leftList = new ThreadSafeJList(allListModel); leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); leftList.setLayoutOrientation(JList.VERTICAL); leftList.getSelectionModel().addListSelectionListener(this); leftList.addMouseListener(this); leftList.setVisibleRowCount(10); // Initialize the text field containing the amount to add addQtyTxt = new JTextField("1"); // Build the "Add" button addButton = new JButton(LanguageManager.getString("db_add")); addButton.setMnemonic('a'); addButton.setEnabled(false); // Build the panel containing : "Add" amount and "Add" button final Box addPanel = Box.createHorizontalBox(); addPanel.add(addButton); addPanel.add(addQtyTxt); addPanel.setMaximumSize(new Dimension(32010, 26)); // Build the panel containing the selected card name cardNameTxt = new JTextField(); new HireListener(cardNameTxt, addButton, this, leftList); final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : "); searchLabel.setLabelFor(cardNameTxt); // Build the panel containing search label and card name text field final Box searchPanel = Box.createHorizontalBox(); searchPanel.add(searchLabel); searchPanel.add(cardNameTxt); searchPanel.setMaximumSize(new Dimension(32010, 26)); listScrollerLeft = new JScrollPane(leftList); MToolKit.addOverlay(listScrollerLeft); // Build the left panel containing : list, available amount, "Add" panel final JPanel srcPanel = new JPanel(null); srcPanel.add(searchPanel); srcPanel.add(listScrollerLeft); srcPanel.add(amountLeft); srcPanel.add(addPanel); srcPanel.setMinimumSize(new Dimension(220, 200)); srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS)); // Initialize constraints constraintsChecker = new ConstraintsChecker(); constraintsChecker.setBorder(new EtchedBorder()); final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker); MToolKit.addOverlay(constraintsCheckerScroll); // create a pane with the oracle text for the present card oracleText = new JLabel(); oracleText.setPreferredSize(new Dimension(180, 200)); oracleText.setVerticalAlignment(SwingConstants.TOP); final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(oracle); // build some Pie Charts and a panel to display it initSets(); datasets = new ChartSets(); final JTabbedPane tabbedPane = new JTabbedPane(); for (ChartFilter filter : ChartFilter.values()) { final Dataset dataSet = filter.createDataSet(this); final JFreeChart chart = new JFreeChart(null, null, filter.createPlot(dataSet, painterMapper.get(filter)), false); datasets.addDataSet(filter, dataSet); ChartPanel pieChartPanel = new ChartPanel(chart, true); tabbedPane.add(pieChartPanel, filter.getTitle()); } // add the Constraints scroll panel and Oracle text Pane to the tabbedPane tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints")); tabbedPane.add(oracle, LanguageManager.getString("db_text")); tabbedPane.setSelectedComponent(oracle); // The toollBar for color filtering toolBar = new JToolBar(); toolBar.setFloatable(false); final JButton clearButton = UIHelper.buildButton("clear"); clearButton.addActionListener(this); toolBar.add(clearButton); final JToggleButton toggleColorlessButton = new JToggleButton( UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true); toggleColorlessButton.setActionCommand("0"); toggleColorlessButton.addActionListener(this); toolBar.add(toggleColorlessButton); for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) { final JToggleButton toggleButton = new JToggleButton( UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true); toggleButton.setActionCommand(String.valueOf(index)); toggleButton.addActionListener(this); toolBar.add(toggleButton); } // sorted card type combobox creation final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames)); Collections.sort(idCards); final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") }, idCards.toArray()); idCardComboBox = new JComboBox(cardTypes); idCardComboBox.setSelectedIndex(0); idCardComboBox.addActionListener(this); idCardComboBox.setActionCommand("cardTypeFilter"); // sorted card properties combobox creation final List<String> properties = new ArrayList<String>( CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty())); Collections.sort(properties); final Object[] cardProperties = ArrayUtils .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray()); propertiesComboBox = new JComboBox(cardProperties); propertiesComboBox.setSelectedIndex(0); propertiesComboBox.addActionListener(this); propertiesComboBox.setActionCommand("propertyFilter"); final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : "); final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : "); final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : "); // filter Panel with colors toolBar and card type combobox final Box filterPanel = Box.createHorizontalBox(); filterPanel.add(colors); filterPanel.add(toolBar); filterPanel.add(types); filterPanel.add(idCardComboBox); filterPanel.add(property); filterPanel.add(propertiesComboBox); getContentPane().add(filterPanel, BorderLayout.NORTH); // Destination section : // Build the panel containing amount of available cards final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT); rightAmount.setMaximumSize(new Dimension(220, 26)); // Build the right list rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true)); rightListModel.addTableModelListener(this); rightList = new JTable(rightListModel); rightList.setShowGrid(false); rightList.setTableHeader(null); rightList.getSelectionModel().addListSelectionListener(this); rightList.getColumnModel().getColumn(0).setMaxWidth(25); rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); // Build the panel containing the selected deck deckNameTxt = new JTextField("loading..."); deckNameTxt.setEditable(false); deckNameTxt.setBorder(null); final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : "); deckLabel.setLabelFor(deckNameTxt); final Box deckNamePanel = Box.createHorizontalBox(); deckNamePanel.add(deckLabel); deckNamePanel.add(deckNameTxt); deckNamePanel.setMaximumSize(new Dimension(220, 26)); // Initialize the text field containing the amount to remove removeQtyTxt = new JTextField("1"); // Build the "Remove" button removeButton = new JButton(LanguageManager.getString("db_remove")); removeButton.setMnemonic('r'); removeButton.addMouseListener(this); removeButton.setEnabled(false); // Build the panel containing : "Remove" amount and "Remove" button final Box removePanel = Box.createHorizontalBox(); removePanel.add(removeButton); removePanel.add(removeQtyTxt); removePanel.setMaximumSize(new Dimension(220, 26)); // Build the right panel containing : list, available amount, constraints final JScrollPane deskListScroller = new JScrollPane(rightList); MToolKit.addOverlay(deskListScroller); deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY)); deskListScroller.setMinimumSize(new Dimension(220, 200)); deskListScroller.setMaximumSize(new Dimension(220, 32000)); final Box destPanel = Box.createVerticalBox(); destPanel.add(deckNamePanel); destPanel.add(deskListScroller); destPanel.add(rightAmount); destPanel.add(removePanel); destPanel.setMinimumSize(new Dimension(220, 200)); destPanel.setMaximumSize(new Dimension(220, 32000)); // Build the panel containing the name of card in picture cardPictureNameTxt = new JLabel("<html><i>no selected card</i>"); final Box cardPictureNamePanel = Box.createHorizontalBox(); cardPictureNamePanel.add(cardPictureNameTxt); cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26)); // Group the detail panels final JPanel viewCard = new JPanel(null); viewCard.add(cardPictureNamePanel); viewCard.add(CardView.getInstance()); viewCard.add(tabbedPane); viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS)); final Box mainPanel = Box.createHorizontalBox(); mainPanel.add(destPanel); mainPanel.add(viewCard); // Add the main panel getContentPane().add(srcPanel, BorderLayout.WEST); getContentPane().add(mainPanel, BorderLayout.CENTER); // Size this frame getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT)); getRootPane().setMinimumSize(getRootPane().getPreferredSize()); pack(); }
From source file:es.ubu.XRayDetector.interfaz.PanelAplicacion.java
/** * Gets the image results panel./* ww w . j a va 2s . co m*/ * * @param panelTabla Results table panel */ public void getTablaResultados(JPanel panelTabla) { tablaResultados = new JTable(); tablaResultados.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Regi\u00F3n", "\u00C1rea", "Per\u00EDmetro", "Circularidad", "Redondez", "Semieje Mayor", "Semieje Menor", "\u00C1ngulo", "Distancia Feret" }) { private static final long serialVersionUID = 1L; @SuppressWarnings("rawtypes") Class[] columnTypes = new Class[] { Integer.class, Double.class, Double.class, Double.class, Double.class, Double.class, Double.class, Double.class, Double.class }; @SuppressWarnings({ "unchecked", "rawtypes" }) public Class getColumnClass(int columnIndex) { return columnTypes[columnIndex]; } @Override public boolean isCellEditable(int row, int column) { return false; } }); resizeColumnas(); tablaResultados.setEnabled(false); tablaResultados.setRowSelectionAllowed(true); tablaResultados.addMouseListener(new TableMouseListener()); panelTabla_1.setLayout(null); JScrollPane scrlPane = new JScrollPane(tablaResultados); scrlPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrlPane.setBounds(10, 21, 730, 141); panelTabla.add(scrlPane); imgPanel.setTablaResultados(tablaResultados); }
From source file:org.onesun.sdi.swing.app.views.DataServicesView.java
private void addControlsToPanel() { dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); dataTable.setAutoscrolls(true);/* w w w .jav a2 s . co m*/ JPanel panel = null; panel = new JPanel(new SpringLayout()); panel.add(copyDataButton); SpringLayoutUtils.makeCompactGrid(panel, 1, 1, 5, 5, 5, 5); this.add(panel); panel = new JPanel(new SpringLayout()); panel.add(containerPanel); SpringLayoutUtils.makeCompactGrid(panel, 1, 1, 5, 5, 5, 5); this.add(panel); panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); panel.add(executeButton); panel.add(computeMetricsButton); this.add(panel); panel = new JPanel(new SpringLayout()); JLabel label = new JLabel("Enriched Data", JLabel.LEADING); label.setPreferredSize(new Dimension(150, 24)); scrollPane.setPreferredSize(new Dimension(250, 900)); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(label); label.setLabelFor(scrollPane); panel.add(scrollPane); SpringLayoutUtils.makeCompactGrid(panel, 2, 1, 5, 5, 5, 5); this.add(panel); panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(rowCountLabel); this.add(panel); }