List of usage examples for javax.swing JLabel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java
/** * @param parentList/*from w w w. j a v a 2 s . c o m*/ */ protected void fillNextList(final JList parentList) { if (processingLists) { return; } processingLists = true; final int curInx = listBoxList.indexOf(parentList); if (curInx > -1) { int startSize = listBoxPanel.getComponentCount(); for (int i = curInx + 1; i < listBoxList.size(); i++) { listBoxPanel.remove(spList.get(i)); } int removed = startSize - listBoxPanel.getComponentCount(); for (int i = 0; i < removed; i++) { tableTreeList.remove(tableTreeList.size() - 1); } } else { listBoxPanel.removeAll(); tableTreeList.clear(); } QryListRendererIFace item = (QryListRendererIFace) parentList.getSelectedValue(); if (item instanceof ExpandableQRI) { JList newList; DefaultListModel model; JScrollPane sp; if (curInx == listBoxList.size() - 1) { newList = new JList(model = new DefaultListModel()); newList.addMouseListener(new MouseAdapter() { /* (non-Javadoc) * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) */ @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { if (currentInx != -1) { JList list = (JList) e.getSource(); QryListRendererIFace qriFace = (QryListRendererIFace) list.getSelectedValue(); if (BaseQRI.class.isAssignableFrom(qriFace.getClass())) { BaseQRI qri = (BaseQRI) qriFace; if (qri.isInUse()) { //remove the field for (QueryFieldPanel qfp : QueryBldrPane.this.queryFieldItems) { FieldQRI fqri = qfp.getFieldQRI(); if (fqri == qri || (fqri instanceof RelQRI && fqri.getTable() == qri)) { boolean clearIt = qfp.getSchemaItem() != null; QueryBldrPane.this.removeQueryFieldItem(qfp); if (clearIt) { qfp.setField(null, null); } break; } } } else { // add the field try { FieldQRI fieldQRI = buildFieldQRI(qri); if (fieldQRI == null) { throw new Exception("null FieldQRI"); } SpQueryField qf = new SpQueryField(); qf.initialize(); qf.setFieldName(fieldQRI.getFieldName()); qf.setStringId(fieldQRI.getStringId()); query.addReference(qf, "fields"); if (!isExportMapping) { addQueryFieldItem(fieldQRI, qf, false); } else { addNewMapping(fieldQRI, qf, null, false); } } catch (Exception ex) { log.error(ex); UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance() .capture(QueryBldrPane.class, ex); return; } } } } } } }); newList.setCellRenderer(qryRenderer); listBoxList.add(newList); sp = new JScrollPane(newList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JLabel colHeader = UIHelper.createLabel(item.getTitle()); colHeader.setHorizontalAlignment(SwingConstants.CENTER); colHeader.setBackground(listBoxPanel.getBackground()); colHeader.setOpaque(true); sp.setColumnHeaderView(colHeader); spList.add(sp); newList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fillNextList(listBoxList.get(curInx + 1)); } } }); } else { newList = listBoxList.get(curInx + 1); model = (DefaultListModel) newList.getModel(); sp = spList.get(curInx + 1); JLabel colHeaderLbl = (JLabel) sp.getColumnHeader().getComponent(0); if (item instanceof TableQRI) { colHeaderLbl.setText(((TableQRI) item).getTitle()); } else { colHeaderLbl.setText(getResourceString("QueryBldrPane.QueryFields")); } } createNewList((TableQRI) item, model); listBoxPanel.remove(addBtn); listBoxPanel.add(sp); tableTreeList.add(((ExpandableQRI) item).getTableTree()); listBoxPanel.add(addBtn); currentInx = -1; } else { listBoxPanel.add(addBtn); } SwingUtilities.invokeLater(new Runnable() { public void run() { updateAddBtnState(); // Is all this really necessary listBoxPanel.validate(); listBoxPanel.repaint(); scrollPane.validate(); scrollPane.invalidate(); scrollPane.doLayout(); scrollPane.repaint(); validate(); invalidate(); doLayout(); repaint(); UIRegistry.forceTopFrameRepaint(); } }); processingLists = false; currentInx = curInx; }
From source file:org.nuclos.client.ui.collect.Chart.java
private void init(int iScrollPane) { contentPane.add(toolbar,/*from w w w . j av a 2 s. c o m*/ toolbar.getOrientation() == JToolBar.HORIZONTAL ? BorderLayout.NORTH : BorderLayout.WEST); // Configure table JFreeChart chart = new JFreeChart(new Plot() { @Override public String getPlotType() { return null; } @Override public void draw(Graphics2D arg0, Rectangle2D arg1, Point2D arg2, PlotState arg3, PlotRenderingInfo arg4) { } }); panel = new ChartPanel(chart, false, false, true, false, false); if (bFromProperties) { panel.setPopupMenu(null); } if (iScrollPane == -1) scrollPane.add(panel, BorderLayout.CENTER); else { ((JScrollPane) scrollPane).getViewport().setBackground(panel.getBackground()); JLabel labCorner = new JLabel(); labCorner.setEnabled(false); labCorner.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.GRAY)); labCorner.setBackground(Color.LIGHT_GRAY); ((JScrollPane) scrollPane).setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, labCorner); if (iScrollPane != 2) { //both if (iScrollPane == 0) { // horizontal JPanel pnl = new ScrollPaneHeightTrackingPanel(new BorderLayout()); pnl.add(panel, BorderLayout.CENTER); ((JScrollPane) scrollPane).getViewport().setView(pnl); ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); ((JScrollPane) scrollPane) .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); } else if (iScrollPane == 1) { // vertical JPanel pnl = new ScrollPaneWidthTrackingPanel(new BorderLayout()); pnl.add(panel, BorderLayout.CENTER); ((JScrollPane) scrollPane).getViewport().setView(pnl); ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); ((JScrollPane) scrollPane).setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); } else if (iScrollPane == -1) { // none ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); ((JScrollPane) scrollPane).setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); } } else { ((JScrollPane) scrollPane).getViewport().setView(panel); } } }
From source file:op.allowance.PnlAllowance.java
private JPanel createContentPanel4(final Resident resident, LocalDate month) { final String key = getKey(resident, month); if (!contentmap.containsKey(key)) { JPanel pnlMonth = new JPanel(new VerticalLayout()); pnlMonth.setBackground(getBG(resident, 11)); pnlMonth.setOpaque(false);/*from ww w . j ava 2 s .c o m*/ // final String prevKey = resident.getRID() + "-" + SYSCalendar.eom(month.minusMonths(1)).getYear() + "-" + SYSCalendar.eom(month.minusMonths(1)).getMonthOfYear(); if (!carrySums.containsKey(key)) { carrySums.put(key, AllowanceTools.getSUM(resident, SYSCalendar.eom(month.minusMonths(1)))); } BigDecimal rowsum = carrySums.get(key); if (!cashmap.containsKey(key)) { cashmap.put(key, AllowanceTools.getMonth(resident, month.toDate())); } JLabel lblEOM = new JLabel("<html><table border=\"0\">" + "<tr>" + "<td width=\"130\" align=\"left\">" + DateFormat.getDateInstance().format(month.dayOfMonth().withMaximumValue().toDate()) + "</td>" + "<td width=\"400\" align=\"left\">" + SYSTools.xx("admin.residents.cash.endofmonth") + "</td>" + "<td width=\"100\" align=\"right\"></td>" + "<td width=\"100\" align=\"right\">" + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(rowsum) + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>" + "</table>" + "</font></html>"); pnlMonth.add(lblEOM); for (final Allowance allowance : cashmap.get(key)) { String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"130\" align=\"left\">" + DateFormat.getDateInstance().format(allowance.getPit()) + "</td>" + "<td width=\"400\" align=\"left\">" + allowance.getText() + "</td>" + "<td width=\"100\" align=\"right\">" + (allowance.getAmount().compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(allowance.getAmount()) + (allowance.getAmount().compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "<td width=\"100\" align=\"right\">" + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(rowsum) + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>" + "</table>" + "</font></html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { } }); cptitle.getButton().setIcon( allowance.isReplaced() || allowance.isReplacement() ? SYSConst.icon22eraser : null); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /*** * _____ _ _ _ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__| * */ final JButton btnEdit = new JButton(SYSConst.icon22edit3); btnEdit.setPressedIcon(SYSConst.icon22edit3Pressed); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnEdit.setContentAreaFilled(false); btnEdit.setBorder(null); btnEdit.setToolTipText(SYSTools.xx("admin.residents.cash.btnedit.tooltip")); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { final JidePopup popupTX = new JidePopup(); popupTX.setMovable(false); PnlTX pnlTX = getPnlTX(resident, allowance); popupTX.setContentPane(pnlTX); popupTX.removeExcludedComponent(pnlTX); popupTX.setDefaultFocusComponent(pnlTX); popupTX.setOwner(btnEdit); GUITools.showPopup(popupTX, SwingConstants.WEST); } }); cptitle.getRight().add(btnEdit); // you can edit your own entries or you are a manager. once they are replaced or a replacement record, its over. btnEdit.setEnabled((OPDE.getAppInfo().isAllowedTo(InternalClassACL.MANAGER, internalClassID) || allowance.getUser().equals(OPDE.getLogin().getUser())) && !allowance.isReplaced() && !allowance.isReplacement()); /*** * _ _ _ _______ __ * | | | |_ __ __| | ___ |_ _\ \/ / * | | | | '_ \ / _` |/ _ \ | | \ / * | |_| | | | | (_| | (_) | | | / \ * \___/|_| |_|\__,_|\___/ |_| /_/\_\ * */ final JButton btnUndoTX = new JButton(SYSConst.icon22undo); btnUndoTX.setPressedIcon(SYSConst.icon22Pressed); btnUndoTX.setAlignmentX(Component.RIGHT_ALIGNMENT); btnUndoTX.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnUndoTX.setContentAreaFilled(false); btnUndoTX.setBorder(null); btnUndoTX.setToolTipText(SYSTools.xx("admin.residents.cash.btnundotx.tooltip")); btnUndoTX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("misc.questions.undo1") + "<br/><i>" + "<br/><i>" + allowance.getText() + " " + cf.format(allowance.getAmount()) + "</i><br/>" + SYSTools.xx("misc.questions.undo2"), SYSConst.icon48undo, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Allowance myOldAllowance = em.merge(allowance); Allowance myCancelAllowance = em .merge(new Allowance(myOldAllowance)); em.lock(em.merge(myOldAllowance.getResident()), LockModeType.OPTIMISTIC); em.lock(myOldAllowance, LockModeType.OPTIMISTIC); myOldAllowance.setReplacedBy(myCancelAllowance, em.merge(OPDE.getLogin().getUser())); em.getTransaction().commit(); DateTime txDate = new DateTime(myCancelAllowance.getPit()); final String keyMonth = myCancelAllowance.getResident().getRID() + "-" + txDate.getYear() + "-" + txDate.getMonthOfYear(); contentmap.remove(keyMonth); cpMap.remove(keyMonth); cashmap.get(keyMonth).remove(allowance); cashmap.get(keyMonth).add(myOldAllowance); cashmap.get(keyMonth).add(myCancelAllowance); Collections.sort(cashmap.get(keyMonth)); updateCarrySums(myCancelAllowance); createCP4(myCancelAllowance.getResident()); try { cpMap.get(keyMonth).setCollapsed(false); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage() .indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); cptitle.getRight().add(btnUndoTX); btnUndoTX.setEnabled(!allowance.isReplaced() && !allowance.isReplacement()); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, internalClassID)) { /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = new JButton(SYSConst.icon22delete); btnDelete.setPressedIcon(SYSConst.icon22deletePressed); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnDelete.setContentAreaFilled(false); btnDelete.setBorder(null); btnDelete.setToolTipText(SYSTools.xx("admin.residents.cash.btndelete.tooltip")); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("misc.questions.delete1") + "<br/><i>" + allowance.getText() + " " + cf.format(allowance.getAmount()) + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Allowance myAllowance = em.merge(allowance); em.lock(em.merge(myAllowance.getResident()), LockModeType.OPTIMISTIC); Allowance theOtherOne = null; // Check for special cases if (myAllowance.isReplacement()) { theOtherOne = em.merge(myAllowance.getReplacementFor()); theOtherOne.setReplacedBy(null); theOtherOne.setEditedBy(null); myAllowance.setEditPit(null); } if (myAllowance.isReplaced()) { theOtherOne = em.merge(myAllowance.getReplacedBy()); theOtherOne.setReplacementFor(null); } em.remove(myAllowance); em.getTransaction().commit(); DateTime txDate = new DateTime(myAllowance.getPit()); final String keyMonth = myAllowance.getResident().getRID() + "-" + txDate.getYear() + "-" + txDate.getMonthOfYear(); cpMap.remove(keyMonth); cashmap.get(keyMonth).remove(myAllowance); if (theOtherOne != null) { cashmap.get(keyMonth).remove(theOtherOne); cashmap.get(keyMonth).add(theOtherOne); Collections.sort(cashmap.get(keyMonth)); } // only to update the carrysums. myAllowance will be discarded soon. myAllowance.setAmount(myAllowance.getAmount().negate()); updateCarrySums(myAllowance); createCP4(myAllowance.getResident()); try { if (cpMap.containsKey(keyMonth)) { cpMap.get(keyMonth).setCollapsed(false); } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage() .indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); cptitle.getRight().add(btnDelete); } pnlMonth.add(cptitle.getMain()); linemap.put(allowance, cptitle.getMain()); rowsum = rowsum.subtract(allowance.getAmount()); } JLabel lblBOM = new JLabel("<html><table border=\"0\">" + "<tr>" + "<td width=\"130\" align=\"left\">" + DateFormat.getDateInstance().format(month.dayOfMonth().withMinimumValue().toDate()) + "</td>" + "<td width=\"400\" align=\"left\">" + SYSTools.xx("admin.residents.cash.startofmonth") + "</td>" + "<td width=\"100\" align=\"right\"></td>" + "<td width=\"100\" align=\"right\">" + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(rowsum) + (rowsum.compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>" + "</table>" + "</font></html>"); lblBOM.setBackground(getBG(resident, 11)); pnlMonth.add(lblBOM); contentmap.put(key, pnlMonth); } return contentmap.get(key); }
From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultTreeView.java
@Override public void refreshView(final ViewState state) { Rectangle visibleRect = null; if (this.tree != null) { visibleRect = this.tree.getVisibleRect(); }/* w ww.j av a 2 s . co m*/ this.removeAll(); this.actionsMenu = this.createPopupMenu(state); DefaultMutableTreeNode root = new DefaultMutableTreeNode("WORKFLOWS"); for (ModelGraph graph : state.getGraphs()) { root.add(this.buildTree(graph, state)); } tree = new JTree(root); tree.setShowsRootHandles(true); tree.setRootVisible(false); tree.add(this.actionsMenu); if (state.getSelected() != null) { // System.out.println("SELECTED: " + state.getSelected()); TreePath treePath = this.getTreePath(root, state.getSelected()); if (state.getCurrentMetGroup() != null) { treePath = this.getTreePath(treePath, state); } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_STATIC_METADATA))) { DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent(); for (int i = 0; i < baseNode.getChildCount(); i++) { if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject() .equals("static-metadata")) { treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath()); break; } } } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_PRECONDITIONS))) { if (treePath == null) { treePath = this.getTreePath(root, state.getSelected().getPreConditions()); } DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent(); for (int i = 0; i < baseNode.getChildCount(); i++) { if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject() .equals("pre-conditions")) { treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath()); break; } } } else if (Boolean.parseBoolean(state.getFirstPropertyValue(EXPAND_POSTCONDITIONS))) { if (treePath == null) { treePath = this.getTreePath(root, state.getSelected().getPostConditions()); } DefaultMutableTreeNode baseNode = (DefaultMutableTreeNode) treePath.getLastPathComponent(); for (int i = 0; i < baseNode.getChildCount(); i++) { if (((DefaultMutableTreeNode) baseNode.getChildAt(i)).getUserObject() .equals("post-conditions")) { treePath = new TreePath(((DefaultMutableTreeNode) baseNode.getChildAt(i)).getPath()); break; } } } this.tree.expandPath(treePath); this.tree.setSelectionPath(treePath); } tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { if (e.getPath().getLastPathComponent() instanceof DefaultMutableTreeNode) { DefaultTreeView.this.resetProperties(state); DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); if (node.getUserObject() instanceof ModelGraph) { state.setSelected((ModelGraph) node.getUserObject()); state.setCurrentMetGroup(null); DefaultTreeView.this.notifyListeners(); } else if (node.getUserObject().equals("static-metadata") || node.getUserObject().equals("pre-conditions") || node.getUserObject().equals("post-conditions")) { state.setSelected((ModelGraph) ((DefaultMutableTreeNode) node.getParent()).getUserObject()); state.setCurrentMetGroup(null); state.setProperty(EXPAND_STATIC_METADATA, Boolean.toString(node.getUserObject().equals("static-metadata"))); state.setProperty(EXPAND_PRECONDITIONS, Boolean.toString(node.getUserObject().equals("pre-conditions"))); state.setProperty(EXPAND_POSTCONDITIONS, Boolean.toString(node.getUserObject().equals("post-conditions"))); DefaultTreeView.this.notifyListeners(); } else if (node.getUserObject() instanceof ConcurrentHashMap) { DefaultMutableTreeNode metNode = null; String group = null; Object[] path = e.getPath().getPath(); for (int i = path.length - 1; i >= 0; i--) { if (((DefaultMutableTreeNode) path[i]).getUserObject() instanceof ModelGraph) { metNode = (DefaultMutableTreeNode) path[i]; break; } else if (((DefaultMutableTreeNode) path[i]) .getUserObject() instanceof ConcurrentHashMap) { if (group == null) { group = (String) ((ConcurrentHashMap<String, String>) ((DefaultMutableTreeNode) path[i]) .getUserObject()).keySet().iterator().next(); } else { group = (String) ((ConcurrentHashMap<String, String>) ((DefaultMutableTreeNode) path[i]) .getUserObject()).keySet().iterator().next() + "/" + group; } } } ModelGraph graph = (ModelGraph) metNode.getUserObject(); state.setSelected(graph); state.setCurrentMetGroup(group); DefaultTreeView.this.notifyListeners(); } else { state.setSelected(null); DefaultTreeView.this.notifyListeners(); } } } }); tree.setCellRenderer(new TreeCellRenderer() { public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; if (node.getUserObject() instanceof String) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JLabel label = new JLabel((String) node.getUserObject()); label.setForeground(Color.blue); panel.add(label, BorderLayout.CENTER); panel.setBackground(selected ? Color.lightGray : Color.white); return panel; } else if (node.getUserObject() instanceof ModelGraph) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JLabel iconLabel = new JLabel( ((ModelGraph) node.getUserObject()).getModel().getExecutionType() + ": "); iconLabel.setForeground(((ModelGraph) node.getUserObject()).getModel().getColor()); iconLabel.setBackground(Color.white); JLabel idLabel = new JLabel(((ModelGraph) node.getUserObject()).getModel().getModelName()); idLabel.setBackground(Color.white); panel.add(iconLabel, BorderLayout.WEST); panel.add(idLabel, BorderLayout.CENTER); panel.setBackground(selected ? Color.lightGray : Color.white); return panel; } else if (node.getUserObject() instanceof ConcurrentHashMap) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); String group = (String) ((ConcurrentHashMap<String, String>) node.getUserObject()).keySet() .iterator().next(); JLabel nameLabel = new JLabel(group + " : "); nameLabel.setForeground(Color.blue); nameLabel.setBackground(Color.white); JLabel valueLabel = new JLabel( ((ConcurrentHashMap<String, String>) node.getUserObject()).get(group)); valueLabel.setForeground(Color.darkGray); valueLabel.setBackground(Color.white); panel.add(nameLabel, BorderLayout.WEST); panel.add(valueLabel, BorderLayout.EAST); panel.setBackground(selected ? Color.lightGray : Color.white); return panel; } else { return new JLabel(); } } }); tree.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3 && DefaultTreeView.this.tree.getSelectionPath() != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) DefaultTreeView.this.tree .getSelectionPath().getLastPathComponent(); if (node.getUserObject() instanceof String && !(node.getUserObject().equals("pre-conditions") || node.getUserObject().equals("post-conditions"))) { return; } orderSubMenu.setEnabled(node.getUserObject() instanceof ModelGraph && !((ModelGraph) node.getUserObject()).isCondition() && ((ModelGraph) node.getUserObject()).getParent() != null); DefaultTreeView.this.actionsMenu.show(DefaultTreeView.this.tree, e.getX(), e.getY()); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); this.scrollPane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); this.add(this.scrollPane, BorderLayout.CENTER); if (visibleRect != null) { this.tree.scrollRectToVisible(visibleRect); } this.revalidate(); }
From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.GlobalConfigView.java
@Override public void refreshView(ViewState state) { Rectangle visibleRect = null; if (this.tree != null) { visibleRect = this.tree.getVisibleRect(); }/* w w w . j av a2 s. c om*/ DefaultMutableTreeNode root = new DefaultMutableTreeNode("GlobalConfig"); if (state != null && state.getGlobalConfigGroups() != null) { if (globalConfig != null && globalConfig.keySet().equals(state.getGlobalConfigGroups().keySet()) && globalConfig.values().equals(state.getGlobalConfigGroups().values())) { return; } this.removeAll(); for (ConfigGroup group : (globalConfig = state.getGlobalConfigGroups()).values()) { HashSet<String> keys = new HashSet<String>(); DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(new Group(group.getName())); root.add(groupNode); for (String key : group.getMetadata().getAllKeys()) { keys.add(key); DefaultMutableTreeNode keyNode = new DefaultMutableTreeNode(new Key(key)); groupNode.add(keyNode); DefaultMutableTreeNode valueNode = new DefaultMutableTreeNode( new Value(StringUtils.join(group.getMetadata().getAllMetadata(key), ","))); keyNode.add(valueNode); } if (group.getExtends() != null) { List<String> extendsGroups = new Vector<String>(group.getExtends()); Collections.reverse(extendsGroups); for (String extendsGroup : extendsGroups) { List<String> groupKeys = state.getGlobalConfigGroups().get(extendsGroup).getMetadata() .getAllKeys(); groupKeys.removeAll(keys); if (groupKeys.size() > 0) { for (String key : groupKeys) { if (!keys.contains(key)) { keys.add(key); DefaultMutableTreeNode keyNode = new DefaultMutableTreeNode( new ExtendsKey(extendsGroup, key)); groupNode.add(keyNode); DefaultMutableTreeNode valueNode = new DefaultMutableTreeNode( new ExtendsValue(StringUtils.join(state.getGlobalConfigGroups() .get(extendsGroup).getMetadata().getAllMetadata(key), ","))); keyNode.add(valueNode); } } } } } } tree = new JTree(root); tree.setShowsRootHandles(true); tree.setRootVisible(false); tree.setCellRenderer(new TreeCellRenderer() { public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; if (node.getUserObject() instanceof Key) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JLabel label = new JLabel(node.getUserObject().toString()); label.setForeground(Color.darkGray); panel.add(label, BorderLayout.CENTER); panel.setBackground(selected ? Color.lightGray : Color.white); return panel; } else if (node.getUserObject() instanceof ExtendsKey) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); ExtendsKey key = (ExtendsKey) node.getUserObject(); JLabel groupLabel = new JLabel("(" + key.getGroup() + ") "); groupLabel.setForeground(Color.black); JLabel keyLabel = new JLabel(key.getValue()); keyLabel.setForeground(Color.gray); panel.add(groupLabel, BorderLayout.WEST); panel.add(keyLabel, BorderLayout.CENTER); panel.setBackground(selected ? Color.lightGray : Color.white); return panel; } else if (node.getUserObject() instanceof Group) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JLabel label = new JLabel(node.getUserObject().toString()); label.setForeground(Color.black); label.setBackground(Color.white); panel.add(label, BorderLayout.CENTER); panel.setBackground(selected ? Color.lightGray : Color.white); return panel; } else if (node.getUserObject() instanceof Value) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.setBorder(new EtchedBorder(1)); JLabel label = new JLabel(node.getUserObject().toString()); label.setForeground(Color.black); panel.add(label, BorderLayout.CENTER); panel.setBackground(selected ? Color.lightGray : Color.white); return panel; } else if (node.getUserObject() instanceof ExtendsValue) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.setBorder(new EtchedBorder(1)); JLabel label = new JLabel(node.getUserObject().toString()); label.setForeground(Color.gray); panel.add(label, BorderLayout.CENTER); panel.setBackground(selected ? Color.lightGray : Color.white); return panel; } else { return new JLabel(); } } }); } this.setBorder(new EtchedBorder()); JLabel panelName = new JLabel("Global-Config Groups"); panelName.setBorder(new EtchedBorder()); this.add(panelName, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); tabbedPane = new JTabbedPane(); tabbedPane.addTab("Tree", scrollPane); tabbedPane.addTab("Table", new JPanel()); this.add(tabbedPane, BorderLayout.CENTER); if (visibleRect != null) { this.tree.scrollRectToVisible(visibleRect); } this.revalidate(); }
From source file:org.broad.igv.hic.MainWindow.java
private void initComponents() { JPanel mainPanel = new JPanel(); JPanel toolbarPanel = new JPanel(); //======== this ======== Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); mainPanel.setLayout(new BorderLayout()); toolbarPanel.setBorder(null);//from www.j av a2 s.c om toolbarPanel.setLayout(new GridLayout()); JPanel chrSelectionPanel = new JPanel(); chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder()); chrSelectionPanel.setMinimumSize(new Dimension(130, 57)); chrSelectionPanel.setPreferredSize(new Dimension(130, 57)); chrSelectionPanel.setLayout(new BorderLayout()); JPanel panel10 = new JPanel(); panel10.setBackground(new Color(204, 204, 204)); panel10.setLayout(new BorderLayout()); JLabel label3 = new JLabel(); label3.setText("Chromosomes"); label3.setHorizontalAlignment(SwingConstants.CENTER); panel10.add(label3, BorderLayout.CENTER); chrSelectionPanel.add(panel10, BorderLayout.PAGE_START); JPanel panel9 = new JPanel(); panel9.setBackground(new Color(238, 238, 238)); panel9.setLayout(new BoxLayout(panel9, BoxLayout.X_AXIS)); //---- chrBox1 ---- chrBox1 = new JComboBox(); chrBox1.setModel(new DefaultComboBoxModel(new String[] { "All" })); chrBox1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox1ActionPerformed(e); } }); panel9.add(chrBox1); //---- chrBox2 ---- chrBox2 = new JComboBox(); chrBox2.setModel(new DefaultComboBoxModel(new String[] { "All" })); chrBox2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox2ActionPerformed(e); } }); panel9.add(chrBox2); //---- refreshButton ---- JideButton refreshButton = new JideButton(); refreshButton .setIcon(new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif"))); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { refreshButtonActionPerformed(e); } }); panel9.add(refreshButton); chrSelectionPanel.add(panel9, BorderLayout.CENTER); toolbarPanel.add(chrSelectionPanel); //======== displayOptionPanel ======== JPanel displayOptionPanel = new JPanel(); JPanel panel1 = new JPanel(); displayOptionComboBox = new JComboBox(); displayOptionPanel.setBackground(new Color(238, 238, 238)); displayOptionPanel.setBorder(LineBorder.createGrayLineBorder()); displayOptionPanel.setLayout(new BorderLayout()); //======== panel14 ======== JPanel panel14 = new JPanel(); panel14.setBackground(new Color(204, 204, 204)); panel14.setLayout(new BorderLayout()); //---- label4 ---- JLabel label4 = new JLabel(); label4.setText("Show"); label4.setHorizontalAlignment(SwingConstants.CENTER); panel14.add(label4, BorderLayout.CENTER); displayOptionPanel.add(panel14, BorderLayout.PAGE_START); //======== panel1 ======== panel1.setBorder(new EmptyBorder(0, 10, 0, 10)); panel1.setLayout(new GridLayout(1, 0, 20, 0)); //---- comboBox1 ---- displayOptionComboBox .setModel(new DefaultComboBoxModel(new String[] { DisplayOption.OBSERVED.toString() })); displayOptionComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { displayOptionComboBoxActionPerformed(e); } }); panel1.add(displayOptionComboBox); displayOptionPanel.add(panel1, BorderLayout.CENTER); toolbarPanel.add(displayOptionPanel); //======== colorRangePanel ======== JPanel colorRangePanel = new JPanel(); JLabel colorRangeLabel = new JLabel(); colorRangeSlider = new RangeSlider(); colorRangePanel.setBorder(LineBorder.createGrayLineBorder()); colorRangePanel.setMinimumSize(new Dimension(96, 70)); colorRangePanel.setPreferredSize(new Dimension(202, 70)); colorRangePanel.setMaximumSize(new Dimension(32769, 70)); colorRangePanel.setLayout(new BorderLayout()); //======== panel11 ======== JPanel colorLabelPanel = new JPanel(); colorLabelPanel.setBackground(new Color(204, 204, 204)); colorLabelPanel.setLayout(new BorderLayout()); //---- colorRangeLabel ---- colorRangeLabel.setText("Color Range"); colorRangeLabel.setHorizontalAlignment(SwingConstants.CENTER); colorRangeLabel.setToolTipText("Range of color scale in counts per mega-base squared."); colorRangeLabel.setHorizontalTextPosition(SwingConstants.CENTER); colorRangeLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider); rangeDialog.setVisible(true); } } @Override public void mouseClicked(MouseEvent e) { ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider); rangeDialog.setVisible(true); } }); colorLabelPanel.add(colorRangeLabel, BorderLayout.CENTER); colorRangePanel.add(colorLabelPanel, BorderLayout.PAGE_START); //---- colorRangeSlider ---- colorRangeSlider.setPaintTicks(true); colorRangeSlider.setPaintLabels(true); colorRangeSlider.setLowerValue(0); colorRangeSlider.setMajorTickSpacing(500); colorRangeSlider.setMaximumSize(new Dimension(32767, 52)); colorRangeSlider.setPreferredSize(new Dimension(200, 52)); colorRangeSlider.setMinimumSize(new Dimension(36, 52)); colorRangeSlider.setMaximum(2000); colorRangeSlider.setUpperValue(500); colorRangeSlider.setMinorTickSpacing(100); colorRangeSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { colorRangeSliderStateChanged(e); } }); colorRangePanel.add(colorRangeSlider, BorderLayout.PAGE_END); // JPanel colorRangeTextPanel = new JPanel(); // colorRangeTextPanel.setLayout(new FlowLayout()); // JTextField minField = new JTextField(); // minField.setPreferredSize(new Dimension(50, 15)); // colorRangeTextPanel.add(minField); // colorRangeTextPanel.add(new JLabel(" - ")); // JTextField maxField = new JTextField(); // maxField.setPreferredSize(new Dimension(50, 15)); // colorRangeTextPanel.add(maxField); // colorRangeTextPanel.setPreferredSize(new Dimension(200, 52)); // colorRangePanel.add(colorRangeTextPanel, BorderLayout.PAGE_END); toolbarPanel.add(colorRangePanel); //======== resolutionPanel ======== JLabel resolutionLabel = new JLabel(); JPanel resolutionPanel = new JPanel(); resolutionPanel.setBorder(LineBorder.createGrayLineBorder()); resolutionPanel.setLayout(new BorderLayout()); //======== panel12 ======== JPanel panel12 = new JPanel(); panel12.setBackground(new Color(204, 204, 204)); panel12.setLayout(new BorderLayout()); //---- resolutionLabel ---- resolutionLabel.setText("Resolution"); resolutionLabel.setHorizontalAlignment(SwingConstants.CENTER); resolutionLabel.setBackground(new Color(204, 204, 204)); panel12.add(resolutionLabel, BorderLayout.CENTER); resolutionPanel.add(panel12, BorderLayout.PAGE_START); //======== panel2 ======== JPanel panel2 = new JPanel(); panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS)); //---- resolutionSlider ---- resolutionSlider = new JSlider(); resolutionSlider.setMaximum(8); resolutionSlider.setMajorTickSpacing(1); resolutionSlider.setPaintTicks(true); resolutionSlider.setSnapToTicks(true); resolutionSlider.setPaintLabels(true); resolutionSlider.setMinorTickSpacing(1); Dictionary<Integer, JLabel> resolutionLabels = new Hashtable<Integer, JLabel>(); Font f = FontManager.getFont(8); for (int i = 0; i < HiCGlobals.zoomLabels.length; i++) { if ((i + 1) % 2 == 0) { final JLabel tickLabel = new JLabel(HiCGlobals.zoomLabels[i]); tickLabel.setFont(f); resolutionLabels.put(i, tickLabel); } } resolutionSlider.setLabelTable(resolutionLabels); // Setting the zoom should always be done by calling resolutionSlider.setValue() so work isn't done twice. resolutionSlider.addChangeListener(new ChangeListener() { // Change zoom level while staying centered on current location. // Centering is relative to the bounds of the data, which might not be the bounds of the window public void stateChanged(ChangeEvent e) { if (!resolutionSlider.getValueIsAdjusting()) { int idx = resolutionSlider.getValue(); idx = Math.max(0, Math.min(idx, MAX_ZOOM)); if (hic.zd != null && idx == hic.zd.getZoom()) { // Nothing to do return; } if (hic.xContext != null) { int centerLocationX = (int) hic.xContext .getChromosomePosition(getHeatmapPanel().getWidth() / 2); int centerLocationY = (int) hic.yContext .getChromosomePosition(getHeatmapPanel().getHeight() / 2); hic.setZoom(idx, centerLocationX, centerLocationY, false); } //zoomInButton.setEnabled(newZoom < MAX_ZOOM); //zoomOutButton.setEnabled(newZoom > 0); } } }); panel2.add(resolutionSlider); resolutionPanel.add(panel2, BorderLayout.CENTER); toolbarPanel.add(resolutionPanel); mainPanel.add(toolbarPanel, BorderLayout.NORTH); //======== hiCPanel ======== final JPanel hiCPanel = new JPanel(); hiCPanel.setLayout(new HiCLayout()); //---- rulerPanel2 ---- rulerPanel2 = new HiCRulerPanel(hic); rulerPanel2.setMaximumSize(new Dimension(4000, 50)); rulerPanel2.setMinimumSize(new Dimension(1, 50)); rulerPanel2.setPreferredSize(new Dimension(1, 50)); rulerPanel2.setBorder(null); JPanel panel2_5 = new JPanel(); panel2_5.setLayout(new BorderLayout()); panel2_5.add(rulerPanel2, BorderLayout.SOUTH); trackPanel = new TrackPanel(hic); trackPanel.setMaximumSize(new Dimension(4000, 50)); trackPanel.setPreferredSize(new Dimension(1, 50)); trackPanel.setMinimumSize(new Dimension(1, 50)); trackPanel.setBorder(null); // trackPanelScrollpane = new JScrollPane(); // trackPanelScrollpane.getViewport().add(trackPanel); // trackPanelScrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); // trackPanelScrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // trackPanelScrollpane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102))); // trackPanelScrollpane.setBackground(new java.awt.Color(237, 237, 237)); // trackPanelScrollpane.setVisible(false); // panel2_5.add(trackPanelScrollpane, BorderLayout.NORTH); // trackPanel.setVisible(false); panel2_5.add(trackPanel, BorderLayout.NORTH); hiCPanel.add(panel2_5, BorderLayout.NORTH); //---- rulerPanel1 ---- rulerPanel1 = new HiCRulerPanel(hic); rulerPanel1.setMaximumSize(new Dimension(50, 4000)); rulerPanel1.setPreferredSize(new Dimension(50, 500)); rulerPanel1.setBorder(null); rulerPanel1.setMinimumSize(new Dimension(50, 1)); hiCPanel.add(rulerPanel1, BorderLayout.WEST); //---- heatmapPanel ---- heatmapPanel = new HeatmapPanel(this, hic); heatmapPanel.setBorder(LineBorder.createBlackLineBorder()); heatmapPanel.setMaximumSize(new Dimension(500, 500)); heatmapPanel.setMinimumSize(new Dimension(500, 500)); heatmapPanel.setPreferredSize(new Dimension(500, 500)); heatmapPanel.setBackground(new Color(238, 238, 238)); hiCPanel.add(heatmapPanel, BorderLayout.CENTER); //======== panel8 ======== JPanel rightSidePanel = new JPanel(); rightSidePanel.setMaximumSize(new Dimension(120, 100)); rightSidePanel.setBorder(new EmptyBorder(0, 10, 0, 0)); rightSidePanel.setLayout(null); //---- thumbnailPanel ---- thumbnailPanel = new ThumbnailPanel(this, hic); thumbnailPanel.setMaximumSize(new Dimension(100, 100)); thumbnailPanel.setMinimumSize(new Dimension(100, 100)); thumbnailPanel.setPreferredSize(new Dimension(100, 100)); thumbnailPanel.setBorder(LineBorder.createBlackLineBorder()); thumbnailPanel.setPreferredSize(new Dimension(100, 100)); thumbnailPanel.setBounds(new Rectangle(new Point(20, 0), thumbnailPanel.getPreferredSize())); rightSidePanel.add(thumbnailPanel); //======== xPlotPanel ======== xPlotPanel = new JPanel(); xPlotPanel.setPreferredSize(new Dimension(250, 100)); xPlotPanel.setLayout(null); rightSidePanel.add(xPlotPanel); xPlotPanel.setBounds(10, 100, xPlotPanel.getPreferredSize().width, 228); //======== yPlotPanel ======== yPlotPanel = new JPanel(); yPlotPanel.setPreferredSize(new Dimension(250, 100)); yPlotPanel.setLayout(null); rightSidePanel.add(yPlotPanel); yPlotPanel.setBounds(10, 328, yPlotPanel.getPreferredSize().width, 228); // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < rightSidePanel.getComponentCount(); i++) { Rectangle bounds = rightSidePanel.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = rightSidePanel.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; rightSidePanel.setMinimumSize(preferredSize); rightSidePanel.setPreferredSize(preferredSize); hiCPanel.add(rightSidePanel, BorderLayout.EAST); mainPanel.add(hiCPanel, BorderLayout.CENTER); contentPane.add(mainPanel, BorderLayout.CENTER); JMenuBar menuBar = createMenuBar(hiCPanel); contentPane.add(menuBar, BorderLayout.NORTH); // setup the glass pane to display a wait cursor when visible, and to grab all mouse events rootPane.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); rootPane.getGlassPane().addMouseListener(new MouseAdapter() { }); }
From source file:org.colombbus.tangara.EditorFrame.java
/** * This method initializes msgButtonsPanel * * @return javax.swing.JPanel//from ww w . j a v a 2s.c om */ private JPanel getMsgButtonsPanel() { if (msgButtonsPanel == null) { msgButtonsPanel = new JPanel(); msgButtonsPanel.setLayout(new BorderLayout()); msgButtonsPanel.setBackground(Color.white); msgButtonsPanel.add(getMsgButtons(), BorderLayout.WEST); JLabel endIcon = new JLabel(); endIcon.setText(""); //$NON-NLS-1$ endIcon.setBackground(Color.white); endIcon.setIcon(new ImageIcon(getClass().getResource("/org/colombbus/tangara/main_end.png"))); //$NON-NLS-1$ msgButtonsPanel.add(endIcon, BorderLayout.EAST); } return msgButtonsPanel; }
From source file:org.interreg.docexplore.ServerConfigPanel.java
public ServerConfigPanel(final File config, final File serverDir) throws Exception { super(new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); this.serverDir = serverDir; this.books = new Vector<Book>(); this.bookList = new JList(new DefaultListModel()); JPanel listPanel = new JPanel(new BorderLayout()); listPanel.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBooksLabel"))); bookList.setOpaque(false);//from w w w . j ava 2s . c om bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bookList.setCellRenderer(new ListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Book book = (Book) value; JLabel label = new JLabel("<html><b>" + book.name + "</b> - " + book.nPages + " pages</html>"); label.setOpaque(true); if (isSelected) { label.setBackground(TextToolbar.styleHighLightedBackground); label.setForeground(Color.white); } if (book.deleted) label.setForeground(Color.red); else if (!book.used) label.setForeground(Color.gray); return label; } }); bookList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; setFields((Book) bookList.getSelectedValue()); } }); JScrollPane scrollPane = new JScrollPane(bookList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(500, 300)); scrollPane.getVerticalScrollBar().setUnitIncrement(10); listPanel.add(scrollPane, BorderLayout.CENTER); JPanel importPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); importPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgImportLabel")) { public void actionPerformed(ActionEvent e) { final File inFile = DocExploreTool.getFileDialogs().openFile(DocExploreTool.getIBookCategory()); if (inFile == null) return; try { final File tmpDir = new File(serverDir, "tmp"); tmpDir.mkdir(); GuiUtils.blockUntilComplete(new ProgressRunnable() { float[] progress = { 0 }; public void run() { try { ZipUtils.unzip(inFile, tmpDir, progress); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (float) progress[0]; } }, ServerConfigPanel.this); File tmpFile = new File(tmpDir, "index.tmp"); ObjectInputStream input = new ObjectInputStream(new FileInputStream(tmpFile)); String bookFile = input.readUTF(); String bookName = input.readUTF(); String bookDesc = input.readUTF(); input.close(); new PresentationImporter().doImport(ServerConfigPanel.this, bookName, bookDesc, new File(tmpDir, bookFile)); FileUtils.cleanDirectory(tmpDir); FileUtils.deleteDirectory(tmpDir); updateBooks(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } })); listPanel.add(importPanel, BorderLayout.SOUTH); add(listPanel); JPanel setupPanel = new JPanel( new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); setupPanel.setBorder( BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBookInfoLabel"))); usedBox = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseLabel")); usedBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Book book = (Book) bookList.getSelectedValue(); if (book != null) { book.used = usedBox.isSelected(); bookList.repaint(); } } }); setupPanel.add(usedBox); JPanel fieldPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTitleLabel"))); nameField = new JTextField(50); nameField.getDocument().addDocumentListener(new DocumentListener() { public void removeUpdate(DocumentEvent e) { changedUpdate(e); } public void insertUpdate(DocumentEvent e) { changedUpdate(e); } public void changedUpdate(DocumentEvent e) { Book book = (Book) bookList.getSelectedValue(); if (book == null) return; book.name = nameField.getText(); bookList.repaint(); } }); fieldPanel.add(nameField); fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDescriptionLabel"))); descField = new JTextPane(); //descField.setWrapStyleWord(true); descField.getDocument().addDocumentListener(new DocumentListener() { public void removeUpdate(DocumentEvent e) { changedUpdate(e); } public void insertUpdate(DocumentEvent e) { changedUpdate(e); } public void changedUpdate(DocumentEvent e) { Book book = (Book) bookList.getSelectedValue(); if (book == null) return; book.desc = descField.getText(); } }); scrollPane = new JScrollPane(descField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(420, 50)); scrollPane.getVerticalScrollBar().setUnitIncrement(10); fieldPanel.add(scrollPane); setupPanel.add(fieldPanel); exportButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgExportLabel")) { public void actionPerformed(ActionEvent e) { File file = DocExploreTool.getFileDialogs().saveFile(DocExploreTool.getIBookCategory()); if (file == null) return; final Book book = (Book) bookList.getSelectedValue(); final File indexFile = new File(serverDir, "index.tmp"); try { final File outFile = file; ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(indexFile)); out.writeUTF(book.bookFile.getName()); out.writeUTF(book.name); out.writeUTF(book.desc); out.close(); GuiUtils.blockUntilComplete(new ProgressRunnable() { float[] progress = { 0 }; public void run() { try { ZipUtils.zip(serverDir, new File[] { indexFile, book.bookFile, book.bookDir }, outFile, progress, 0, 1, 9); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (float) progress[0]; } }, ServerConfigPanel.this); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } if (indexFile.exists()) indexFile.delete(); } }); deleteButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgDeleteRestoreLabel")) { public void actionPerformed(ActionEvent e) { Book book = (Book) bookList.getSelectedValue(); if (book == null) return; book.deleted = !book.deleted; bookList.repaint(); } }); JPanel actionsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); actionsPanel.add(exportButton); actionsPanel.add(deleteButton); setupPanel.add(actionsPanel); add(setupPanel); JPanel optionsPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); optionsPanel .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgOptionsLabel"))); JPanel timeoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); timeoutField = new JTextField(5); timeoutPanel.add(timeoutField); timeoutPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTimeoutLabel"))); optionsPanel.add(timeoutPanel); add(optionsPanel); updateBooks(); setFields(null); final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>"; String idle = StringUtils.getTagContent(xml, "idle"); if (idle != null) try { timeoutField.setText("" + Integer.parseInt(idle)); } catch (Throwable e) { } }
From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java
/** * Create the FlatButton panel - a panel which contains graphical representations of the options available * to the user when interacting with the software. *//*from ww w .j a v a 2 s . c om*/ private void createButtonPanel() { spreadsheetFunctionPanel = new JPanel(); spreadsheetFunctionPanel.setLayout(new BoxLayout(spreadsheetFunctionPanel, BoxLayout.LINE_AXIS)); spreadsheetFunctionPanel.setBackground(UIHelper.BG_COLOR); addRow = new JLabel(addRowButton); addRow.setToolTipText("<html><b>add row</b>" + "<p>add a new row to the table</p></html>"); addRow.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { addRow.setIcon(addRowButton); showMultipleRowsGUI(); } public void mouseEntered(MouseEvent mouseEvent) { addRow.setIcon(addRowButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addRow.setIcon(addRowButton); } }); deleteRow = new JLabel(deleteRowButton); deleteRow.setToolTipText("<html><b>remove row</b>" + "<p>remove selected row from table</p></html>"); deleteRow.setEnabled(false); deleteRow.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButton); if (table.getSelectedRow() != -1) { if (!(table.getSelectedRowCount() > 1)) { spreadsheetFunctions.deleteRow(table.getSelectedRow()); } else { spreadsheetFunctions.deleteRow(table.getSelectedRows()); } } } public void mouseEntered(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButtonOver); } public void mouseExited(MouseEvent mouseEvent) { deleteRow.setIcon(deleteRowButton); } }); deleteColumn = new JLabel(deleteColumnButton); deleteColumn .setToolTipText("<html><b>remove column</b>" + "<p>remove selected column from table</p></html>"); deleteColumn.setEnabled(false); deleteColumn.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButton); if (!(table.getSelectedColumns().length > 1)) { spreadsheetFunctions.deleteColumn(table.getSelectedColumn()); } else { showColumnErrorMessage(); } } public void mouseEntered(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButtonOver); } public void mouseExited(MouseEvent mouseEvent) { deleteColumn.setIcon(deleteColumnButton); } }); multipleSort = new JLabel(multipleSortButton); multipleSort.setToolTipText( "<html><b>multiple sort</b>" + "<p>perform a multiple sort on the table</p></html>"); multipleSort.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButton); showMultipleColumnSortGUI(); } public void mouseEntered(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButtonOver); } public void mouseExited(MouseEvent mouseEvent) { multipleSort.setIcon(multipleSortButton); } }); copyColDown = new JLabel(copyColDownButton); copyColDown.setToolTipText("<html><b>copy column downwards</b>" + "<p>duplicate selected column and copy it from the current</p>" + "<p>position down to the final row in the table</p></html>"); copyColDown.setEnabled(false); copyColDown.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButton); } public void mouseEntered(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButtonOver); } public void mousePressed(MouseEvent mouseEvent) { copyColDown.setIcon(copyColDownButton); final int row = table.getSelectedRow(); final int col = table.getSelectedColumn(); if (row != -1 && col != -1) { JOptionPane copyColDownConfirmationPane = new JOptionPane( "<html><b>Confirm Copy of Column...</b><p>Are you sure you wish to copy " + "this column downwards?</p><p>This Action can not be undone!</p></html>", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); copyColDownConfirmationPane.setIcon(copyColumnDownWarningIcon); UIHelper.applyOptionPaneBackground(copyColDownConfirmationPane, UIHelper.BG_COLOR); copyColDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); parentFrame.hideSheet(); if (lastOptionAnswer == JOptionPane.YES_OPTION) { spreadsheetFunctions.copyColumnDownwards(row, col); } } } }); parentFrame.showJDialogAsSheet( copyColDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Column?")); } } }); copyRowDown = new JLabel(copyRowDownButton); copyRowDown.setToolTipText( "<html><b>copy row downwards</b>" + "<p>duplicate selected row and copy it from the current</p>" + "<p>position down to the final row</p></html>"); copyRowDown.setEnabled(false); copyRowDown.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButton); } public void mouseEntered(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButtonOver); } public void mousePressed(MouseEvent mouseEvent) { copyRowDown.setIcon(copyRowDownButton); final int row = table.getSelectedRow(); JOptionPane copyRowDownConfirmationPane = new JOptionPane( "<html><b>Confirm Copy of Row...</b><p>Are you sure you wish to copy " + "this row downwards?</p><p>This Action can not be undone!</p>", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); copyRowDownConfirmationPane.setIcon(copyRowDownWarningIcon); UIHelper.applyOptionPaneBackground(copyRowDownConfirmationPane, UIHelper.BG_COLOR); copyRowDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) { int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString()); parentFrame.hideSheet(); if (lastOptionAnswer == JOptionPane.YES_OPTION) { spreadsheetFunctions.copyRowDownwards(row); } } } }); parentFrame.showJDialogAsSheet( copyRowDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Row Down?")); } }); addProtocol = new JLabel(addProtocolButton); addProtocol.setToolTipText( "<html><b>add a protocol column</b>" + "<p>Add a protocol column to the table</p></html>"); addProtocol.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButton); } public void mousePressed(MouseEvent mouseEvent) { addProtocol.setIcon(addProtocolButton); if (addProtocol.isEnabled()) { FieldObject fo = new FieldObject(table.getColumnCount(), "Protocol REF", "Protocol used for experiment", DataTypes.LIST, "", false, false, false); fo.setFieldList(studyDataEntryEnvironment.getProtocolNames()); spreadsheetFunctions.addFieldToReferenceObject(fo); spreadsheetFunctions.addColumnAfterPosition("Protocol REF", null, fo.isRequired(), -1); } } }); addFactor = new JLabel(addFactorButton); addFactor.setToolTipText( "<html><b>add a factor column</b>" + "<p>Add a factor column to the table</p></html>"); addFactor.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButton); } public void mousePressed(MouseEvent mouseEvent) { addFactor.setIcon(addFactorButton); if (addFactor.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_FACTOR_COLUMN); } } }); addCharacteristic = new JLabel(addCharacteristicButton); addCharacteristic.setToolTipText("<html><b>add a characteristic column</b>" + "<p>Add a characteristic column to the table</p></html>"); addCharacteristic.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButton); } public void mousePressed(MouseEvent mouseEvent) { addCharacteristic.setIcon(addCharacteristicButton); if (addCharacteristic.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_CHARACTERISTIC_COLUMN); } } }); addParameter = new JLabel(addParameterButton); addParameter.setToolTipText( "<html><b>add a parameter column</b>" + "<p>Add a parameter column to the table</p></html>"); addParameter.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButtonOver); } public void mouseExited(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButton); } public void mousePressed(MouseEvent mouseEvent) { addParameter.setIcon(addParameterButton); if (addParameter.isEnabled()) { showAddColumnsGUI(AddColumnGUI.ADD_PARAMETER_COLUMN); } } }); undo = new JLabel(undoButton); undo.setToolTipText("<html><b>undo previous action<b></html>"); undo.setEnabled(undoManager.canUndo()); undo.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { undo.setIcon(undoButton); undoManager.undo(); if (highlightActive) { setRowsToDefaultColor(); } table.addNotify(); } public void mouseEntered(MouseEvent mouseEvent) { undo.setIcon(undoButtonOver); } public void mouseExited(MouseEvent mouseEvent) { undo.setIcon(undoButton); } }); redo = new JLabel(redoButton); redo.setToolTipText("<html><b>redo action<b></html>"); redo.setEnabled(undoManager.canRedo()); redo.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { redo.setIcon(redoButton); undoManager.redo(); if (highlightActive) { setRowsToDefaultColor(); } table.addNotify(); } public void mouseEntered(MouseEvent mouseEvent) { redo.setIcon(redoButtonOver); } public void mouseExited(MouseEvent mouseEvent) { redo.setIcon(redoButton); } }); transpose = new JLabel(transposeIcon); transpose.setToolTipText("<html>View a transposed version of this spreadsheet</html>"); transpose.addMouseListener(new MouseAdapter() { public void mouseExited(MouseEvent mouseEvent) { transpose.setIcon(transposeIcon); } public void mouseEntered(MouseEvent mouseEvent) { transpose.setIcon(transposeIconOver); } public void mousePressed(MouseEvent mouseEvent) { showTransposeSpreadsheetGUI(); } }); addButtons(); if (studyDataEntryEnvironment != null) { JPanel labelContainer = new JPanel(new GridLayout(1, 1)); labelContainer.setBackground(UIHelper.BG_COLOR); JLabel lab = UIHelper.createLabel(spreadsheetTitle, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, JLabel.RIGHT); lab.setBackground(UIHelper.BG_COLOR); lab.setVerticalAlignment(JLabel.CENTER); lab.setPreferredSize(new Dimension(200, 30)); labelContainer.add(lab); spreadsheetFunctionPanel.add(labelContainer); spreadsheetFunctionPanel.add(Box.createHorizontalStrut(10)); } add(spreadsheetFunctionPanel, BorderLayout.NORTH); }
From source file:org.jannocessor.ui.RenderPreviewDialog.java
private void initialize() { logger.debug("Initializing UI..."); DefaultSyntaxKit.initKit();/*w w w. j a v a 2s. co m*/ JEditorPane.registerEditorKitForContentType("text/java_template", "org.jannocessor.syntax.JavaTemplateKit", getClass().getClassLoader()); JEditorPane.registerEditorKitForContentType("text/java_output", "org.jannocessor.syntax.JavaOutputKit", getClass().getClassLoader()); setTitle("JAnnocessor - Java Annotation Processor"); setLayout(new BorderLayout(5, 5)); listFiles(); Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); double width = screenSize.getWidth() * 0.9; double height = screenSize.getHeight() * 0.8; // Font font = new Font("Courier New", Font.PLAIN, 14); input = createInput(); JScrollPane scroll1 = new JScrollPane(input, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); input.setContentType("text/java_template"); input.setText(""); scroll1.setMinimumSize(new Dimension(200, 200)); scroll1.setPreferredSize(new Dimension((int) (width * 0.5), (int) height)); add(scroll1, BorderLayout.CENTER); output = Box.createVerticalBox(); scroll2 = new JScrollPane(output, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll2.setMinimumSize(new Dimension(200, 200)); scroll2.setPreferredSize(new Dimension((int) (width * 0.5), (int) height)); add(scroll2, BorderLayout.EAST); combo = createCombo(); combo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { load((File) combo.getSelectedItem()); } }); add(combo, BorderLayout.NORTH); JLabel help = new JLabel( " Choose a template from the drop-down box to edit it. Navigation: Alt + Left & Alt + Right; Refresh = F5, Close = Esc", JLabel.CENTER); help.setForeground(Color.WHITE); help.setBackground(Color.BLACK); help.setOpaque(true); help.setFont(new Font("Courier New", Font.BOLD, 14)); add(help, BorderLayout.SOUTH); keyListener = new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F5) { e.consume(); processElements(); refresh(); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { e.consume(); dispose(); } else if (e.getKeyCode() == KeyEvent.VK_LEFT && e.isAltDown()) { e.consume(); moveBackward(); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT && e.isAltDown()) { e.consume(); moveForward(); } else if (e.getKeyCode() == KeyEvent.VK_S && e.isControlDown()) { e.consume(); save(); } else if (e.getKeyCode() == KeyEvent.VK_I && e.isControlDown()) { e.consume(); increase(); } else if (e.getKeyCode() == KeyEvent.VK_D && e.isControlDown()) { e.consume(); decrease(); } } }; input.addKeyListener(keyListener); combo.addKeyListener(keyListener); setActive(0); pack(); setModal(true); setLocationRelativeTo(null); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); input.requestFocus(); logger.debug("Initialized UI."); }