Esempio n. 1
0
  private void formWindowOpened(
      java.awt.event.WindowEvent evt) { // GEN-FIRST:event_formWindowOpened
    lst = new ListRsbm();
    lst2 = new ListRsbmNota();

    lst.setVisible(false);
    lst.setSize(500, 200);
    lst.con = conn;

    lst2.setVisible(false);
    lst2.setSize(500, 200);
    lst2.con = conn;

    MyKeyListener kListener = new MyKeyListener();
    for (int i = 0; i < jPanel1.getComponentCount(); i++) {
      Component c = jPanel1.getComponent(i);
      if (c.getClass().getSimpleName().equalsIgnoreCase("JTEXTFIELD")
          || c.getClass().getSimpleName().equalsIgnoreCase("JFormattedTextField")
          || c.getClass().getSimpleName().equalsIgnoreCase("JTextArea")
          || c.getClass().getSimpleName().equalsIgnoreCase("JComboBox")
          || c.getClass().getSimpleName().equalsIgnoreCase("JButton")
          || c.getClass().getSimpleName().equalsIgnoreCase("JCheckBox")
          || c.getClass().getSimpleName().equalsIgnoreCase("JRadioButton")) {
        // System.out.println(c.getClass().getSimpleName());
        c.addKeyListener(kListener);
      }
    }
  } // GEN-LAST:event_formWindowOpened
Esempio n. 2
0
 private final void printComp(final Component comp, final int deep) {
   final Rectangle rect = comp.getBounds();
   if (L.isInWorkshop) {
     System.out.println(
         comp.getClass().getName()
             + deep
             + ", x : "
             + rect.x
             + ", y : "
             + rect.y
             + ", w : "
             + rect.width
             + ", h : "
             + rect.height);
   }
   if (comp instanceof Container) {
     final Container container = (Container) comp;
     final int count = container.getComponentCount();
     for (int i = 0; i < count; i++) {
       printComp(container.getComponent(i), deep + 1);
     }
   } else if (comp instanceof JScrollPane) {
     if (L.isInWorkshop) {
       System.out.println("------This is JScrollPane-----");
     }
     printComp(((JScrollPane) comp).getViewport().getView(), deep);
   }
 }
Esempio n. 3
0
    @Override
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

      DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
      if (node.getUserObject() != null) {
        ComponentWrapper userObject = (ComponentWrapper) node.getUserObject();
        if (userObject != null) {
          Component c = userObject.component;
          for (int i = 0; i < cmpClasses.length; i++) {
            Class clazz = cmpClasses[i];
            if (clazz.isAssignableFrom(c.getClass())) {
              setIcon(cmpIcons[i]);
              return this;
            }
          }
        }
        setIcon(noneIcon);
      }
      return this;
    }
 @SuppressWarnings({"HardCodedStringLiteral"})
 private Element writePanel(final JPanel panel) {
   final Component comp = panel.getComponent(0);
   if (comp instanceof Splitter) {
     final Splitter splitter = (Splitter) comp;
     final Element res = new Element("splitter");
     res.setAttribute("split-orientation", splitter.getOrientation() ? "vertical" : "horizontal");
     res.setAttribute("split-proportion", Float.toString(splitter.getProportion()));
     final Element first = new Element("split-first");
     first.addContent(writePanel((JPanel) splitter.getFirstComponent()));
     final Element second = new Element("split-second");
     second.addContent(writePanel((JPanel) splitter.getSecondComponent()));
     res.addContent(first);
     res.addContent(second);
     return res;
   } else if (comp instanceof JBTabs) {
     final Element res = new Element("leaf");
     final EditorWindow window = findWindowWith(comp);
     writeWindow(res, window);
     return res;
   } else if (comp instanceof EditorWindow.TCompForTablessMode) {
     final EditorWithProviderComposite composite =
         ((EditorWindow.TCompForTablessMode) comp).myEditor;
     final Element res = new Element("leaf");
     writeComposite(res, composite.getFile(), composite, false, composite);
     return res;
   } else {
     LOG.error(comp != null ? comp.getClass().getName() : null);
     return null;
   }
 }
Esempio n. 5
0
  private void begin() {
    // copy text from the component with keyboard focus
    Component keyboardComp =
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();

    if (keyboardComp != null && keyboardComp instanceof JTextComponent) {
      JTextComponent textComp = (JTextComponent) keyboardComp;
      textComp.copy();
    } else {
      // if it was not a text component, see if we have the cut
      // method available
      Method copyMethod = null;
      try {
        copyMethod = keyboardComp.getClass().getMethod("copy", new Class[0]);
      } catch (SecurityException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
      } catch (NoSuchMethodException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
      }

      if (copyMethod != null) {
        try {
          copyMethod.invoke(keyboardComp, new Object[0]);
        } catch (IllegalArgumentException ex) {
          LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        } catch (IllegalAccessException ex) {
          LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        } catch (InvocationTargetException ex) {
          LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        }
      }
    }
  }
Esempio n. 6
0
 private void setOpaque(Component comp, boolean opaque) {
   try {
     Method m = comp.getClass().getMethod("setOpaque", new Class[] {boolean.class});
     m.invoke(comp, new Object[] {opaque});
   } catch (Exception ign) {;
   }
 }
 /**
  * Dumps the component constraints to the console.
  *
  * @param container the layout container to inspect
  */
 public static void dumpConstraints(Container container) {
   System.out.println("COMPONENT CONSTRAINTS");
   if (!(container.getLayout() instanceof FormLayout)) {
     System.out.println("The container's layout is not a FormLayout.");
     return;
   }
   FormLayout layout = (FormLayout) container.getLayout();
   int childCount = container.getComponentCount();
   for (int i = 0; i < childCount; i++) {
     Component child = container.getComponent(i);
     CellConstraints cc = layout.getConstraints(child);
     String ccString = cc == null ? "no constraints" : cc.toShortString(layout);
     System.out.print(ccString);
     System.out.print("; ");
     String childType = child.getClass().getName();
     System.out.print(childType);
     if (child instanceof JLabel) {
       JLabel label = (JLabel) child;
       System.out.print("      \"" + label.getText() + "\"");
     }
     if (child.getName() != null) {
       System.out.print("; name=");
       System.out.print(child.getName());
     }
     System.out.println();
   }
   System.out.println();
 }
  private JToolBar removeUnnecessarySeparators(JToolBar toolBar) {
    Component component;
    int previousDeleted = -1;
    int nbComponents = toolBar.getComponentCount();
    for (int i = 0; i < nbComponents; ) {
      component = toolBar.getComponent(i);
      if (toolBar.getComponent(i).getClass() == JSeparator.class) {
        if (i > previousDeleted) {
          toolBar.remove(component);
          nbComponents--;
        } else {
          i++;
        }
      } else {
        previousDeleted = ++i;
      }
    }

    if (nbComponents > 0) {
      component = toolBar.getComponent(toolBar.getComponentCount() - 1);
      if (component != null && component.getClass() == JSeparator.class) {
        toolBar.remove(component);
      }
    }
    return toolBar;
  }
 /**
  * ************************************************************************ Dump info
  *
  * @param title
  * @param c
  */
 private void info(String title, Component c) {
   System.out.print(title);
   if (c == null) System.out.println(" - null");
   else {
     System.out.print(c.getClass().getName());
     System.out.println(" - " + c.getName());
   }
 } //  info
Esempio n. 10
0
 /**
  * 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));
 }
Esempio n. 11
0
 public String toHtmlString() {
   StringBuilder str = new StringBuilder("<html>");
   str.append("&nbsp;name: ").append("<b>").append(component.getName()).append("</b><br>");
   str.append("&nbsp;class: ")
       .append("<b>")
       .append(component.getClass().getName())
       .append("</b><br>");
   return str.toString();
 }
Esempio n. 12
0
  protected void attachTo(Component jc) {
    if (extListener != null && extListener.accept(jc)) {
      extListener.startListeningTo(jc, extNotifier);
      listenedTo.add(jc);
      if (wizardPage.getMapKeyFor(jc) != null) {
        wizardPage.maybeUpdateMap(jc);
      }
      return;
    }
    if (isProbablyAContainer(jc)) {
      attachToHierarchyOf((Container) jc);
    } else if (jc instanceof JList) {
      listenedTo.add(jc);
      ((JList) jc).addListSelectionListener(this);
    } else if (jc instanceof JComboBox) {
      ((JComboBox) jc).addActionListener(this);
    } else if (jc instanceof JTree) {
      listenedTo.add(jc);
      ((JTree) jc).getSelectionModel().addTreeSelectionListener(this);
    } else if (jc instanceof JToggleButton) {
      ((AbstractButton) jc).addItemListener(this);
    } else if (jc
        instanceof JFormattedTextField) { // JFormattedTextField must be tested before JTextCompoent
      jc.addPropertyChangeListener("value", this);
    } else if (jc instanceof JTextComponent) {
      listenedTo.add(jc);
      ((JTextComponent) jc).getDocument().addDocumentListener(this);
    } else if (jc instanceof JColorChooser) {
      listenedTo.add(jc);
      ((JColorChooser) jc).getSelectionModel().addChangeListener(this);
    } else if (jc instanceof JSpinner) {
      ((JSpinner) jc).addChangeListener(this);
    } else if (jc instanceof JSlider) {
      ((JSlider) jc).addChangeListener(this);
    } else if (jc instanceof JTable) {
      listenedTo.add(jc);
      ((JTable) jc).getSelectionModel().addListSelectionListener(this);
    } else {
      if (logger.isLoggable(Level.FINE)) {
        logger.fine(
            "Don't know how to listen to a "
                + // NOI18N
                jc.getClass().getName());
      }
    }

    if (accept(jc) && !(jc instanceof JPanel)) {
      jc.addPropertyChangeListener("name", this);
      if (wizardPage.getMapKeyFor(jc) != null) {
        wizardPage.maybeUpdateMap(jc);
      }
    }

    if (logger.isLoggable(Level.FINE) && accept(jc)) {
      logger.fine("Begin listening to " + jc); // NOI18N
    }
  }
Esempio n. 13
0
 /**
  * Returns whether the given component is the default Swing hidden frame.
  *
  * @param c the component to check.
  * @return {@code true} if the given component is the default hidden frame, {@code false}
  *     otherwise.
  */
 public static boolean isSharedInvisibleFrame(@Nullable Component c) {
   if (c == null) {
     return false;
   }
   // Must perform an additional check, since applets may have their own version in their
   // AppContext
   return c instanceof Frame
       && (c == JOptionPane.getRootFrame()
           || c.getClass().getName().startsWith(ROOT_FRAME_CLASSNAME));
 }
Esempio n. 14
0
 private void inisialisasiAksi() {
   listener = new MemilihActionListener();
   Component[] komponens = panelMenu.getComponents();
   for (Component komponen : komponens) {
     if (komponen.getClass().getSimpleName().equals("Button")) {
       ((Button) komponen).addActionListener(listener);
       System.out.println("menambahkan listener ke " + ((Button) komponen).getActionCommand());
     }
   }
 }
Esempio n. 15
0
  private void toogle() {
    boolean selected = jRadioButtonMenuItem3.isSelected();

    for (Component comp : jTaskPane1.getComponents()) {
      if (comp.getClass().equals(MyAnunci.class)) {
        MyAnunci ma = (MyAnunci) comp;
        ma.setExpanded(selected);
      }
    }
  }
  /**
   * Builds a list of components (Component) for a form that are ordered in the default focus order.
   */
  public static LinkedHashSet buildDefaultFocusPolicy(FormComponent fc) {
    System.out.println("buildDefaultFocusPolicy  form: " + fc.getId());

    final FormComponent theform = fc;
    LinkedHashSet default_policy = new LinkedHashSet();
    LayoutFocusTraversalPolicy policy =
        new LayoutFocusTraversalPolicy() {
          protected boolean accept(Component aComponent) {
            if (aComponent instanceof StandardComponent) {
              if (((StandardComponent) aComponent).getBeanDelegate() == null) return false;
            }

            if (aComponent == theform) return super.accept(aComponent);

            if (aComponent instanceof FormComponent) {
              if (((FormComponent) aComponent).isTopLevelForm()) return false;
            }

            if (aComponent instanceof JTabbedPane) return true;

            if (aComponent != null) {
              /** handle the case for embedded focus cycle roots such as JTabbedPane forms */
              Container cc = aComponent.getParent();
              while (cc != null && cc != theform) {
                if (cc instanceof FormContainerComponent) {
                  return false;
                }

                cc = cc.getParent();
              }
            }
            return super.accept(aComponent);
          }
        };
    Component comp = policy.getFirstComponent(fc);
    Component last_comp = policy.getLastComponent(fc);
    while (true) {

      /** Don't add scroll pane in design mode since the scroll bars might not be visible */
      if (FormUtils.isDesignMode()) {
        if (!(comp instanceof JScrollPane) && !(comp instanceof JScrollBar)) {
          default_policy.add(comp);
        }
      } else {
        default_policy.add(comp);
      }

      if (comp == last_comp) break;

      System.out.println("FormFocusManager.getComponentAfter: " + comp.getClass());
      comp = policy.getComponentAfter(fc, comp);
    }

    return default_policy;
  }
 /** Checks that all focuskeys reference the correct components */
 public void validateFocusKeys(FormComponent root, FocusPolicyMemento memento) {
   Iterator iter = memento.getFocusPolicyKeys().iterator();
   while (iter.hasNext()) {
     FocusKey fkey = (FocusKey) iter.next();
     Component comp = fkey.getComponent(root);
     assert (comp != null);
     System.out.print("Focuskey validated: ");
     fkey.print();
     System.out.println("   comp: " + comp.getClass());
   }
 }
 /**
  * Update all components that have been published using {@link #createMenuBar()} and similar.
  * Content of such components will be removed and replaced by fresh components.
  */
 protected void updatePublishedComponents() {
   for (Entry<URI, List<WeakReference<Component>>> entry : uriToPublishedComponents.entrySet())
     for (WeakReference<Component> reference : entry.getValue()) {
       URI id = entry.getKey();
       Component component = reference.get();
       if (component == null) continue;
       if (component instanceof JToolBar) populateToolBar((JToolBar) component, id);
       else if (component instanceof JMenuBar) populateMenuBar((JMenuBar) component, id);
       else
         logger.warn("Could not update published component " + id + ": " + component.getClass());
     }
 }
Esempio n. 19
0
  public static Container getAncestorOfClass(
      final Class<?> wantedClass, final Component component) {
    if (component == null || wantedClass == null) {
      return null;
    }

    Component ancestor = null;
    for (ancestor = component.getParent();
        !((ancestor == null) || (wantedClass.isAssignableFrom(ancestor.getClass())));
        ancestor = ancestor.getParent()) {}
    return (Container) ancestor;
  }
Esempio n. 20
0
 /**
  * Returns whether the given AWT or Swing {@code Component} is a heavy-weight pop-up, that is, a
  * container for a {@code JPopupMenu} that is implemented with a heavy-weight component (usually
  * an AWT or Swing {@code Window}).
  *
  * <p><b>Note:</b> This method is accessed in the current executing thread. Such thread may or may
  * not be the event dispatch thread (EDT.) Client code must call this method from the EDT.
  *
  * @param c the given {@code Component}.
  * @return {@code true} if the given {@code Component} is a heavy-weight pop-up; {@code false}
  *     otherwise.
  */
 @RunsInCurrentThread
 public static boolean isHeavyWeightPopup(@Nonnull Component c) {
   if (!(c instanceof Window) || c instanceof Dialog || c instanceof Frame) {
     return false;
   }
   String name = obtainNameSafely(c);
   if ("###overrideRedirect###".equals(name) || "###focusableSwingPopup###".equals(name)) {
     return true;
   }
   String typeName = c.getClass().getName();
   return typeName.contains("PopupFactory$WindowPopup") || typeName.contains("HeavyWeightWindow");
 }
Esempio n. 21
0
 /*
  * Ritorna true se un GestionePersonaPanel con tale id è già aperto
  */
 public boolean isAperto(int id) {
   if (id == Costanti.ID_NUOVA_PERSONA) return false;
   int count = getTabbedPaneDx().getTabCount();
   for (int i = 0; i < count; i++) {
     java.awt.Component jpnl = getTabbedPaneDx().getComponentAt(i);
     if (jpnl instanceof GestionePersonaPanel) {
       if (((GestionePersonaPanel) jpnl).getId() == id && id != Costanti.ID_NUOVA_PERSONA) {
         return true;
       }
     } else System.out.println(jpnl.getClass().toString());
   }
   return false;
 }
 public String toString() {
   return "Repaint("
       + component.getClass().getName()
       + "@"
       + x
       + ","
       + y
       + " "
       + w
       + "x"
       + h
       + ")";
 }
Esempio n. 23
0
 /** Return the semantic recorder for the given component. */
 private SemanticRecorder getSemanticRecorder(Component comp) {
   // FIXME extract into AWT.getLAFParent?
   // Account for LAF implementations that use a JButton on top
   // of the combo box
   if ((comp instanceof JButton) && (comp.getParent() instanceof JComboBox)) {
     comp = comp.getParent();
   }
   // Account for LAF components of JInternalFrame
   else if (AWT.isInternalFrameDecoration(comp)) {
     while (!(comp instanceof JInternalFrame)) comp = comp.getParent();
   }
   return getSemanticRecorder(comp.getClass());
 }
Esempio n. 24
0
 /** Construit l'affichage du calendrier */
 public void build() {
   int col = 0;
   // D'abord on le vide
   for (Component component : getComponents()) {
     if (component.getClass() == JCalendarEvent.class) {
       remove(component);
     }
   }
   // Puis on le rempli
   for (JCalendarEvent jEvent : eventsList) {
     addEvent(jEvent);
     col++;
   }
 }
 @SuppressWarnings("unchecked")
 public <E extends Component> List<E> getTabsOfClass(Class<E> clazz) {
   List<E> list = new ArrayList<E>();
   Component[] components = getComponents();
   for (Component component : components) {
     if (component instanceof JScrollPane) {
       component = ((JScrollPane) component).getViewport().getComponent(0);
     }
     if (clazz.isAssignableFrom(component.getClass())) {
       list.add((E) component);
     }
   }
   return list;
 }
Esempio n. 26
0
  /**
   * @param aContainer
   * @param aComponentClass
   * @return
   */
  private static Component findComponent(
      final Container aContainer, final Class<? extends Component> aComponentClass) {
    Component result = null;

    final int cnt = aContainer.getComponentCount();
    for (int i = 0; (result == null) && (i < cnt); i++) {
      final Component comp = aContainer.getComponent(i);
      if (aComponentClass.equals(comp.getClass())) {
        result = comp;
      } else if (comp instanceof Container) {
        result = findComponent((Container) comp, aComponentClass);
      }
    }
    return result;
  }
Esempio n. 27
0
 private static Method getBRBIMethod(Component component) {
   Class klass = component.getClass();
   while (klass != null) {
     if (BRB_I_MAP.containsKey(klass)) {
       Method method = (Method) BRB_I_MAP.get(klass);
       return method;
     }
     klass = klass.getSuperclass();
   }
   klass = component.getClass();
   Method[] methods = klass.getMethods();
   for (int i = methods.length - 1; i >= 0; i--) {
     Method method = methods[i];
     if ("getBaselineResizeBehaviorInt".equals(method.getName())) {
       Class[] params = method.getParameterTypes();
       if (params.length == 0) {
         BRB_I_MAP.put(klass, method);
         return method;
       }
     }
   }
   BRB_I_MAP.put(klass, null);
   return null;
 }
Esempio n. 28
0
  public static JFileChooser getJFileChooser(String defaultName) {
    JFileChooser jfcWorkFolder = new JFileChooser(defaultName);
    try {
      JPanel cons = (JPanel) jfcWorkFolder.getComponent(3);
      Component jp = cons.getComponent(0);
      System.out.println(jp.getClass());
      JPanel la = (JPanel) jp;
      JLabel jl = (JLabel) la.getComponent(0);
      System.out.println(jl.getText());
      jl.setText("文件路径:");

    } catch (Exception e) {

    }

    return jfcWorkFolder;
  }
Esempio n. 29
0
  @SuppressWarnings("unchecked")
  public static void removeListeners(Component comp) {
    Method[] methods = comp.getClass().getMethods();
    for (int i = 0; i < methods.length; i++) {
      Method method = methods[i];
      String name = method.getName();
      if (name.startsWith("remove") && name.endsWith("Listener")) {

        Class[] params = method.getParameterTypes();
        if (params.length == 1) {
          EventListener[] listeners = null;
          try {
            listeners = comp.getListeners(params[0]);
          } catch (Exception e) {
            // It is possible that someone could create a listener
            // that doesn't extend from EventListener.  If so,ignore it
            //// System.out.println("Listener " + params[0] + " does not extend EventListener");
            continue;
          }
          for (int j = 0; j < listeners.length; j++) {
            try {
              method.invoke(comp, new Object[] {listeners[j]});
              listeners[j] = null;
              //// System.out.println("removed Listener " + name + "+ for comp " + comp );
            } catch (Exception e) {
              // //System.out.println("Cannot invoke removeListener method " + e);
              // Continue on.  The reason for removing alllisteners is to
              // make sure that we don't have a listener holdingon to something
              // which will keep it from being garbage collected.We want to
              // continue freeing listeners to make sure we canfree as much
              // memory has possible
            }
          }
        } else {
          // The only Listener method that I know of that has more than
          // one argument is removePropertyChangeListener.  If it is
          // something other than that, flag it and move on.
          // if (!name.equals("removePropertyChangeListener"))
          // System.out.println("    Wrong number of Args " + name);
        }
      }
    }
    comp = null;
  }
Esempio n. 30
0
    public RecordAction(Component comp) {
      super("", new ImageIcon(comp.getClass().getResource("/resource/icon/Record24.gif")));
      component = comp;
      fileChooser = new JFileChooser();
      fileChooser.setCurrentDirectory(new File(System.getProperty("user.dir")));
      fileChooser.setAcceptAllFileFilterUsed(true);
      fileChooser.resetChoosableFileFilters();
      fileChooser.setMultiSelectionEnabled(false);
      fileChooser.addChoosableFileFilter(
          new FileFilter() {
            public boolean accept(File f) {
              return f.isDirectory() || f.getName().endsWith(".avi");
            }

            public String getDescription() {
              return "Microsoft Video Format (*.avi)";
            }
          });
    }