List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color)
From source file:edu.ku.brc.specify.tasks.subpane.LocalityMapperSubPane.java
/** * *//*from ww w . j ava2 s . co m*/ protected void createUI() { kmlGen = new CollectingEventLocalityKMLGenerator(); this.collectingEvents = new ArrayList<CollectingEvent>(); CollectingEvent startCE = null; CollectingEvent endCE = null; Vector<Locality> localities = new Vector<Locality>(); Vector<String> labels = new Vector<String>(); for (Object obj : colEvents) { CollectingEvent collectingEvent = (CollectingEvent) obj; Locality locality = collectingEvent.getLocality(); if (locality == null || locality.getLatitude1() == null || locality.getLongitude1() == null) { continue; } collectingEvents.add(collectingEvent); kmlGen.addDataObj(collectingEvent, ""); if (collectingEvents.size() == 1) { startCE = collectingEvent; endCE = collectingEvent; } // XXX TODO FIX ME! if (startCE == null || endCE == null) { return; } // There may be an End Date that is further out than than the End Date of the last item // with the latest Start Date if (startCE.getStartDate().compareTo(collectingEvent.getStartDate()) > 1) { startCE = collectingEvent; } Calendar leftCal = endCE.getEndDate() != null ? endCE.getEndDate() : endCE.getStartDate(); Calendar rightCal = collectingEvent.getEndDate() != null ? collectingEvent.getEndDate() : collectingEvent.getStartDate(); if (leftCal.compareTo(rightCal) < 0) { endCE = collectingEvent; } Hashtable<String, Object> map = new Hashtable<String, Object>(); Set<CollectionObject> colObjs = collectingEvent.getCollectionObjects(); map.put("startDate", collectingEvent.getStartDate()); map.put("endDate", collectingEvent.getEndDate()); Set<Object> taxonNames = new HashSet<Object>(); for (CollectionObject co : colObjs) { for (Determination d : co.getDeterminations()) { if (d.isCurrentDet()) { //System.out.println(d.getTaxon().getName() + "("+co.getCountAmt()+")"); Taxon taxon = d.getPreferredTaxon(); if (taxon != null) { taxonNames.add(taxon.getName() + (co.getCountAmt() != null ? " (" + co.getCountAmt() + ")" : "")); if (taxon.getRankId() == 220) { Taxon genus = taxon.getParent(); if (genus.getRankId() == 180) { ImageGetter imgGetter = new ImageGetter(imageGetterList, imageMap, imageURLs, genus.getName(), taxon.getName()); imageGetterList.add(imgGetter); } } } break; } } } map.put("taxonItems", taxonNames); map.put("latitude1", locality.getLatitude1()); map.put("longitude1", locality.getLongitude1()); /* Calendar cal = collectingEvent.getStartDate(); if (cal != null) { labels.add(scrDateFormat.format(cal.getTime())); } else if (collectingEvent.getVerbatimDate() != null) { labels.add(collectingEvent.getVerbatimDate()); } else { labels.add(Integer.toString(collectingEvent.getCollectingEventId())); } */ labels.add(Integer.toString(collectingEvents.size())); localities.add(locality); valueList.add(map); } // XXX Fix me shouldn't be hard coded here to make it work localityMapper.setMaxMapWidth(515); localityMapper.setMaxMapHeight(375); Color arrow = new Color(220, 220, 220); localityMapper.setArrowColor(arrow); localityMapper.setDotColor(Color.WHITE); localityMapper.setDotSize(4); localityMapper.setLabelColor(Color.RED); int inx = 0; for (Locality locality : localities) { localityMapper.addLocationAndLabel(locality, labels != null ? labels.get(inx) : null); inx++; } localityMapper.setCurrentLoc(localities.get(0)); localityMapper.setCurrentLocColor(Color.RED); // XXX DEMO (Hard Coded 'null' means everyone would have one which may not be true) // "null" ViewSet name means it should use the default ViewIFace view = AppContextMgr.getInstance().getView("LocalityMapper"); // TODO WHERE's the ERROR checking ! multiView = new MultiView(null, null, view, AltViewIFace.CreationMode.VIEW, MultiView.NO_OPTIONS); multiView.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(138, 128, 128)), BorderFactory.createEmptyBorder(4, 4, 4, 4))); formViewObj = multiView.getCurrentViewAsFormViewObj(); formViewObj.getUIComponent().setBackground(Color.WHITE); imageJList = formViewObj.getCompById("taxonItems"); imageJList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { String nameStr = (String) imageJList.getSelectedValue(); if (nameStr != null) { int index = nameStr.indexOf(" ("); if (index > -1) { nameStr = nameStr.substring(0, index); } } //System.out.println("Getting["+name+"]"); Image img = null; if (StringUtils.isNotEmpty(nameStr)) { img = imageMap.get(nameStr); // might return null ImageDisplay imgDisplay = formViewObj.getCompById("image"); if (img != null) { imgDisplay.setImage(new ImageIcon(img)); } else { imgDisplay.setImage((Image) null); } } } } }); // XXX TODO FIX ME! if (startCE == null || endCE == null) { return; } String startDateStr = scrDateFormat.format(startCE.getStartDate().getTime()); String endDateStr = scrDateFormat .format((endCE.getEndDate() != null ? endCE.getEndDate() : endCE.getStartDate()).getTime()); Formatter formatter = new Formatter(); titleLabel.setText(formatter .format(getResourceString("LocalityMapperTitle"), new Object[] { startDateStr, endDateStr }) .toString()); Font font = titleLabel.getFont(); titleLabel.setFont(new Font(font.getFontName(), Font.BOLD, font.getSize() + 2)); recordSetController = new ResultSetController(null, false, false, false, null, collectingEvents.size(), true); recordSetController.addListener(this); recordSetController.getPanel().setBackground(Color.WHITE); controlPanel = new ControlBarPanel(getBackground()); controlPanel.add(recordSetController.getPanel()); controlPanel.setRecordSetController(recordSetController); controlPanel.setBackground(Color.WHITE); googleBtn = new JButton(IconManager.getIcon("GoogleEarth", IconManager.STD_ICON_SIZE)); googleBtn.setMargin(new Insets(1, 1, 1, 1)); googleBtn.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); googleBtn.setSize(new Dimension(18, 18)); googleBtn.setPreferredSize(new Dimension(18, 18)); googleBtn.setMaximumSize(new Dimension(18, 18)); googleBtn.setFocusable(false); googleBtn.setBackground(Color.WHITE); controlPanel.addButtons(new JButton[] { googleBtn }, false); googleBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { UIRegistry.displayStatusBarText("Exporting Collecting Events in KML."); // XXX I18N kmlGen.setSpeciesToImageMapper(imageURLs); kmlGen.outputToFile(System.getProperty("user.home") + File.separator + "specify.kml"); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LocalityMapperSubPane.class, ex); ex.printStackTrace(); } } }); addMouseMotionListener(new MouseMotionListener() { public void mouseDragged(MouseEvent e) { // nothing } public void mouseMoved(MouseEvent e) { checkMouseLocation(e.getPoint(), false); } }); addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { checkMouseLocation(e.getPoint(), true); } }); SwingUtilities.invokeLater(new Runnable() { public void run() { getLocalityMap(); } }); }
From source file:edu.ku.brc.specify.ui.DBObjSearchPanel.java
/** * Creates the Default UI./*from ww w. j ava 2 s. c o m*/ * */ public void createUI() { panel = new JPanel(new BorderLayout()); add(panel, BorderLayout.CENTER); panel.setPreferredSize(new Dimension(300, 200)); panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0), BorderFactory.createLineBorder(Color.BLACK))); }
From source file:org.jfree.chart.demo.SuperDemo.java
private JPanel createChartDisplayPanel() { displayPanel = new JPanel(new BorderLayout()); chartContainer = new JPanel(new BorderLayout()); chartContainer.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); chartContainer.add(createNoDemoSelectedPanel()); descriptionContainer = new JPanel(new BorderLayout()); descriptionContainer.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); descriptionContainer.setPreferredSize(new Dimension(600, 140)); descriptionPane = new JTextPane(); descriptionPane.setEditable(false);/*from w ww . j ava 2s. com*/ JScrollPane jscrollpane = new JScrollPane(descriptionPane, 20, 31); descriptionContainer.add(jscrollpane); displayDescription("select.html"); JSplitPane jsplitpane = new JSplitPane(0); jsplitpane.setTopComponent(chartContainer); jsplitpane.setBottomComponent(descriptionContainer); displayPanel.add(jsplitpane); jsplitpane.setDividerLocation(0.75D); return displayPanel; }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatPanel.java
/** * Sets the chat session to associate to this chat panel. * @param chatSession the chat session to associate to this chat panel *//* w w w . ja va 2s. c om*/ public void setChatSession(ChatSession chatSession) { if (this.chatSession != null) { // remove old listener this.chatSession.removeChatTransportChangeListener(this); } this.chatSession = chatSession; this.chatSession.addChatTransportChangeListener(this); if ((this.chatSession != null) && this.chatSession.isContactListSupported()) { topPanel.remove(conversationPanelContainer); TransparentPanel rightPanel = new TransparentPanel(new BorderLayout()); Dimension chatConferencesListsPanelSize = new Dimension(150, 25); Dimension chatContactsListsPanelSize = new Dimension(150, 175); Dimension rightPanelSize = new Dimension(150, 200); rightPanel.setMinimumSize(rightPanelSize); rightPanel.setPreferredSize(rightPanelSize); TransparentPanel contactsPanel = new TransparentPanel(new BorderLayout()); contactsPanel.setMinimumSize(chatContactsListsPanelSize); contactsPanel.setPreferredSize(chatContactsListsPanelSize); conferencePanel.setMinimumSize(chatConferencesListsPanelSize); conferencePanel.setPreferredSize(chatConferencesListsPanelSize); this.chatContactListPanel = new ChatRoomMemberListPanel(this); this.chatContactListPanel.setOpaque(false); topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); topSplitPane.setBorder(null); // remove default borders topSplitPane.setOneTouchExpandable(true); topSplitPane.setOpaque(false); topSplitPane.setResizeWeight(1.0D); Color msgNameBackground = Color.decode(ChatHtmlUtils.MSG_NAME_BACKGROUND); // add border to the divider if (topSplitPane.getUI() instanceof BasicSplitPaneUI) { ((BasicSplitPaneUI) topSplitPane.getUI()).getDivider() .setBorder(BorderFactory.createLineBorder(msgNameBackground)); } ChatTransport chatTransport = chatSession.getCurrentChatTransport(); JPanel localUserLabelPanel = new JPanel(new BorderLayout()); JLabel localUserLabel = new JLabel(chatTransport.getProtocolProvider().getAccountID().getDisplayName()); localUserLabel.setFont(localUserLabel.getFont().deriveFont(Font.BOLD)); localUserLabel.setHorizontalAlignment(SwingConstants.CENTER); localUserLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 3, 0)); localUserLabel.setForeground(Color.decode(ChatHtmlUtils.MSG_IN_NAME_FOREGROUND)); localUserLabelPanel.add(localUserLabel, BorderLayout.CENTER); localUserLabelPanel.setBackground(msgNameBackground); JButton joinConference = new JButton( GuiActivator.getResources().getI18NString("service.gui.JOIN_VIDEO")); joinConference.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { showChatConferenceDialog(); } }); contactsPanel.add(localUserLabelPanel, BorderLayout.NORTH); contactsPanel.add(chatContactListPanel, BorderLayout.CENTER); conferencePanel.add(joinConference, BorderLayout.CENTER); rightPanel.add(conferencePanel, BorderLayout.NORTH); rightPanel.add(contactsPanel, BorderLayout.CENTER); topSplitPane.setLeftComponent(conversationPanelContainer); topSplitPane.setRightComponent(rightPanel); topPanel.add(topSplitPane); } else { if (topSplitPane != null) { if (chatContactListPanel != null) { topSplitPane.remove(chatContactListPanel); chatContactListPanel = null; } this.messagePane.remove(topSplitPane); topSplitPane = null; } topPanel.add(conversationPanelContainer); } if (chatSession instanceof MetaContactChatSession) { // The subject panel is added here, because it's specific for the // multi user chat and is not contained in the single chat chat panel. if (subjectPanel != null) { this.remove(subjectPanel); subjectPanel = null; this.revalidate(); this.repaint(); } writeMessagePanel.initPluginComponents(); writeMessagePanel.setTransportSelectorBoxVisible(true); //Enables to change the protocol provider by simply pressing the // CTRL-P key combination ActionMap amap = this.getActionMap(); amap.put("ChangeProtocol", new ChangeTransportAction()); InputMap imap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK), "ChangeProtocol"); } else if (chatSession instanceof ConferenceChatSession) { ConferenceChatSession confSession = (ConferenceChatSession) chatSession; writeMessagePanel.setTransportSelectorBoxVisible(false); confSession.addLocalUserRoleListener(this); confSession.addMemberRoleListener(this); ChatRoom room = ((ChatRoomWrapper) chatSession.getDescriptor()).getChatRoom(); room.addMemberPropertyChangeListener(this); setConferencesPanelVisible(room.getCachedConferenceDescriptionSize() > 0); subjectPanel = new ChatRoomSubjectPanel((ConferenceChatSession) chatSession); // The subject panel is added here, because it's specific for the // multi user chat and is not contained in the single chat chat panel. this.add(subjectPanel, BorderLayout.NORTH); this.revalidate(); this.repaint(); } if (chatContactListPanel != null) { // Initialize chat participants' panel. Iterator<ChatContact<?>> chatParticipants = chatSession.getParticipants(); while (chatParticipants.hasNext()) chatContactListPanel.addContact(chatParticipants.next()); } }
From source file:com.edduarte.protbox.ui.windows.RestoreFileWindow.java
private RestoreFileWindow(final PReg registry) { super();/*from w w w .ja v a2 s . c o m*/ setLayout(null); final JTextField searchField = new JTextField(); searchField.setLayout(null); searchField.setBounds(2, 2, 301, 26); searchField.setBorder(new LineBorder(Color.lightGray)); searchField.setFont(Constants.FONT); add(searchField); final JLabel noBackupFilesLabel = new JLabel("<html>No backups files were found!<br><br>" + "<font color=\"gray\">If you think there is a problem with the<br>" + "backup system, please create an issue here:<br>" + "<a href=\"#\">https://github.com/com.edduarte/protbox/issues</a></font></html>"); noBackupFilesLabel.setLayout(null); noBackupFilesLabel.setBounds(20, 50, 300, 300); noBackupFilesLabel.setFont(Constants.FONT.deriveFont(14f)); noBackupFilesLabel.addMouseListener((OnMouseClick) e -> { String urlPath = "https://github.com/com.edduarte/protbox/issues"; try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(new URI(urlPath)); } else { if (SystemUtils.IS_OS_WINDOWS) { Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + urlPath); } else { java.util.List<String> browsers = Lists.newArrayList("firefox", "opera", "safari", "mozilla", "chrome"); for (String browser : browsers) { if (Runtime.getRuntime().exec(new String[] { "which", browser }).waitFor() == 0) { Runtime.getRuntime().exec(new String[] { browser, urlPath }); break; } } } } } catch (Exception ex) { ex.printStackTrace(); } }); DefaultMutableTreeNode rootTreeNode = registry.buildEntryTree(); final JTree tree = new JTree(rootTreeNode); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); if (rootTreeNode.getChildCount() == 0) { searchField.setEnabled(false); add(noBackupFilesLabel); } expandTree(tree); tree.setLayout(null); tree.setRootVisible(false); tree.setEditable(false); tree.setCellRenderer(new SearchableTreeCellRenderer(searchField)); searchField.addKeyListener((OnKeyReleased) e -> { // update and expand tree DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); model.nodeStructureChanged((TreeNode) model.getRoot()); expandTree(tree); }); final JScrollPane scroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setBorder(new DropShadowBorder()); scroll.setBorder(new LineBorder(Color.lightGray)); scroll.setBounds(2, 30, 334, 360); add(scroll); JLabel close = new JLabel(new ImageIcon(Constants.getAsset("close.png"))); close.setLayout(null); close.setBounds(312, 7, 18, 18); close.setFont(Constants.FONT); close.setForeground(Color.gray); close.addMouseListener((OnMouseClick) e -> dispose()); add(close); final JLabel permanentDeleteButton = new JLabel(new ImageIcon(Constants.getAsset("permanent.png"))); permanentDeleteButton.setLayout(null); permanentDeleteButton.setBounds(91, 390, 40, 39); permanentDeleteButton.setBackground(Color.black); permanentDeleteButton.setEnabled(false); permanentDeleteButton.addMouseListener((OnMouseClick) e -> { if (permanentDeleteButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (JOptionPane.showConfirmDialog(null, "Are you sure you wish to permanently delete '" + entry.realName() + "'?\nThis file and its " + "backup copies will be deleted immediately. You cannot undo this action.", "Confirm Cancel", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { registry.permanentDelete(entry); dispose(); RestoreFileWindow.getInstance(registry); } else { setVisible(true); } } }); add(permanentDeleteButton); final JLabel configBackupsButton = new JLabel(new ImageIcon(Constants.getAsset("config.png"))); configBackupsButton.setLayout(null); configBackupsButton.setBounds(134, 390, 40, 39); configBackupsButton.setBackground(Color.black); configBackupsButton.setEnabled(false); configBackupsButton.addMouseListener((OnMouseClick) e -> { if (configBackupsButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; JFrame frame = new JFrame("Choose backup policy"); Object option = JOptionPane.showInputDialog(frame, "Choose below the backup policy for this file:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, PbxFile.BackupPolicy.values(), pbxFile.getBackupPolicy()); if (option == null) { setVisible(true); return; } PbxFile.BackupPolicy pickedPolicy = PbxFile.BackupPolicy.valueOf(option.toString()); pbxFile.setBackupPolicy(pickedPolicy); } setVisible(true); } }); add(configBackupsButton); final JLabel restoreBackupButton = new JLabel(new ImageIcon(Constants.getAsset("restore.png"))); restoreBackupButton.setLayout(null); restoreBackupButton.setBounds(3, 390, 85, 39); restoreBackupButton.setBackground(Color.black); restoreBackupButton.setEnabled(false); restoreBackupButton.addMouseListener((OnMouseClick) e -> { if (restoreBackupButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFolder) { registry.restoreFolderFromEntry((PbxFolder) entry); } else if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; java.util.List<String> snapshots = pbxFile.snapshotsToString(); if (snapshots.isEmpty()) { setVisible(true); return; } JFrame frame = new JFrame("Choose backup"); Object option = JOptionPane.showInputDialog(frame, "Choose below what backup snapshot would you like restore:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, snapshots.toArray(), snapshots.get(0)); if (option == null) { setVisible(true); return; } int pickedIndex = snapshots.indexOf(option.toString()); registry.restoreFileFromEntry((PbxFile) entry, pickedIndex); } dispose(); } }); add(restoreBackupButton); tree.addMouseListener((OnMouseClick) e -> { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { PbxEntry entry = (PbxEntry) node.getUserObject(); if ((entry instanceof PbxFolder && entry.areNativeFilesDeleted())) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(false); } else if (entry instanceof PbxFile) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(true); } else { permanentDeleteButton.setEnabled(false); restoreBackupButton.setEnabled(false); configBackupsButton.setEnabled(false); } } }); final JLabel cancel = new JLabel(new ImageIcon(Constants.getAsset("cancel.png"))); cancel.setLayout(null); cancel.setBounds(229, 390, 122, 39); cancel.setBackground(Color.black); cancel.addMouseListener((OnMouseClick) e -> dispose()); add(cancel); addWindowFocusListener(new WindowFocusListener() { private boolean gained = false; @Override public void windowGainedFocus(WindowEvent e) { gained = true; } @Override public void windowLostFocus(WindowEvent e) { if (gained) { dispose(); } } }); setSize(340, 432); setUndecorated(true); getContentPane().setBackground(Color.white); setResizable(false); getRootPane().setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100))); Utils.setComponentLocationOnCenter(this); setVisible(true); }
From source file:edu.ku.brc.ui.CustomDialog.java
/** * Create the UI for the dialog.// ww w . j av a 2 s. c o m */ public void createUI() { isCreated = true; /*if (helpContext == null) { whichBtns &= ~HELP_BTN; // Clear Bit for Help button if there is no HelpContext }*/ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); mainPanel = createMainPanel(); mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 5, 2)); if (titleBarLabel != null) { mainPanel.add(titleBarLabel, BorderLayout.NORTH); mainPanel.setBorder(BorderFactory.createLineBorder(borderColor)); } if (contentPanel != null) { mainPanel.add(contentPanel, BorderLayout.CENTER); } // Bottom Button UI createButtons(); getRootPane().setDefaultButton(findDefaultBtn()); JPanel bb = buildButtonBar(); if (extraBtn != null) { PanelBuilder builder = new PanelBuilder(new FormLayout("p,f:p:g", "p")); CellConstraints cc = new CellConstraints(); builder.add(extraBtn, cc.xy(1, 1)); builder.add(bb, cc.xy(2, 1)); builder.getPanel().setOpaque(false); bb = builder.getPanel(); } if (bb != null) { bb.setOpaque(false); Component bbComp = bb; if (UIHelper.getOSType() == UIHelper.OSTYPE.MacOSX) // adjust for intruding resizer on Mac OS X { PanelBuilder builder = new PanelBuilder(new FormLayout("p:g,15px", "p")); CellConstraints cc = new CellConstraints(); builder.add(bb, cc.xy(1, 1)); builder.getPanel().setOpaque(false); bbComp = builder.getPanel(); } mainPanel.add(bbComp, BorderLayout.SOUTH); } setContentPane(mainPanel); pack(); setLocationRelativeTo(this.getOwner()); }
From source file:org.nuxeo.launcher.gui.NuxeoFrame.java
/** * @param logFile/*from w w w . ja v a 2 s . c o m*/ */ protected JComponent buildLogPanel(String logFile) { ColoredTextPane textArea = new ColoredTextPane(); textArea.setEditable(false); textArea.setAutoscrolls(true); textArea.setBackground(new Color(54, 55, 67)); textArea.setMaxSize(LOG_MAX_SIZE); JScrollPane logsScroller = new JScrollPane(textArea); logsScroller.setVisible(true); logsScroller.setBorder(BorderFactory.createLineBorder(Color.BLACK)); logsScroller.setAutoscrolls(true); logsScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); logsScroller.setWheelScrollingEnabled(true); logsScroller.setPreferredSize(new Dimension(450, 160)); controller.initLogsManagement(logFile, textArea); logsScroller.addComponentListener(new LogsPanelListener(logFile)); return logsScroller; }
From source file:edu.ku.brc.specify.utilapps.ERDTable.java
/** * @param font/*from w w w . ja va 2 s . c o m*/ */ public void build(final Font font) { int numRows = 7; switch (displayType) { case All: numRows = 7; break; case MainFields: numRows = 7; break; case Title: numRows = 1; break; case TitleAndRel: numRows = 4; break; } Font bold = new Font(font.getFamily(), Font.BOLD, font.getSize()); Font italic = new Font(font.getFamily(), Font.ITALIC, font.getSize()); PanelBuilder pb = new PanelBuilder( new FormLayout("f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", numRows))); CellConstraints cc = new CellConstraints(); String className = StringUtils.substringAfterLast(table.getClassName(), "."); DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByShortClassName(className); if (tblInfo == null) { throw new RuntimeException("Couldn't find table for className[" + className + "]"); } String tblName = tblInfo.getTitle(); int y = 1; pb.add(ERDVisualizer.mkLabel(bold, tblName, SwingConstants.CENTER), cc.xy(1, y)); y += 2; boolean doingAll = displayType == DisplayType.All; if (displayType == DisplayType.All || displayType == DisplayType.MainFields) { pb.addSeparator("", cc.xy(1, y)); y += 2; pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELDS"), SwingConstants.CENTER), cc.xy(1, y)); y += 2; String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px,p:g,4px" : "") + ",f:p:g"; PanelBuilder fieldsPB = new PanelBuilder(new FormLayout(colsDef, UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getFields().size() + 2))); int yy = 1; fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_FIELD"), SwingConstants.LEFT), cc.xy(1, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER), cc.xy(3, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_LENGTH"), SwingConstants.CENTER), cc.xy(5, yy)); if (doingAll) { fieldsPB.add( ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER), cc.xy(7, yy)); fieldsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_UNIQUE"), SwingConstants.CENTER), cc.xy(9, yy)); } yy += 2; if (StringUtils.isNotEmpty(table.getIdColumnName())) { build(fieldsPB, table, font, yy, doingAll); // does ID yy += 2; } for (DBFieldInfo f : table.getFields()) { build(fieldsPB, f, font, yy, doingAll); yy += 2; } pb.add(fieldsPB.getPanel(), cc.xy(1, y)); y += 2; } if ((displayType == DisplayType.All || displayType == DisplayType.TitleAndRel) && table.getRelationships().size() > 0) { pb.addSeparator("", cc.xy(1, y)); y += 2; pb.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_RELATIONSHIPS"), SwingConstants.CENTER), cc.xy(1, y)); y += 2; String colsDef = "p:g,4px,p:g,4px" + (doingAll ? ",p:g,4px" : "") + ",f:p:g"; PanelBuilder relsPB = new PanelBuilder(new FormLayout(colsDef, UIHelper.createDuplicateJGoodiesDef("p", "2px", table.getRelationships().size() + 1))); int yy = 1; relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TABLE"), SwingConstants.LEFT), cc.xy(1, yy)); relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_NAME"), SwingConstants.CENTER), cc.xy(3, yy)); relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_TYPE"), SwingConstants.CENTER), cc.xy(5, yy)); if (doingAll) { relsPB.add(ERDVisualizer.mkLabel(italic, getResourceString("ERD_REQUIRED"), SwingConstants.CENTER), cc.xy(7, yy)); } yy += 2; Vector<DBRelationshipInfo> orderedList = new Vector<DBRelationshipInfo>(table.getRelationships()); Collections.sort(orderedList, new Comparator<DBRelationshipInfo>() { public int compare(DBRelationshipInfo o1, DBRelationshipInfo o2) { String name1 = ((DBRelationshipInfo) o1).getClassName(); if (name1.startsWith("Sp")) { name1 = name1.substring(2, name1.length()); } String name2 = ((DBRelationshipInfo) o2).getClassName(); if (name2.startsWith("Sp")) { name2 = name2.substring(2, name2.length()); } return name1.compareTo(name2); } }); for (DBRelationshipInfo r : orderedList) { //System.out.println(r.getName()+" "+r.getType()); if (!r.getName().toLowerCase().endsWith("iface")) { JComponent p = build(relsPB, r, font, yy, doingAll); relUIHash.put(r, p); yy += 2; } } pb.add(relsPB.getPanel(), cc.xy(1, y)); y += 2; //fieldsPB.getPanel().setBackground(Color.GREEN); //relsPB.getPanel().setBackground(Color.BLUE); } inner = pb.getPanel(); //inner.setBorder(BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP)); inner.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(BRD_GAP, BRD_GAP, BRD_GAP, BRD_GAP))); setBackground(Color.WHITE); add(inner, BorderLayout.CENTER); }
From source file:com.att.aro.ui.view.videotab.VideoTab.java
/** * MidPanel contains Video Manifests/*from w ww . ja va 2 s .c om*/ */ private JPanel buildManifestsGroup() { JPanel pane; pane = new JPanel(new GridBagLayout()); int section = 0; videoManifestPanel = new VideoManifestPanel(overviewRoute, aroView); pane.add(videoManifestPanel, new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, noInsets, 0, 0)); bpObservable.registerObserver(videoManifestPanel); JPanel wrapper = getTitledWrapper("video.tab.manifest.title", new LoadManifestDialog(aroView)); wrapper.add(pane, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, noInsets, 0, 0)); pane.setBorder(BorderFactory.createLineBorder(Color.WHITE)); return wrapper; }
From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java
private void initUI() { setLayout(new GridBagLayout()); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); components = new ArrayList<JComponent>(); checks = new ArrayList<JCheckBox>(); int size = paramList.size(); boolean shouldExpand = false; boolean needScroll = false; for (int i = 0; i < size; i++) { final int pos = i; final QueryParameter param = paramList.get(i); if (param.isHidden()) { components.add(null);//w w w . j a v a 2 s . c o m checks.add(null); initHiddenParameterValues(param); continue; } String source = param.getSource(); String defaultSource = param.getDefaultSource(); if ((defaultSource != null) && !defaultSource.trim().equals("")) { try { param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param)); } catch (NextSqlException e) { Show.error(e); } } final JComponent component; int anchor = GridBagConstraints.WEST; double y = 0.0; int expand = GridBagConstraints.HORIZONTAL; if ((source != null) && !source.equals("")) { List<IdName> values = new ArrayList<IdName>(); try { if (param.isManualSource()) { if (!param.isDependent()) { values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy()); } } else { int index = source.indexOf("."); int index2 = source.lastIndexOf("."); String tableName = source.substring(0, index); String columnName; String shownColumnName = null; if (index == index2) { columnName = source.substring(index + 1); } else { columnName = source.substring(index + 1, index2); shownColumnName = source.substring(index2 + 1); } values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName, columnName, shownColumnName, param.getOrderBy()); } } catch (NextSqlException e) { error = true; Show.error(e); } catch (InvalidSqlException e) { String m = I18NSupport.getString("source.dialog.valid"); Show.info(m + " : \"select <exp1> , <exp2> from ...\""); } if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) { component = new JComboBox(); final JComboBox combo = (JComboBox) component; combo.setRenderer(new IdNameRenderer()); combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --"); for (int j = 0, len = values.size(); j < len; j++) { combo.addItem(values.get(j)); } combo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { IdName in = null; if (combo.getSelectedIndex() > 0) { in = (IdName) combo.getSelectedItem(); } parameterSelection(pos, in); } } }); AutoCompleteDecorator.decorate(combo); needScroll = false; } else { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; DefaultListModel model = new DefaultListModel(); for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } List srcList = Arrays.asList(model.toArray()); component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } // needed for saved parameters on rerun protected void onSetRight() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getDestinationElements().toArray(); if (values.length == 0) { values = new Object[] { ParameterUtil.NULL }; } parameterSelection(pos, values); } } }; ((ListSelectionPanel) component).setListSize(scrListDim); ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(), new IdNameComparator(param.getOrderBy())); shouldExpand = true; } } else { if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; ; component = new ListAddPanel(param) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getElements().toArray(); parameterSelection(pos, values); } } }; } else { needScroll = false; if (param.getValueClassName().equals("java.util.Date")) { component = new JXDatePicker(); ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName())) { parameterSelection(pos, ((JXDatePicker) component).getDate()); } } }); // hack to fix bug with big popup button JButton popupButton = (JButton) component.getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.sql.Timestamp") || param.getValueClassName().equals("java.sql.Time")) { component = new JDateTimePicker() { protected void onChange() { parameterSelection(pos, getDate()); } }; // hack to fix bug with big popup button JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker()) .getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.lang.Boolean")) { component = new JCheckBox(); ((JCheckBox) component).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); parameterSelection(pos, selected); } }); } else { component = new JTextField(25); ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void insertUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void removeUpdate(DocumentEvent e) { updateFromTextField(e); } private void updateFromTextField(DocumentEvent e) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { Object value = null; try { if ("".equals(((JTextField) component).getText().trim())) { value = null; } else { value = ParameterUtil.getParameterValueFromString( param.getValueClassName(), ((JTextField) component).getText()); } parameterSelection(pos, value); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } } }); } }); } } } components.add(component); final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore")); checks.add(cb); final JLabel label = new JLabel(getRuntimeParameterName(param)); panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); final JComponent addComponent; if (needScroll) { JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scr.setPreferredSize(listDim); addComponent = scr; } else { addComponent = component; } panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand, new Insets(5, 0, 5, 5), 0, 0)); int checkAnchor = GridBagConstraints.WEST; if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) { checkAnchor = GridBagConstraints.NORTHWEST; } if (Globals.getParametersIgnore()) { panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); } cb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (cb.isSelected()) { if (addComponent instanceof JScrollPane) { component.setEnabled(false); } label.setEnabled(false); addComponent.setEnabled(false); param.setIgnore(true); } else { if (addComponent instanceof JScrollPane) { component.setEnabled(true); } label.setEnabled(true); addComponent.setEnabled(true); param.setIgnore(false); } } }); } // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter) // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here for (int i = 0; i < size; i++) { final QueryParameter param = paramList.get(i); if (param.isHidden()) { populateDependentParameters(param, false); } } if (!shouldExpand) { panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrPanel.setPreferredSize(scrDim); scrPanel.setMinimumSize(scrDim); add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); setParameterValues(parametersValues); setParameterIgnore(parametersIgnore); }