コード例 #1
0
ファイル: JRehaInternal.java プロジェクト: bomm/thera-pi
 public void destroyTitleBar() {
   int comp = nord.getComponentCount();
   Component icomp;
   for (int i = 0; i < comp; i++) {
     icomp = nord.getComponent(i);
     if (icomp != null) {
       ListenerTools.removeListeners(icomp);
       icomp = null;
     }
   }
   ListenerTools.removeListeners(thisContent);
   comp = thisContent.getComponentCount();
   for (int i = 0; i < comp; i++) {
     icomp = thisContent.getComponent(i);
     if (icomp != null) {
       ListenerTools.removeListeners(icomp);
       icomp = null;
     }
   }
   ListenerTools.removeListeners(inhalt);
   comp = inhalt.getComponentCount();
   for (int i = 0; i < comp; i++) {
     icomp = inhalt.getComponent(i);
     if (icomp != null) {
       ListenerTools.removeListeners(icomp);
       icomp = null;
     }
   }
 }
コード例 #2
0
ファイル: BoxLayoutTest.java プロジェクト: kalwar/metawidget
  public void testLayout() throws Exception {

    SwingMetawidget metawidget = new SwingMetawidget();
    JComponent container = new JPanel();

    // startLayout

    BoxLayout boxLayout = new BoxLayout();
    boxLayout.startContainerLayout(container, metawidget);

    assertTrue(container.getLayout() instanceof javax.swing.BoxLayout);
    assertFalse((metawidget.getLayout() instanceof javax.swing.BoxLayout));

    // layoutWidget

    assertEquals(0, container.getComponentCount());

    Stub stub = new Stub();
    boxLayout.layoutWidget(stub, PROPERTY, null, container, metawidget);
    assertEquals(0, container.getComponentCount());

    stub.add(new JSpinner());
    boxLayout.layoutWidget(stub, PROPERTY, null, container, metawidget);
    assertEquals(stub, container.getComponent(0));
    assertEquals(1, container.getComponentCount());

    boxLayout.layoutWidget(new JTextField(), PROPERTY, null, container, metawidget);
    assertTrue(container.getComponent(1) instanceof JTextField);
    assertEquals(2, container.getComponentCount());
  }
コード例 #3
0
 public void testCardLayoutShow() throws Exception {
   JComponent rootComponent =
       getInstrumentedRootComponent("TestCardLayoutShow.form", "BindingTest");
   assertTrue(rootComponent.getLayout() instanceof CardLayout);
   assertEquals(rootComponent.getComponentCount(), 2);
   assertFalse(rootComponent.getComponent(0).isVisible());
   assertTrue(rootComponent.getComponent(1).isVisible());
 }
コード例 #4
0
ファイル: StatusComponent.java プロジェクト: omusico/siga
  /**
   * Guarda el estado de un componente. Este proceso es recursivo. El estado se guarda en un array y
   * este array no es vaciado inicialmente. La idea es guardar en un disabled y recuperar en un
   * enabled y asegurarse que no puede ocurrir un disabled o un enabled dos veces.
   *
   * @param component
   */
  private void saveComponentsStatus(JComponent component) {
    // Guardar estado
    StatusComponentStruct auxStatus = new StatusComponentStruct();
    auxStatus.setEnabled(component.isEnabled());
    auxStatus.setObject(component);
    statusList.add(auxStatus);

    for (int i = 0; i < component.getComponentCount(); i++)
      if (component.getComponent(i) instanceof JComponent)
        saveComponentsStatus((JComponent) component.getComponent(i));
  }
コード例 #5
0
  @Override
  public JComponent config() {
    FormLayout layout =
        new FormLayout("left:pref, 0:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, 0:grow");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator("Audio settings", cc.xyw(2, 1, 1));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    noresample = new JCheckBox(Messages.getString("TrTab2.22"));
    noresample.setContentAreaFilled(false);
    noresample.setSelected(configuration.isAudioResample());
    noresample.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setAudioResample(e.getStateChange() == ItemEvent.SELECTED);
          }
        });
    builder.add(noresample, cc.xy(2, 3));

    return builder.getPanel();
  }
コード例 #6
0
 public void testIntProperty() throws Exception {
   JComponent rootComponent = getInstrumentedRootComponent("TestIntProperty.form", "BindingTest");
   assertEquals(1, rootComponent.getComponentCount());
   JTextField textField = (JTextField) rootComponent.getComponent(0);
   assertEquals(37, textField.getColumns());
   assertEquals(false, textField.isEnabled());
 }
コード例 #7
0
  @Override
  public JComponent config() {
    FormLayout layout =
        new FormLayout("left:pref, 3dlu, p, 3dlu, 0:grow", "p, 3dlu, p, 3dlu, 0:grow");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 5));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("FFMpegDVRMSRemux.0"), cc.xy(1, 3));
    altffpath = new JTextField(PMS.getConfiguration().getFfmpegAlternativePath());
    altffpath.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            PMS.getConfiguration().setFfmpegAlternativePath(altffpath.getText());
          }
        });
    builder.add(altffpath, cc.xyw(3, 3, 3));

    return builder.getPanel();
  }
コード例 #8
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
 public void mouseClicked(MouseEvent e) {
   JComponent c = (JComponent) e.getSource();
   if (!(c instanceof AbstractButton)) {
     AbstractButton b = (AbstractButton) c.getComponent(0);
     b.doClick();
   }
 }
コード例 #9
0
  private static void processSideBars(Map sideBars, JComponent ec) {
    JScrollPane scroller = (JScrollPane) ec.getComponent(0);

    // Remove all existing sidebars
    ec.removeAll();

    // Add the scroller and the new sidebars
    ec.add(scroller);
    scroller.setRowHeader(null);
    scroller.setColumnHeaderView(null);
    //        final MouseDispatcher mouse = new MouseDispatcher((JTextComponent)
    // ec.getClientProperty(JTextComponent.class));
    for (Iterator entries = sideBars.entrySet().iterator(); entries.hasNext(); ) {
      Map.Entry entry = (Map.Entry) entries.next();
      SideBarPosition position = (SideBarPosition) entry.getKey();
      JComponent sideBar = (JComponent) entry.getValue();

      //            if (position.getPosition() == SideBarPosition.WEST) {
      //                JPanel p = new JPanel(new BorderLayout()) {
      //
      //                    @Override
      //                    public void addNotify() {
      //                        super.addNotify();
      //                        infiltrateContainer(this, mouse, true);
      //                    }
      //
      //                    @Override
      //                    public void removeNotify() {
      //                        infiltrateContainer(this, mouse, false);
      //                        super.removeNotify();
      //                    }
      //
      //                };
      //                p.add(sideBar, BorderLayout.CENTER);
      //                sideBar = p;
      //            }

      if (position.isScrollable()) {
        if (position.getPosition() == SideBarPosition.WEST) {
          scroller.setRowHeaderView(sideBar);
        } else {
          if (position.getPosition() == SideBarPosition.NORTH) {
            scroller.setColumnHeaderView(sideBar);
          } else {
            throw new IllegalArgumentException(
                "Unsupported side bar position, scrollable = true, position="
                    + position.getBorderLayoutPosition()); // NOI18N
          }
        }
      } else {
        ec.add(sideBar, position.getBorderLayoutPosition());
      }
    }
  }
コード例 #10
0
ファイル: SchemaBox.java プロジェクト: KenaDess/limewire
 public void mouseExited(MouseEvent e) {
   JComponent c = (JComponent) e.getSource();
   AbstractButton b;
   if (c instanceof AbstractButton) {
     b = (AbstractButton) c;
     c = (JComponent) c.getParent();
   } else {
     b = (AbstractButton) c.getComponent(0);
   }
   if (!b.isSelected()) setIfNotNull(c, "TabbedPane.background");
 }
コード例 #11
0
  @Nullable
  private static JScrollBar findHorizontalScrollBar(Component c) {
    if (c == null) return null;
    if (c instanceof JScrollPane) {
      return ((JScrollPane) c).getHorizontalScrollBar();
    }

    if (isDiagramViewComponent(c)) {
      final JComponent view = (JComponent) c;
      for (int i = 0; i < view.getComponentCount(); i++) {
        if (view.getComponent(i) instanceof JScrollBar) {
          final JScrollBar scrollBar = (JScrollBar) view.getComponent(i);
          if (scrollBar.getOrientation() == Adjustable.HORIZONTAL) {
            return scrollBar;
          }
        }
      }
    }
    return findHorizontalScrollBar(c.getParent());
  }
コード例 #12
0
 private static int getSplitCount(JComponent component) {
   if (component.getComponentCount() > 0) {
     final JComponent firstChild = (JComponent) component.getComponent(0);
     if (firstChild instanceof Splitter) {
       final Splitter splitter = (Splitter) firstChild;
       return getSplitCount(splitter.getFirstComponent())
           + getSplitCount(splitter.getSecondComponent());
     }
     return 1;
   }
   return 0;
 }
コード例 #13
0
ファイル: StatusComponent.java プロジェクト: omusico/siga
  /**
   * Recupera el estado de un componente y todos sus hijos, vaciando la pila de estados. Eso quiere
   * decir que no se podra volver a recuperar su estado sin haberlo guardado previamente.
   *
   * @param component
   */
  private void restoreStatus(JComponent component) {
    boolean auxEnabled = false;
    boolean finded = false;
    // Buscar estado de dicho componente
    for (int i = 0; i < statusList.size(); i++) {
      StatusComponentStruct auxStatus = (StatusComponentStruct) statusList.get(i);
      if (auxStatus.getObject() == component) {
        auxEnabled = auxStatus.isEnabled();
        statusList.remove(i);
        finded = true;
        break;
      }
    }

    // Asignar su estado
    if (finded) component.setEnabled(auxEnabled);

    for (int i = 0; i < component.getComponentCount(); i++)
      if (component.getComponent(i) instanceof JComponent)
        restoreStatus((JComponent) component.getComponent(i));
  }
コード例 #14
0
ファイル: SetFrameComponent.java プロジェクト: naduda/Reports
  public void setReports(JComponent menu, CreateReport cReport) {
    if (menu.getClass() == JMenuBar.class) {
      for (int i = 0; i < menu.getComponentCount(); i++) {
        setReports((JComponent) menu.getComponent(i), cReport);
      }
    } else if (menu.getClass() == JMenu.class) {
      for (int i = 0; i < ((JMenu) menu).getItemCount(); i++) {
        JMenuItem item = ((JMenu) menu).getItem(i);
        if (item.getClass() == JMenuItem.class) {
          Template template = new Template();

          template.setDataTemplate(
              ToolsPrLib.getFullPath((String) item.getClientProperty("dataTemplate")));
          template.setId((String) item.getClientProperty("uniqueID"));
          template.setName((String) item.getClientProperty("name"));
          template.setParams((String) item.getClientProperty("params"));
          template.setQuery((String) item.getClientProperty("query"));
          template.setRtfTemplate(
              ToolsPrLib.getFullPath((String) item.getClientProperty("rtfTemplate")));

          String uniqueID = (String) item.getClientProperty("uniqueID");
          if (uniqueID.indexOf("Export") >= 0) {
            String format = (String) item.getClientProperty("format");
            Byte fopFormat = 0;
            if (format.toLowerCase().equals("excel")) {
              fopFormat = FOProcessor.FORMAT_EXCEL;
            } else if (format.toLowerCase().equals("pdf")) {
              fopFormat = FOProcessor.FORMAT_PDF;
            } else if (format.toLowerCase().equals("gif")) {
              fopFormat = FOProcessor.FORMAT_IMAGE_GIF;
            } else if (format.toLowerCase().equals("rtf")) {
              fopFormat = FOProcessor.FORMAT_RTF;
            }

            item.addActionListener(new ActionListenerJMenuItem(fopFormat, cReport));
          } else {
            item.addActionListener(
                new ActionListenerJMenuItem(template, mainFrame.getLbActiveReport(), cReport));
          }

          String def = (String) item.getClientProperty("default");
          if ((def != null) && (def.toString().toLowerCase().equals("true"))) {

            mainFrame.getCreateReport().setTemplate(template);
            mainFrame.getLbActiveReport().setText(template.getName());
          }
        } else if (item.getClass() == JMenu.class) {
          setReports((JMenu) item, cReport);
        }
      }
    }
  }
コード例 #15
0
 /** Sets an empty border with consistent insets. */
 private void configureEditorBorder(JComponent editor) {
   if ((editor instanceof JSpinner.DefaultEditor)) {
     JSpinner.DefaultEditor defaultEditor = (JSpinner.DefaultEditor) editor;
     JTextField editorField = defaultEditor.getTextField();
     Insets insets = UIManager.getInsets("Spinner.defaultEditorInsets");
     editorField.setBorder(new EmptyBorder(insets));
   } else if ((editor instanceof JPanel)
       && (editor.getBorder() == null)
       && (editor.getComponentCount() > 0)) {
     JComponent editorField = (JComponent) editor.getComponent(0);
     Insets insets = UIManager.getInsets("Spinner.defaultEditorInsets");
     editorField.setBorder(new EmptyBorder(insets));
   }
 }
コード例 #16
0
    protected void clear(JComponent comp) {
      int nCompCount = comp.getComponentCount();
      ArrayList aListComps = new ArrayList();

      for (int i = 0; i < comp.getComponentCount(); i++) {
        Component compChild = comp.getComponent(i);
        if (compChild instanceof JComponent) {
          JComponent jcomp = (JComponent) compChild;
          if (jcomp instanceof JCheckBox || jcomp instanceof JTextField) aListComps.add(comp);
          else clear(jcomp);
        }
      }
      clear(aListComps);
    }
コード例 #17
0
 private JButton getButton(int direction) {
   if (_directionPanel == null) {
     return null;
   }
   for (int i = 0; i < _directionPanel.getComponentCount(); i++) {
     Component component = _directionPanel.getComponent(i);
     if (component instanceof DirectionButton) {
       if (((DirectionButton) component).getDirection() == direction) {
         return ((DirectionButton) component);
       }
     }
   }
   return null;
 }
コード例 #18
0
  public boolean isToDrawMacCorner() {
    if (!SystemInfo.isMac || myComponent.getComponentCount() <= 0) {
      return false;
    }

    if (myComponent.getComponentCount() > 0) {
      Component component = myComponent.getComponent(0);
      if (component instanceof JComponent
          && Boolean.TRUE.equals(((JComponent) component).getClientProperty(SUPPRESS_MAC_CORNER))) {
        return false;
      }
    }

    return true;
  }
コード例 #19
0
    /** Initializes the layout of this view. */
    protected void initializeLayout() {
      GridBagConstraints constraints = new GridBagConstraints();

      // Name widgets
      JComponent nameWidgets =
          buildLabeledTextField("LOGIN_PROPERTY_EDITOR_NAME_FIELD", buildNameDocumentAdapter());

      constraints.gridx = 0;
      constraints.gridy = 0;
      constraints.gridwidth = 1;
      constraints.gridheight = 1;
      constraints.weightx = 1;
      constraints.weighty = 0;
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.anchor = GridBagConstraints.CENTER;
      constraints.insets = new Insets(0, 0, 0, 0);

      add(nameWidgets, constraints);
      putClientProperty("initialFocus", nameWidgets.getComponent(1));

      // Value widgets
      JComponent valueWidgets =
          buildLabeledTextField("LOGIN_PROPERTY_EDITOR_VALUE_FIELD", buildValueDocumentAdapter());

      constraints.gridx = 0;
      constraints.gridy = 1;
      constraints.gridwidth = 1;
      constraints.gridheight = 1;
      constraints.weightx = 1;
      constraints.weighty = 1;
      constraints.fill = GridBagConstraints.HORIZONTAL;
      constraints.anchor = GridBagConstraints.PAGE_START;
      constraints.insets = new Insets(5, 0, 0, 0);

      add(valueWidgets, constraints);
    }
コード例 #20
0
ファイル: StatusComponent.java プロジェクト: omusico/siga
 /**
  * Desactivar el componente y todos sus hijos sin guardar los estados. Hay que tener cuidado con
  * no confundirlo con setEnabled(false). Este metodo nunca guardara el estado, asi que no se podra
  * recuperar despues dicho estado.
  *
  * @param component
  */
 public static void setDisabled(JComponent component) {
   component.setEnabled(false);
   for (int i = 0; i < component.getComponentCount(); i++)
     if (component.getComponent(i) instanceof JComponent)
       setDisabled((JComponent) component.getComponent(i));
 }
コード例 #21
0
 public void testClientProp() throws Exception { // IDEA-46372
   JComponent rootComponent = getInstrumentedRootComponent("TestClientProp.form", "BindingTest");
   assertEquals(1, rootComponent.getComponentCount());
   JTable table = (JTable) rootComponent.getComponent(0);
   assertSame(Boolean.TRUE, table.getClientProperty("terminateEditOnFocusLost"));
 }
コード例 #22
0
 public void testStringProperty() throws Exception {
   JComponent rootComponent =
       getInstrumentedRootComponent("TestGridConstraints.form", "BindingTest");
   JButton btn = (JButton) rootComponent.getComponent(0);
   assertEquals("MyTestButton", btn.getText());
 }
コード例 #23
0
  public static void main(String args[]) {
    JComponent ch = new JComponent() {};
    ch.getAccessibleContext();
    ch.isFocusTraversable();
    ch.setEnabled(false);
    ch.setEnabled(true);
    ch.requestFocus();
    ch.requestFocusInWindow();
    ch.getPreferredSize();
    ch.getMaximumSize();
    ch.getMinimumSize();
    ch.contains(1, 2);
    Component c1 = ch.add(new Component() {});
    Component c2 = ch.add(new Component() {});
    Component c3 = ch.add(new Component() {});
    Insets ins = ch.getInsets();
    ch.getAlignmentY();
    ch.getAlignmentX();
    ch.getGraphics();
    ch.setVisible(false);
    ch.setVisible(true);
    ch.setForeground(Color.red);
    ch.setBackground(Color.red);
    for (String font : Toolkit.getDefaultToolkit().getFontList()) {
      for (int j = 8; j < 17; j++) {
        Font f1 = new Font(font, Font.PLAIN, j);
        Font f2 = new Font(font, Font.BOLD, j);
        Font f3 = new Font(font, Font.ITALIC, j);
        Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j);

        ch.setFont(f1);
        ch.setFont(f2);
        ch.setFont(f3);
        ch.setFont(f4);

        ch.getFontMetrics(f1);
        ch.getFontMetrics(f2);
        ch.getFontMetrics(f3);
        ch.getFontMetrics(f4);
      }
    }
    ch.enable();
    ch.disable();
    ch.reshape(10, 10, 10, 10);
    ch.getBounds(new Rectangle(1, 1, 1, 1));
    ch.getSize(new Dimension(1, 2));
    ch.getLocation(new Point(1, 2));
    ch.getX();
    ch.getY();
    ch.getWidth();
    ch.getHeight();
    ch.isOpaque();
    ch.isValidateRoot();
    ch.isOptimizedDrawingEnabled();
    ch.isDoubleBuffered();
    ch.getComponentCount();
    ch.countComponents();
    ch.getComponent(1);
    ch.getComponent(2);
    Component[] cs = ch.getComponents();
    ch.getLayout();
    ch.setLayout(new FlowLayout());
    ch.doLayout();
    ch.layout();
    ch.invalidate();
    ch.validate();
    ch.remove(0);
    ch.remove(c2);
    ch.removeAll();
    ch.preferredSize();
    ch.minimumSize();
    ch.getComponentAt(1, 2);
    ch.locate(1, 2);
    ch.getComponentAt(new Point(1, 2));
    ch.isFocusCycleRoot(new Container());
    ch.transferFocusBackward();
    ch.setName("goober");
    ch.getName();
    ch.getParent();
    ch.getGraphicsConfiguration();
    ch.getTreeLock();
    ch.getToolkit();
    ch.isValid();
    ch.isDisplayable();
    ch.isVisible();
    ch.isShowing();
    ch.isEnabled();
    ch.enable(false);
    ch.enable(true);
    ch.enableInputMethods(false);
    ch.enableInputMethods(true);
    ch.show();
    ch.show(false);
    ch.show(true);
    ch.hide();
    ch.getForeground();
    ch.isForegroundSet();
    ch.getBackground();
    ch.isBackgroundSet();
    ch.getFont();
    ch.isFontSet();
    Container c = new Container();
    c.add(ch);
    ch.getLocale();
    for (Locale locale : Locale.getAvailableLocales()) ch.setLocale(locale);

    ch.getColorModel();
    ch.getLocation();

    boolean exceptions = false;
    try {
      ch.getLocationOnScreen();
    } catch (IllegalComponentStateException e) {
      exceptions = true;
    }
    if (!exceptions)
      throw new RuntimeException("IllegalComponentStateException did not occur when expected");

    ch.location();
    ch.setLocation(1, 2);
    ch.move(1, 2);
    ch.setLocation(new Point(1, 2));
    ch.getSize();
    ch.size();
    ch.setSize(1, 32);
    ch.resize(1, 32);
    ch.setSize(new Dimension(1, 32));
    ch.resize(new Dimension(1, 32));
    ch.getBounds();
    ch.bounds();
    ch.setBounds(10, 10, 10, 10);
    ch.setBounds(new Rectangle(10, 10, 10, 10));
    ch.isLightweight();
    ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    ch.getCursor();
    ch.isCursorSet();
    ch.inside(1, 2);
    ch.contains(new Point(1, 2));
    ch.isFocusable();
    ch.setFocusable(true);
    ch.setFocusable(false);
    ch.transferFocus();
    ch.getFocusCycleRootAncestor();
    ch.nextFocus();
    ch.transferFocusUpCycle();
    ch.hasFocus();
    ch.isFocusOwner();
    ch.toString();
    ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    ch.setComponentOrientation(ComponentOrientation.UNKNOWN);
    ch.getComponentOrientation();
  }
コード例 #24
0
  private void doSort() {
    if (mustSort && getComponentSpacing() < 0 && componentBox.getComponentCount() > 0) {
      setIgnoreAddRemoveNotify(true);

      mustSort = false;
      Component c;
      Component tc = topComponent != null ? topComponent.getComponent() : null;

      // componentBoxEnabled = false;

      // long millis = System.currentTimeMillis();

      int index = 0;
      if (tc != null) {
        if (componentBox.getComponent(0) != tc) {
          componentBox.remove(tc);
          componentBox.add(tc, index);
        }
        index++;
      }

      int switc = 0;
      int size = layoutOrderList.size();
      for (int i = 0; i < size; i++) {
        c = (Component) layoutOrderList.get(doReverseSort ? size - i - 1 : i);
        if (c != tc) {
          if (componentBox.getComponent(index) != c) {
            switc++;
            componentBox.remove(c);
            componentBox.add(c, index);
          }
          index++;
        }
      }

      setIgnoreAddRemoveNotify(false);

      /*System.out.print("  Box:   ");
      for (int i = 0; i < componentBox.getComponentCount(); i++)
        System.out.print(componentBox.getComponent(i) + "  ");
      System.out.println();
      System.out.print("  Order: ");
      for (int i = 0; i < layoutOrderList.size(); i++)
        System.out.print(layoutOrderList.get(i) + "  ");*/
      // System.out.println();
      /*			long millis = System.currentTimeMillis();
      componentBox.removeAll();

      if (tc != null)
      	componentBox.add(tc);

      int size = layoutOrderList.size();
      for (int i = 0; i < size; i++) {
      	c = (Component) layoutOrderList.get(doReverseSort ? size - i - 1 : i);
      	if (c != tc)
      		componentBox.add(c);
      }*/

      // componentBoxEnabled = true;

      // System.out.println("Sorting " + scount++ + "  time: " + (System.currentTimeMillis() -
      // millis) + "  Sorted: " + switc);
    }
  }
コード例 #25
0
  public JComponent buildCommon() {
    String colSpec = FormLayoutUtil.getColSpec(COMMON_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, COMMON_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    maxbuffer = new JTextField("" + configuration.getMaxMemoryBufferSize());
    maxbuffer.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(maxbuffer.getText());
              configuration.setMaxMemoryBufferSize(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse max memory buffer size from \"" + maxbuffer.getText() + "\"");
            }
          }
        });

    JComponent cmp =
        builder.addSeparator(
            Messages.getString("NetworkTab.5"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("TrTab2.23")
            .replaceAll("MAX_BUFFER_SIZE", configuration.getMaxMemoryBufferSizeStr()),
        FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation));
    builder.add(maxbuffer, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.24") + Runtime.getRuntime().availableProcessors() + ")",
        FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation));

    String[] guiCores = new String[MAX_CORES];
    for (int i = 0; i < MAX_CORES; i++) {
      guiCores[i] = Integer.toString(i + 1);
    }
    nbcores = new JComboBox(guiCores);
    nbcores.setEditable(false);
    int nbConfCores = configuration.getNumberOfCpuCores();
    if (nbConfCores > 0 && nbConfCores <= MAX_CORES) {
      nbcores.setSelectedItem(Integer.toString(nbConfCores));
    } else {
      nbcores.setSelectedIndex(0);
    }

    nbcores.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setNumberOfCpuCores(Integer.parseInt(e.getItem().toString()));
          }
        });
    builder.add(nbcores, FormLayoutUtil.flip(cc.xy(3, 5), colSpec, orientation));

    chapter_interval = new JTextField("" + configuration.getChapterInterval());
    chapter_interval.setEnabled(configuration.isChapterSupport());
    chapter_interval.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(chapter_interval.getText());
              configuration.setChapterInterval(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse chapter interval from \"" + chapter_interval.getText() + "\"");
            }
          }
        });

    chapter_support = new JCheckBox(Messages.getString("TrTab2.52"));
    chapter_support.setContentAreaFilled(false);
    chapter_support.setSelected(configuration.isChapterSupport());

    chapter_support.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setChapterSupport((e.getStateChange() == ItemEvent.SELECTED));
            chapter_interval.setEnabled(configuration.isChapterSupport());
          }
        });

    builder.add(chapter_support, FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation));

    builder.add(chapter_interval, FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.3"),
            FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    channels =
        new JComboBox(
            new Object[] {
              Messages.getString("TrTab2.55"),
              Messages.getString("TrTab2.56") /*, "8 channels 7.1" */
            }); // 7.1 not supported by MPlayer :\
    channels.setEditable(false);
    if (configuration.getAudioChannelCount() == 2) {
      channels.setSelectedIndex(0);
    } else {
      channels.setSelectedIndex(1);
    }
    channels.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setAudioChannelCount(
                Integer.parseInt(e.getItem().toString().substring(0, 1)));
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.50"), FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));
    builder.add(channels, FormLayoutUtil.flip(cc.xy(3, 13), colSpec, orientation));

    forcePCM = new JCheckBox(Messages.getString("TrTab2.27"));
    forcePCM.setContentAreaFilled(false);
    if (configuration.isMencoderUsePcm()) {
      forcePCM.setSelected(true);
    }
    forcePCM.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderUsePcm(e.getStateChange() == ItemEvent.SELECTED);
          }
        });

    builder.add(forcePCM, FormLayoutUtil.flip(cc.xyw(1, 15, 3), colSpec, orientation));

    ac3remux =
        new JCheckBox(
            Messages.getString("TrTab2.26")
                + " "
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    ac3remux.setContentAreaFilled(false);
    if (configuration.isRemuxAC3()) {
      ac3remux.setSelected(true);
    }
    ac3remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setRemuxAC3((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(ac3remux, FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation));

    forceDTSinPCM =
        new JCheckBox(
            Messages.getString("TrTab2.28")
                + " "
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    forceDTSinPCM.setContentAreaFilled(false);
    if (configuration.isDTSEmbedInPCM()) {
      forceDTSinPCM.setSelected(true);
    }
    forceDTSinPCM.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            configuration.setDTSEmbedInPCM(forceDTSinPCM.isSelected());
            if (configuration.isDTSEmbedInPCM()) {
              JOptionPane.showMessageDialog(
                  (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                  Messages.getString("TrTab2.10"),
                  "Information",
                  JOptionPane.INFORMATION_MESSAGE);
            }
          }
        });

    builder.add(forceDTSinPCM, FormLayoutUtil.flip(cc.xyw(1, 19, 3), colSpec, orientation));

    abitrate = new JTextField("" + configuration.getAudioBitrate());
    abitrate.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(abitrate.getText());
              configuration.setAudioBitrate(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug("Could not parse audio bitrate from \"" + abitrate.getText() + "\"");
            }
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.29"), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation));
    builder.add(abitrate, FormLayoutUtil.flip(cc.xy(3, 21), colSpec, orientation));

    mpeg2remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.39")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    mpeg2remux.setContentAreaFilled(false);
    if (configuration.isMencoderRemuxMPEG2()) {
      mpeg2remux.setSelected(true);
    }
    mpeg2remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderRemuxMPEG2((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(mpeg2remux, FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.4"),
            FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("TrTab2.32"),
        FormLayoutUtil.flip(cc.xyw(1, 29, 3), colSpec, orientation));

    Object data[] =
        new Object[] {
          configuration.getMencoderMainSettings(), /* default */
          String.format(
              "keyint=5:vqscale=1:vqmin=2  /* %s */", Messages.getString("TrTab2.60")), /* great */
          String.format(
              "keyint=5:vqscale=1:vqmin=1  /* %s */",
              Messages.getString("TrTab2.61")), /* lossless */
          String.format(
              "keyint=5:vqscale=2:vqmin=3  /* %s */",
              Messages.getString("TrTab2.62")), /* good (wired) */
          String.format(
              "keyint=25:vqmax=5:vqmin=2  /* %s */",
              Messages.getString("TrTab2.63")), /* good (wireless) */
          String.format(
              "keyint=25:vqmax=7:vqmin=2  /* %s */",
              Messages.getString("TrTab2.64")), /* medium (wireless) */
          String.format(
              "keyint=25:vqmax=8:vqmin=3  /* %s */", Messages.getString("TrTab2.65")) /* low */
        };

    MyComboBoxModel cbm = new MyComboBoxModel(data);

    vq = new JComboBox(cbm);
    vq.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String s = (String) e.getItem();
              if (s.indexOf("/*") > -1) {
                s = s.substring(0, s.indexOf("/*")).trim();
              }
              configuration.setMencoderMainSettings(s);
            }
          }
        });
    vq.getEditor()
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              @Override
              public void keyPressed(KeyEvent e) {}

              @Override
              public void keyTyped(KeyEvent e) {}

              @Override
              public void keyReleased(KeyEvent e) {
                vq.getItemListeners()[0].itemStateChanged(
                    new ItemEvent(vq, 0, vq.getEditor().getItem(), ItemEvent.SELECTED));
              }
            });
    vq.setEditable(true);
    builder.add(vq, FormLayoutUtil.flip(cc.xyw(1, 31, 3), colSpec, orientation));

    String help1 = Messages.getString("TrTab2.39");
    help1 += Messages.getString("TrTab2.40");
    help1 += Messages.getString("TrTab2.41");
    help1 += Messages.getString("TrTab2.42");
    help1 += Messages.getString("TrTab2.43");
    help1 += Messages.getString("TrTab2.44");

    JTextArea decodeTips = new JTextArea(help1);
    decodeTips.setEditable(false);
    decodeTips.setBorder(BorderFactory.createEtchedBorder());
    decodeTips.setBackground(new Color(255, 255, 192));
    builder.add(decodeTips, FormLayoutUtil.flip(cc.xyw(1, 41, 3), colSpec, orientation));

    disableSubs = new JCheckBox(Messages.getString("TrTab2.51"));
    disableSubs.setContentAreaFilled(false);

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.7"),
            FormLayoutUtil.flip(cc.xyw(1, 33, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.add(disableSubs, FormLayoutUtil.flip(cc.xy(1, 35), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.8"), FormLayoutUtil.flip(cc.xy(1, 37), colSpec, orientation));

    notranscode = new JTextField(configuration.getNoTranscode());
    notranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setNoTranscode(notranscode.getText());
          }
        });
    builder.add(notranscode, FormLayoutUtil.flip(cc.xy(3, 37), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.9"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation));

    forcetranscode = new JTextField(configuration.getForceTranscode());
    forcetranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setForceTranscode(forcetranscode.getText());
          }
        });
    builder.add(forcetranscode, FormLayoutUtil.flip(cc.xy(3, 39), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
  }