Package javax.swing

Examples of javax.swing.JPanel


        ? GridBagConstraints.LINE_END
        : GridBagConstraints.LINE_START;
    Insets labelInsets = new Insets(0, 0, 5, 5);
    Insets componentInsets = new Insets(0, 0, 5, 0);
    if (this.controller.isPropertyEditable(FurnitureController.Property.ICON)) {
      JPanel iconPanel = new JPanel(new GridBagLayout());
      // Add dummy labels with a vertical weight of 1 at top and bottom of iconPanel
      // to keep iconComponent and rotationButtonsPanel in the middle
      // when grid bag fill constraint is BOTH for iconPanel.
      // If this constraint is set to HORIZONTAL only, iconPanel location may be lower
      // and may not be the first panel treated by the focus traversal algorithm
      iconPanel.add(new JLabel(), new GridBagConstraints(
          0, 0, 1, 1, 0, 1, GridBagConstraints.CENTER,
          GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
      iconPanel.add(this.iconComponent, new GridBagConstraints(
          0, 1, 1, 1, 0, 0, GridBagConstraints.CENTER,
          GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));
      if (this.controller.isPropertyEditable(FurnitureController.Property.MODEL_ROTATION)) {
        JPanel rotationButtonsPanel = new JPanel(new GridBagLayout()) {
            @Override
            public void applyComponentOrientation(ComponentOrientation o) {
              // Ignore panel orientation to ensure left button is always at left of panel
            }
          };
        rotationButtonsPanel.add(this.turnUpButton, new GridBagConstraints(
            1, 0, 1, 1, 0, 0, GridBagConstraints.SOUTH,
            GridBagConstraints.NONE, new Insets(0, 0, 2, 0), 0, 0));   
        rotationButtonsPanel.add(this.turnLeftButton, new GridBagConstraints(
            0, 1, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, new Insets(0, 0, 2, 2), 0, 0));
        rotationButtonsPanel.add(this.turnRightButton, new GridBagConstraints(
            2, 1, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 2, 2, 0), 0, 0));
        rotationButtonsPanel.add(this.turnDownButton, new GridBagConstraints(
            1, 2, 1, 1, 0, 0, GridBagConstraints.NORTH,
            GridBagConstraints.NONE, new Insets(0, 0, 2, 0), 0, 0));
        iconPanel.add(rotationButtonsPanel, new GridBagConstraints(
            0, 2, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
      }
      iconPanel.add(new JLabel(), new GridBagConstraints(
          0, 3, 1, 1, 0, 1, GridBagConstraints.CENTER,
          GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

      add(iconPanel, new GridBagConstraints(
          0, 0, 1, 15, 0, 0, GridBagConstraints.CENTER,
          GridBagConstraints.BOTH, new Insets(0, 0, 0, 15), 0, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.ID)) {
      add(this.idLabel, new GridBagConstraints(
          1, 0, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.idTextField, new GridBagConstraints(
          2, 0, 3, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.NAME)) {
      add(this.nameLabel, new GridBagConstraints(
          1, 1, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.nameTextField, new GridBagConstraints(
          2, 1, 3, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.DESCRIPTION)) {
      add(this.descriptionLabel, new GridBagConstraints(
          1, 2, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.descriptionTextField, new GridBagConstraints(
          2, 2, 3, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.CREATOR)) {
      add(this.creatorLabel, new GridBagConstraints(
          1, 3, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.creatorTextField, new GridBagConstraints(
          2, 3, 1, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), 0, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.CATEGORY)) {
      add(this.categoryLabel, new GridBagConstraints(
          3, 3, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.categoryComboBox, new GridBagConstraints(
          4, 3, 1, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, componentInsets, 0, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.PRICE)) {
      add(this.priceLabel, new GridBagConstraints(
          1, 4, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.priceSpinner, new GridBagConstraints(
          2, 4, 1, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), -10, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.VALUE_ADDED_TAX_PERCENTAGE)) {
      add(this.valueAddedTaxPercentageLabel, new GridBagConstraints(
          3, 4, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.valueAddedTaxPercentageSpinner, new GridBagConstraints(
          4, 4, 2, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.NONE, componentInsets, 10, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.WIDTH)) {
      add(this.widthLabel, new GridBagConstraints(
          1, 5, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.widthSpinner, new GridBagConstraints(
          2, 5, 1, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), -10, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.DEPTH)) {
      add(this.depthLabel, new GridBagConstraints(
          3, 5, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.depthSpinner, new GridBagConstraints(
          4, 5, 1, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, componentInsets, -10, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.HEIGHT)) {
      add(this.heightLabel, new GridBagConstraints(
          1, 6, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.heightSpinner, new GridBagConstraints(
          2, 6, 1, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 10), -10, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.ELEVATION)) {
      add(this.elevationLabel, new GridBagConstraints(
          3, 6, 1, 1, 0, 0, labelAlignment,
          GridBagConstraints.NONE, labelInsets, 0, 0));
      add(this.elevationSpinner, new GridBagConstraints(
          4, 6, 1, 1, 0, 0, GridBagConstraints.LINE_START,
          GridBagConstraints.HORIZONTAL, componentInsets, -10, 0));
    }
    if (this.controller.isPropertyEditable(FurnitureController.Property.PROPORTIONAL)) {
      JPanel multiplySizePanel = new JPanel();
      multiplySizePanel.add(this.enlargeTenTimesButton);
      multiplySizePanel.add(this.reduceTenTimesButton);
      multiplySizePanel.add(this.enlargeInchTimesButton);
      add(multiplySizePanel, new GridBagConstraints(
          1, 7, 3, 1, 0, 0, GridBagConstraints.CENTER,
          GridBagConstraints.NONE, componentInsets, 0, 0));
      add(this.keepProportionsCheckBox, new GridBagConstraints(
          4, 7, 1, 1, 0, 0, GridBagConstraints.LINE_START,
View Full Code Here


  if (e instanceof GenericObjectEditor) {
    //    ((GenericObjectEditor) e).setDisplayOnly(true);
    ((GenericObjectEditor) e).setClassType(m_ValueClass);
  }
  e.setValue(value);
  return new JPanel() {
   
    private static final long serialVersionUID = -3124434678426673334L;

    public void paintComponent(Graphics g) {
View Full Code Here

    // Close any child windows at this point
    removeAll();

    setLayout(new BorderLayout());
    JPanel scrollablePanel = new JPanel();
    JScrollPane scrollPane = new JScrollPane(scrollablePanel);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    add(scrollPane, BorderLayout.CENTER);
   
    GridBagLayout gbLayout = new GridBagLayout();

    scrollablePanel.setLayout(gbLayout);
    setVisible(false);
    m_NumEditable = 0;
    m_Target = targ;
    try {
      BeanInfo bi = Introspector.getBeanInfo(m_Target.getClass());
      m_Properties = bi.getPropertyDescriptors();
      m_Methods = bi.getMethodDescriptors();
    } catch (IntrospectionException ex) {
      System.err.println("PropertySheet: Couldn't introspect");
      return;
    }

    JTextArea jt = new JTextArea();
    m_HelpText = null;
    // Look for a globalInfo method that returns a string
    // describing the target
    for (int i = 0;i < m_Methods.length; i++) {
      String name = m_Methods[i].getDisplayName();
      Method meth = m_Methods[i].getMethod();
      if (name.equals("globalInfo")) {
  if (meth.getReturnType().equals(String.class)) {
    try {
      Object args[] = { };
      String globalInfo = (String)(meth.invoke(m_Target, args));
            String summary = globalInfo;
            int ci = globalInfo.indexOf('.');
            if (ci != -1) {
              summary = globalInfo.substring(0, ci + 1);
            }
      final String className = targ.getClass().getName();
            m_HelpText = new StringBuffer("NAME\n");
            m_HelpText.append(className).append("\n\n");
            m_HelpText.append("SYNOPSIS\n").append(globalInfo).append("\n\n");
            m_HelpBut = new JButton("More");
      m_HelpBut.setToolTipText("More information about "
                                     + className);
     
      m_HelpBut.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent a) {
                openHelpFrame();
                m_HelpBut.setEnabled(false);
              }
            });

      if (m_Target instanceof CapabilitiesHandler) {
        m_CapabilitiesBut = new JButton("Capabilities");
        m_CapabilitiesBut.setToolTipText("The capabilities of "
      + className);
       
        m_CapabilitiesBut.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent a) {
      openCapabilitiesHelpDialog();
      m_CapabilitiesBut.setEnabled(false);
    }
        });
      }
      else {
        m_CapabilitiesBut = null;
      }

      jt.setColumns(30);
      jt.setFont(new Font("SansSerif", Font.PLAIN,12));
      jt.setEditable(false);
      jt.setLineWrap(true);
      jt.setWrapStyleWord(true);
      jt.setText(summary);
            jt.setBackground(getBackground());
      JPanel jp = new JPanel();
      jp.setBorder(BorderFactory.createCompoundBorder(
       BorderFactory.createTitledBorder("About"),
       BorderFactory.createEmptyBorder(5, 5, 5, 5)
     ));
      jp.setLayout(new BorderLayout());
      jp.add(jt, BorderLayout.CENTER);
            JPanel p2 = new JPanel();
            p2.setLayout(new BorderLayout());
            p2.add(m_HelpBut, BorderLayout.NORTH);
            if (m_CapabilitiesBut != null) {
              JPanel p3 = new JPanel();
              p3.setLayout(new BorderLayout());
              p3.add(m_CapabilitiesBut, BorderLayout.NORTH);
              p2.add(p3, BorderLayout.CENTER);
            }
            jp.add(p2, BorderLayout.EAST);
      GridBagConstraints gbConstraints = new GridBagConstraints();
      //      gbConstraints.anchor = GridBagConstraints.EAST;
      gbConstraints.fill = GridBagConstraints.BOTH;
      //      gbConstraints.gridy = 0;     gbConstraints.gridx = 0;
      gbConstraints.gridwidth = 2;
      gbConstraints.insets = new Insets(0,5,0,5);
      gbLayout.setConstraints(jp, gbConstraints);
      m_aboutPanel = jp;
      scrollablePanel.add(m_aboutPanel);
      componentOffset = 1;
      break;
    } catch (Exception ex) {
     
    }
  }
      }
    }

    m_Editors = new PropertyEditor[m_Properties.length];
    m_Values = new Object[m_Properties.length];
    m_Views = new JComponent[m_Properties.length];
    m_Labels = new JLabel[m_Properties.length];
    m_TipTexts = new String[m_Properties.length];
    boolean firstTip = true;
    for (int i = 0; i < m_Properties.length; i++) {

      // Don't display hidden or expert properties.
      if (m_Properties[i].isHidden() || m_Properties[i].isExpert()) {
  continue;
      }

      String name = m_Properties[i].getDisplayName();
      Class type = m_Properties[i].getPropertyType();
      Method getter = m_Properties[i].getReadMethod();
      Method setter = m_Properties[i].getWriteMethod();

      // Only display read/write properties.
      if (getter == null || setter == null) {
  continue;
      }
 
      JComponent view = null;

      try {
  Object args[] = { };
  Object value = getter.invoke(m_Target, args);
  m_Values[i] = value;

  PropertyEditor editor = null;
  Class pec = m_Properties[i].getPropertyEditorClass();
  if (pec != null) {
    try {
      editor = (PropertyEditor)pec.newInstance();
    } catch (Exception ex) {
      // Drop through.
    }
  }
  if (editor == null) {
    editor = PropertyEditorManager.findEditor(type);
  }
  m_Editors[i] = editor;

  // If we can't edit this component, skip it.
  if (editor == null) {
    // If it's a user-defined property we give a warning.
    String getterClass = m_Properties[i].getReadMethod()
      .getDeclaringClass().getName();
    /*
    if (getterClass.indexOf("java.") != 0) {
      System.err.println("Warning: Can't find public property editor"
             + " for property \"" + name + "\" (class \""
             + type.getName() + "\").  Skipping.");
    }
    */
    continue;
  }
  if (editor instanceof GenericObjectEditor) {
    ((GenericObjectEditor) editor).setClassType(type);
  }
 
  if (editor instanceof EnvironmentHandler) {
    ((EnvironmentHandler)editor).setEnvironment(m_env);
  }

  // Don't try to set null values:
  if (value == null) {
    // If it's a user-defined property we give a warning.
    String getterClass = m_Properties[i].getReadMethod()
      .getDeclaringClass().getName();
    /*
    if (getterClass.indexOf("java.") != 0) {
      System.err.println("Warning: Property \"" + name
             + "\" has null initial value.  Skipping.");
    }
    */
    continue;
  }

  editor.setValue(value);

  // now look for a TipText method for this property
        String tipName = name + "TipText";
  for (int j = 0; j < m_Methods.length; j++) {
    String mname = m_Methods[j].getDisplayName();
    Method meth = m_Methods[j].getMethod();
    if (mname.equals(tipName)) {
      if (meth.getReturnType().equals(String.class)) {
        try {
    String tempTip = (String)(meth.invoke(m_Target, args));
    int ci = tempTip.indexOf('.');
    if (ci < 0) {
      m_TipTexts[i] = tempTip;
    } else {
      m_TipTexts[i] = tempTip.substring(0, ci);
    }
                if (m_HelpText != null) {
                  if (firstTip) {
                    m_HelpText.append("OPTIONS\n");
                    firstTip = false;
                  }
                  m_HelpText.append(name).append(" -- ");
                  m_HelpText.append(tempTip).append("\n\n");
                  //jt.setText(m_HelpText.toString());
                }
        } catch (Exception ex) {

        }
        break;
      }
    }
  }   

  // Now figure out how to display it...
  if (editor.isPaintable() && editor.supportsCustomEditor()) {
    view = new PropertyPanel(editor);
  } else if (editor.supportsCustomEditor() && (editor.getCustomEditor() instanceof JComponent)) {
    view = (JComponent) editor.getCustomEditor();
  } else if (editor.getTags() != null) {
    view = new PropertyValueSelector(editor);
  } else if (editor.getAsText() != null) {
    view = new PropertyText(editor);
  } else {
    System.err.println("Warning: Property \"" + name
           + "\" has non-displayabale editor.  Skipping.");
    continue;
  }
 
  editor.addPropertyChangeListener(this);

      } catch (InvocationTargetException ex) {
  System.err.println("Skipping property " + name
         + " ; exception on target: "
         + ex.getTargetException());
  ex.getTargetException().printStackTrace();
  continue;
      } catch (Exception ex) {
  System.err.println("Skipping property " + name
         + " ; exception: " + ex);
  ex.printStackTrace();
  continue;
      }

      m_Labels[i] = new JLabel(name, SwingConstants.RIGHT);
      m_Labels[i].setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
      m_Views[i] = view;
      GridBagConstraints gbConstraints = new GridBagConstraints();
      gbConstraints.anchor = GridBagConstraints.EAST;
      gbConstraints.fill = GridBagConstraints.HORIZONTAL;
      gbConstraints.gridy = i+componentOffset;     gbConstraints.gridx = 0;
      gbLayout.setConstraints(m_Labels[i], gbConstraints);
      scrollablePanel.add(m_Labels[i]);
      JPanel newPanel = new JPanel();
      if (m_TipTexts[i] != null) {
  m_Views[i].setToolTipText(m_TipTexts[i]);
      }
      newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
      newPanel.setLayout(new BorderLayout());
      newPanel.add(m_Views[i], BorderLayout.CENTER);
      gbConstraints = new GridBagConstraints();
      gbConstraints.anchor = GridBagConstraints.WEST;
      gbConstraints.fill = GridBagConstraints.BOTH;
      gbConstraints.gridy = i+componentOffset;     gbConstraints.gridx = 1;
      gbConstraints.weightx = 100;
View Full Code Here

  updateCapabilitiesFilter(m_ClustererEditor.getCapabilitiesFilter());
      }
    });

    // Layout the GUI
    JPanel p1 = new JPanel();
    p1.setBorder(BorderFactory.createCompoundBorder(
     BorderFactory.createTitledBorder("Clusterer"),
     BorderFactory.createEmptyBorder(0, 5, 5, 5)
     ));
    p1.setLayout(new BorderLayout());
    p1.add(m_CLPanel, BorderLayout.NORTH);

    JPanel p2 = new JPanel();
    GridBagLayout gbL = new GridBagLayout();
    p2.setLayout(gbL);
    p2.setBorder(BorderFactory.createCompoundBorder(
     BorderFactory.createTitledBorder("Cluster mode"),
     BorderFactory.createEmptyBorder(0, 5, 5, 5)
     ));
    GridBagConstraints gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.WEST;
    gbC.gridy = 0;     gbC.gridx = 0;
    gbL.setConstraints(m_TrainBut, gbC);
    p2.add(m_TrainBut);

    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.WEST;
    gbC.gridy = 1;     gbC.gridx = 0;
    gbL.setConstraints(m_TestSplitBut, gbC);
    p2.add(m_TestSplitBut);

    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.EAST;
    gbC.fill = GridBagConstraints.HORIZONTAL;
    gbC.gridy = 1;     gbC.gridx = 1;    gbC.gridwidth = 2;
    gbC.insets = new Insets(2, 10, 2, 0);
    gbL.setConstraints(m_SetTestBut, gbC);
    p2.add(m_SetTestBut);

    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.WEST;
    gbC.gridy = 2;     gbC.gridx = 0;
    gbL.setConstraints(m_PercentBut, gbC);
    p2.add(m_PercentBut);

    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.EAST;
    gbC.fill = GridBagConstraints.HORIZONTAL;
    gbC.gridy = 2;     gbC.gridx = 1;
    gbC.insets = new Insets(2, 10, 2, 10);
    gbL.setConstraints(m_PercentLab, gbC);
    p2.add(m_PercentLab);

    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.EAST;
    gbC.fill = GridBagConstraints.HORIZONTAL;
    gbC.gridy = 2;     gbC.gridx = 2;  gbC.weightx = 100;
    gbC.ipadx = 20;
    gbL.setConstraints(m_PercentText, gbC);
    p2.add(m_PercentText);

    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.WEST;
    gbC.gridy = 3;     gbC.gridx = 0;  gbC.gridwidth = 2;
    gbL.setConstraints(m_ClassesToClustersBut, gbC);
    p2.add(m_ClassesToClustersBut);

    m_ClassCombo.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.WEST;
    gbC.gridy = 4;     gbC.gridx = 0;  gbC.gridwidth = 2;
    gbL.setConstraints(m_ClassCombo, gbC);
    p2.add(m_ClassCombo);

    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.WEST;
    gbC.gridy = 5;     gbC.gridx = 0;  gbC.gridwidth = 2;
    gbL.setConstraints(m_StorePredictionsBut, gbC);
    p2.add(m_StorePredictionsBut);

    JPanel buttons = new JPanel();
    buttons.setLayout(new GridLayout(2, 1));
    JPanel ssButs = new JPanel();
    ssButs.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    ssButs.setLayout(new GridLayout(1, 2, 5, 5));
    ssButs.add(m_StartBut);
    ssButs.add(m_StopBut);

    JPanel ib = new JPanel();
    ib.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    ib.setLayout(new GridLayout(1, 1, 5, 5));
    ib.add(m_ignoreBut);
    buttons.add(ib);
    buttons.add(ssButs);
   
    JPanel p3 = new JPanel();
    p3.setBorder(BorderFactory.createTitledBorder("Clusterer output"));
    p3.setLayout(new BorderLayout());
    final JScrollPane js = new JScrollPane(m_OutText);
    p3.add(js, BorderLayout.CENTER);
    js.getViewport().addChangeListener(new ChangeListener() {
      private int lastHeight;
      public void stateChanged(ChangeEvent e) {
  JViewport vp = (JViewport)e.getSource();
  int h = vp.getViewSize().height;
  if (h != lastHeight) { // i.e. an addition not just a user scrolling
    lastHeight = h;
    int x = h - vp.getExtentSize().height;
    vp.setViewPosition(new Point(0, x));
  }
      }
    });   

    JPanel mondo = new JPanel();
    gbL = new GridBagLayout();
    mondo.setLayout(gbL);
    gbC = new GridBagConstraints();
    //    gbC.anchor = GridBagConstraints.WEST;
    gbC.fill = GridBagConstraints.HORIZONTAL;
    gbC.gridy = 0;     gbC.gridx = 0;
    gbL.setConstraints(p2, gbC);
    mondo.add(p2);
    gbC = new GridBagConstraints();
    gbC.anchor = GridBagConstraints.NORTH;
    gbC.fill = GridBagConstraints.HORIZONTAL;
    gbC.gridy = 1;     gbC.gridx = 0;
    gbL.setConstraints(buttons, gbC);
    mondo.add(buttons);
    gbC = new GridBagConstraints();
    //gbC.anchor = GridBagConstraints.NORTH;
    gbC.fill = GridBagConstraints.BOTH;
    gbC.gridy = 2;     gbC.gridx = 0; gbC.weightx = 0;
    gbL.setConstraints(m_History, gbC);
    mondo.add(m_History);
    gbC = new GridBagConstraints();
    gbC.fill = GridBagConstraints.BOTH;
    gbC.gridy = 0;     gbC.gridx = 1;
    gbC.gridheight = 3;
    gbC.weightx = 100; gbC.weighty = 100;
    gbL.setConstraints(p3, gbC);
    mondo.add(p3);

    setLayout(new BorderLayout());
    add(p1, BorderLayout.NORTH);
    add(mondo, BorderLayout.CENTER);
  }
View Full Code Here

    });


    m_InstSummaryPanel.setBorder(BorderFactory
         .createTitledBorder("Current relation"));
    JPanel attStuffHolderPanel = new JPanel();
    attStuffHolderPanel.setBorder(BorderFactory
          .createTitledBorder("Attributes"));
    attStuffHolderPanel.setLayout(new BorderLayout());
    attStuffHolderPanel.add(m_AttPanel, BorderLayout.CENTER);
    m_RemoveButton.setEnabled(false);
    m_RemoveButton.setToolTipText("Remove selected attributes.");
    m_RemoveButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    try {
      Remove r = new Remove();
      int [] selected = m_AttPanel.getSelectedAttributes();
      if (selected.length == 0) {
        return;
      }
      if (selected.length == m_Instances.numAttributes()) {
        // Pop up an error optionpane
        JOptionPane.showMessageDialog(PreprocessPanel.this,
              "Can't remove all attributes from data!\n",
              "Remove Attributes",
              JOptionPane.ERROR_MESSAGE);
        m_Log.logMessage("Can't remove all attributes from data!");
        m_Log.statusMessage("Problem removing attributes");
        return;
      }
      r.setAttributeIndicesArray(selected);
      applyFilter(r);
      m_RemoveButton.setEnabled(false);
    } catch (Exception ex) {
      if (m_Log instanceof TaskLogger) {
        ((TaskLogger)m_Log).taskFinished();
      }
      // Pop up an error optionpane
      JOptionPane.showMessageDialog(PreprocessPanel.this,
            "Problem filtering instances:\n"
            + ex.getMessage(),
            "Remove Attributes",
            JOptionPane.ERROR_MESSAGE);
      m_Log.logMessage("Problem removing attributes: " + ex.getMessage());
      m_Log.statusMessage("Problem removing attributes");
    }
  }
      });

    JPanel p1 = new JPanel();
    p1.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
    p1.setLayout(new BorderLayout());
    p1.add(m_RemoveButton, BorderLayout.CENTER);
    attStuffHolderPanel.add(p1, BorderLayout.SOUTH);
    m_AttSummaryPanel.setBorder(BorderFactory
        .createTitledBorder("Selected attribute"));
    m_UndoBut.setEnabled(false);
    m_EditBut.setEnabled(false);
    m_SaveBut.setEnabled(false);
    m_ApplyFilterBut.setEnabled(false);
   
    // Set up the GUI layout
    JPanel buttons = new JPanel();
    buttons.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
    buttons.setLayout(new GridLayout(1, 6, 5, 5));
    buttons.add(m_OpenFileBut);
    buttons.add(m_OpenURLBut);
    buttons.add(m_OpenDBBut);
    buttons.add(m_GenerateBut);
    buttons.add(m_UndoBut);
    buttons.add(m_EditBut);
    buttons.add(m_SaveBut);

    JPanel attInfo = new JPanel();

    attInfo.setLayout(new BorderLayout());
    attInfo.add(attStuffHolderPanel, BorderLayout.CENTER);

    JPanel filter = new JPanel();
    filter.setBorder(BorderFactory
        .createTitledBorder("Filter"));
    filter.setLayout(new BorderLayout());
    filter.add(m_FilterPanel, BorderLayout.CENTER);
    filter.add(m_ApplyFilterBut, BorderLayout.EAST);

    JPanel attVis = new JPanel();
    attVis.setLayout( new GridLayout(2,1) );
    attVis.add(m_AttSummaryPanel);

    JComboBox colorBox = m_AttVisualizePanel.getColorBox();
    colorBox.setToolTipText("The chosen attribute will also be used as the " +
          "class attribute when a filter is applied.");
    colorBox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent ie) {
  if (ie.getStateChange() == ItemEvent.SELECTED) {
    updateCapabilitiesFilter(m_FilterEditor.getCapabilitiesFilter());
  }
      }
    });
    final JButton visAllBut = new JButton("Visualize All");
    visAllBut.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent ae) {
    if (m_Instances != null) {
      try {
        final weka.gui.beans.AttributeSummarizer as =
    new weka.gui.beans.AttributeSummarizer();
        as.setColoringIndex(m_AttVisualizePanel.getColoringIndex());
        as.setInstances(m_Instances);
       
        final javax.swing.JFrame jf = new javax.swing.JFrame();
        jf.getContentPane().setLayout(new java.awt.BorderLayout());
       
        jf.getContentPane().add(as, java.awt.BorderLayout.CENTER);
        jf.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowClosing(java.awt.event.WindowEvent e) {
        visAllBut.setEnabled(true);
        jf.dispose();
      }
    });
        jf.setSize(830,600);
        jf.setVisible(true);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
      });
    JPanel histoHolder = new JPanel();
    histoHolder.setLayout(new BorderLayout());
    histoHolder.add(m_AttVisualizePanel, BorderLayout.CENTER);
    JPanel histoControls = new JPanel();
    histoControls.setLayout(new BorderLayout());
    histoControls.add(colorBox, BorderLayout.CENTER);
    histoControls.add(visAllBut, BorderLayout.EAST);
    histoHolder.add(histoControls, BorderLayout.NORTH);
    attVis.add(histoHolder);

    JPanel lhs = new JPanel();
    lhs.setLayout(new BorderLayout());
    lhs.add(m_InstSummaryPanel, BorderLayout.NORTH);
    lhs.add(attInfo, BorderLayout.CENTER);

    JPanel rhs = new JPanel();
    rhs.setLayout(new BorderLayout());
    rhs.add(attVis, BorderLayout.CENTER);

    JPanel relation = new JPanel();
    relation.setLayout(new GridLayout(1, 2));
    relation.add(lhs);
    relation.add(rhs);

    JPanel middle = new JPanel();
    middle.setLayout(new BorderLayout());
    middle.add(filter, BorderLayout.NORTH);
    middle.add(relation, BorderLayout.CENTER);

    setLayout(new BorderLayout());
    add(buttons, BorderLayout.NORTH);
    add(middle, BorderLayout.CENTER);
  }
View Full Code Here

  protected void showGeneratedInstances(String data) {
    final JDialog dialog = new JDialog();
    final JButton saveButton = new JButton("Save");
    final JButton closeButton = new JButton("Close");
    final JTextArea textData = new JTextArea(data);
    final JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    textData.setEditable(false);
    textData.setFont(
        new Font("Monospaced", Font.PLAIN, textData.getFont().getSize()));

    saveButton.setMnemonic('S');
    saveButton.setToolTipText("Saves the output to a file");
    saveButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt){
        JFileChooser filechooser = new JFileChooser();
        int result = filechooser.showSaveDialog(dialog);
        if (result == JFileChooser.APPROVE_OPTION) {
          try {
            BufferedWriter writer = new BufferedWriter(
                                      new FileWriter(
                                        filechooser.getSelectedFile()));
            writer.write(textData.getText());
            writer.flush();
            writer.close();
            JOptionPane.showMessageDialog(
              dialog,
              "Output successfully saved to file '"
              + filechooser.getSelectedFile() + "'!",
              "Information",
              JOptionPane.INFORMATION_MESSAGE);
          }
          catch (Exception e) {
            e.printStackTrace();
          }
          dialog.dispose();
        }
      }
    });
    closeButton.setMnemonic('C');
    closeButton.setToolTipText("Closes the dialog");
    closeButton.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt){
        dialog.dispose();
      }
    });
    panel.add(saveButton);
    panel.add(closeButton);
    dialog.setTitle("Generated Instances (incl. comments)");
    dialog.getContentPane().add(new JScrollPane(textData), BorderLayout.CENTER);
    dialog.getContentPane().add(panel, BorderLayout.SOUTH);
    dialog.pack();
View Full Code Here

          ex.printStackTrace();
        }
      }
    });
   
    JPanel bP = new JPanel(); bP.setLayout(new BorderLayout());
    //bP.setBorder(BorderFactory.createEmptyBorder(5,0,5,5));
    bP.add(m_browseBut, BorderLayout.CENTER);
   
    add(bP, BorderLayout.EAST);   
  }
View Full Code Here

    initComponents();
  }


  protected void initComponents() {
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.Y_AXIS));
    setContentPane(mainPanel);

    OptionPanel dialogPanel = new OptionPanel(2);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS));

    mainPanel.add(dialogPanel);
    mainPanel.add(buttonPanel);

    /** Dialog panel **/
    /** End of Dialog panel */

    /** Button panel */
    JButton okButton = new JButton();
    okButton.setText("OK");
    okButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        updateAndHide();
      }
    });
    buttonPanel.add(okButton);

    JButton closeButton = new JButton();
    closeButton.setText("Cancel");
    closeButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        exitForm();
      }
    });
    buttonPanel.add(closeButton);
    /** End of button panel */

    pack ();
  }
View Full Code Here

    initComponents();
  }


  protected void initComponents() {
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.Y_AXIS));
    setContentPane(mainPanel);

    OptionPanel dialogPanel = new OptionPanel(2);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS));

    mainPanel.add(dialogPanel);
    mainPanel.add(buttonPanel);

    /**
       Input fields
     **/
    agentNameField = SwingHelper.createInputField(25);
    dialogPanel.add("Agent name:",agentNameField);

    startRefererField = SwingHelper.createInputField(25);
    dialogPanel.add("Start referer:",startRefererField);

    proxyField = SwingHelper.createInputField(25);
    dialogPanel.add("Proxy (host:port or empty):",proxyField);

    maxDepthField = SwingHelper.createInputField(5);
    dialogPanel.add("Maximal search depth:",maxDepthField);

    sleepField = SwingHelper.createInputField(5);
    dialogPanel.add("Sleep time (in seconds)",sleepField);

    bandwidthField = SwingHelper.createInputField(5);
    dialogPanel.add("Bandwidth limit in Bytes/s (0 to disable)",
        bandwidthField);

    maxAgeField = SwingHelper.createInputField(5);
    dialogPanel.add("Maximum age in days (leave empty to disable)",
        maxAgeField);

    cookiesEnabled = new JCheckBox();
    dialogPanel.add("Enable cookies",cookiesEnabled);

    allowWholeHost = new JCheckBox();
    dialogPanel.add("Allow all URLs on start host",allowWholeHost);

    allowWholeDomain = new JCheckBox();
    dialogPanel.add("Allow all URLs in the same domain",allowWholeDomain);

    flexibleHostCheck = new JCheckBox();
    dialogPanel.add("Do flexible host checking",flexibleHostCheck);

    ignoreRobotsTxt = new JCheckBox();
    dialogPanel.add("Ignore robots.txt",ignoreRobotsTxt);

    localizeLinks = new JCheckBox();
    dialogPanel.add("Localize links",localizeLinks);

    storeCGI = new JCheckBox();
    dialogPanel.add("Save dynamic pages",storeCGI);

    allowCaching = new JCheckBox();
    dialogPanel.add("Don't retrieve pages that are already on disk "
        +"(resume download)",
        allowCaching);

    /** End of input fields */

    /** Button panel */
    JButton okButton = new JButton();
    okButton.setText("OK");
    okButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        updateAndHide();
      }
    });
    buttonPanel.add(okButton);

    JButton closeButton = new JButton();
    closeButton.setText("Cancel");
    closeButton.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        exitForm();
      }
    });
    buttonPanel.add(closeButton);

    /** End of button panel */

    pack ();
    updateFormFromRobot();
View Full Code Here

  private void init(Program[] programs) {
    setTitle(mLocalizer.msg("dialog.title","Removed Programs"));
   
    UiUtilities.registerForClosing(this);
   
    JPanel contentPane = (JPanel)getContentPane();
    contentPane.setLayout(new BorderLayout(6,6));
    contentPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));

    JLabel lb = new JLabel(mLocalizer.msg("dialog.header","<html>Die folgenden Sendungen, an die sie erinnert werden wollten, sind in der aktualisierten Programmvorschau nicht mehr enthalten:</html>"));

    contentPane.add(lb, BorderLayout.NORTH);
    contentPane.add(new JScrollPane(new ProgramList(programs, new ProgramPanelSettings(ProgramPanelSettings.SHOW_PICTURES_NEVER, -1, -1, true, true, 10, true))), BorderLayout.CENTER);
    contentPane.add(createButtonPanel(), BorderLayout.SOUTH);

    setSize(400,200);
  }
View Full Code Here

TOP

Related Classes of javax.swing.JPanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.