private void insertTabImpl(String title, Icon icon, Component component, String tip, int index) { String tabid = component.getName(); if (tabid == null) { tabid = "WIN" + new java.rmi.server.UID(); component.setName(tabid); } Component old = tabIndex.get(tabid); if (old != null) { if (indexOfComponent(old) >= 0) { setSelectedComponent(old); return; } } if (component instanceof OSTabbedView) { String s = ((OSTabbedView) component).getTitle(); if (s != null && s.trim().length() > 0) { title = s; } } super.insertTab(title, icon, component, tip, index); setSelectedIndex(index); tabIndex.put(tabid, component); OSManager.getInstance().registerView(tabid, new OSViewImpl(component)); }
/** * Constructs a default <code>JTable</code> that is initialized with a default data model, a * default column model, and a default selection model. The identifier JComponent is used to save * the state of the table columns in the actual view. Not using this one constructor may lead to * inconsistent behavior of the view if this JTable's parent component has no unique name. It is * recommended to use this constructor in Yabs. * * @see #createDefaultDataModel * @see #createDefaultColumnModel * @see #createDefaultSelectionModel */ public MPTable(Component identifier) { super(); setName("43"); if (identifier.getName() == null) { identifier.setName(identifier.getClass().getSimpleName()); } setPersistanceHandler(new TableViewPersistenceHandler(this, identifier)); }
/** * The constructor with the data set * * @param d the data set */ public BareGraph(GraphDataSet d) { super(); super.setName(base + nameCounter++); setMin(0); setMax(1000000); setDataSet(d); }
public static HashMap<String, JButton> getButtonsFromContainer(Container c) { HashMap<String, JButton> map = new HashMap<String, JButton>(); int count = 0; while (c.getComponentCount() > count) { Component comp = c.getComponent(count++); if (comp.getClass().isAssignableFrom(JButton.class)) { String newName = getNameBeforeDots(comp.getName()); comp.setName(newName); map.put(comp.getName(), (JButton) comp); return map; } else if (comp instanceof Container) { HashMap<String, JButton> recursiveMap = getButtonsFromContainer((Container) comp); if (recursiveMap.size() > 0) { for (JButton w : recursiveMap.values()) { String newName = getNameBeforeDots(w.getName()); comp.setName(newName); map.put(w.getName(), w); } } } } return map; }
/** * Set Label For * * @param c component */ @Override public void setLabelFor(Component c) { // reset old if any if (getLabelFor() != null && getLabelFor() instanceof JTextComponent) { ((JTextComponent) getLabelFor()).setFocusAccelerator('\0'); } super.setLabelFor(c); if (c.getName() == null) c.setName(getName()); // workaround for focus accelerator issue if (c instanceof JTextComponent) { if (m_savedMnemonic > 0) { ((JTextComponent) c).setFocusAccelerator(m_savedMnemonic); } } } // setLabelFor
private static void addContainerWidgets(Container c, HashMap<String, JComponent> map) { int count = 0; while (c.getComponentCount() > count) { Component comp = c.getComponent(count++); if ((comp instanceof JTextField) || (comp instanceof JFormattedTextField) || (comp instanceof JCheckBox) || (comp instanceof JTextArea) || (comp instanceof JComboBox) || (comp instanceof JTable) || (comp instanceof JDateChooser)) { String newName = getNameBeforeDots(comp.getName()); comp.setName(newName); map.put(comp.getName(), (JComponent) comp); } if (comp instanceof Container) { addContainerWidgets((Container) comp, map); } } }
public JToolBar buildToolBar(MutableGuiContext ctxt) throws MenuFactory.BuildException { JToolBar bar = new JToolBar(); bar.setFloatable(getFloatable()); bar.setBorderPainted(getBorderPainted()); for (MenuBuilder item : getComponents()) { item.setForMenu(false); Component cmp = item.build(ctxt); if (cmp instanceof JMenuItem && ((JMenuItem) cmp).getIcon() != null) { Action currentAction = ((JMenuItem) cmp).getAction(); if (!item.isHiddenWhenNotAllowed() || currentAction.isEnabled()) { bar.add(currentAction).setName(currentAction.getValue(Action.NAME).toString()); ; } } else { if (cmp instanceof AbstractButton) { Action actionObject = ((AbstractButton) cmp).getAction(); if (actionObject != null) { String actionName = (String) actionObject.getValue(Action.NAME); cmp.setName(actionName); } } if (getIconOnly() && cmp instanceof JButton && ((JButton) cmp).getIcon() != null) { ((JButton) cmp).setText(""); } if (!item.isHiddenWhenNotAllowed() || cmp.isEnabled()) { bar.add(cmp); } } } rolloverEffect.doEffect(bar); return removeUnnecessarySeparators(bar); }