/**
   * Constructs the Gui used to edit properties; called from each constructor. Constructs labels and
   * text fields for editing each property and adds appropriate listeners.
   */
  private void buildGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    if (alphaField != null) {
      Box b1 = Box.createHorizontalBox();
      b1.add(new JLabel("Alpha:"));
      b1.add(Box.createHorizontalStrut(10));
      b1.add(Box.createHorizontalGlue());
      b1.add(alphaField);
      add(b1);
    }

    Box b2 = Box.createHorizontalBox();
    b2.add(new JLabel("Depth:"));
    b2.add(Box.createHorizontalStrut(10));
    b2.add(Box.createHorizontalGlue());
    b2.add(depthField);
    add(b2);

    //        Box b4 = Box.createHorizontalBox();
    //        b4.add(Box.createHorizontalStrut(25));
    //        b4.add(new JLabel("(where possible)"));
    //        b4.add(Box.createHorizontalGlue());
    //        add(b4);

    add(Box.createHorizontalGlue());
  }
  protected JComponent createCenterPanel() {
    JPanel contentPanel = new JPanel(new BorderLayout());

    Box mainPanel = Box.createHorizontalBox();

    myClassFilterEditor =
        new ClassFilterEditor(
            myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern");
    myClassFilterEditor.setPreferredSize(new Dimension(400, 200));
    myClassFilterEditor.setBorder(
        IdeBorderFactory.createTitledBorder(
            DebuggerBundle.message("class.filters.dialog.inclusion.filters.group"),
            false,
            false,
            true));
    mainPanel.add(myClassFilterEditor);

    myClassExclusionFilterEditor =
        new ClassFilterEditor(
            myProject, myChooserFilter, "reference.viewBreakpoints.classFilters.newPattern");
    myClassExclusionFilterEditor.setPreferredSize(new Dimension(400, 200));
    myClassExclusionFilterEditor.setBorder(
        IdeBorderFactory.createTitledBorder(
            DebuggerBundle.message("class.filters.dialog.exclusion.filters.group"),
            false,
            false,
            true));
    mainPanel.add(myClassExclusionFilterEditor);

    contentPanel.add(mainPanel, BorderLayout.CENTER);

    return contentPanel;
  }
/**
 * Description: <br>
 * Copyright (C), 2005-2008, Yeeku.H.Lee <br>
 * This program is protected by copyright laws. <br>
 * Program Name: <br>
 * Date:
 *
 * @author Yeeku.H.Lee [email protected]
 * @version 1.0
 */
public class TestBoxSpace {
  private Frame f = new Frame("测试");
  // 定义水平摆放组件的Box对象
  private Box horizontal = Box.createHorizontalBox();
  // 定义垂直摆放组件的Box对象
  private Box vertical = Box.createVerticalBox();

  public void init() {
    horizontal.add(new Button("水平按钮一"));
    horizontal.add(Box.createHorizontalGlue());
    horizontal.add(new Button("水平按钮二"));
    // 水平方向不可拉伸的间距,其宽度为10px
    horizontal.add(Box.createHorizontalStrut(10));
    horizontal.add(new Button("水平按钮三"));
    vertical.add(new Button("垂直按钮一"));
    vertical.add(Box.createVerticalGlue());
    vertical.add(new Button("垂直按钮二"));
    // 垂直方向不可拉伸的间距,其高度为10px
    vertical.add(Box.createVerticalStrut(10));
    vertical.add(new Button("垂直按钮三"));
    f.add(horizontal, BorderLayout.NORTH);
    f.add(vertical);
    f.pack();
    f.setVisible(true);
  }

  public static void main(String[] args) {
    new TestBoxSpace().init();
  }
}
Example #4
0
  private MainPanel() {
    super(new BorderLayout());
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < 100; i++) {
      String s = i + LF;
      buf.append(s);
    }

    final JScrollPane scrollPane = new JScrollPane(new JTextArea(buf.toString()));
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    JSpinner spinner =
        new JSpinner(
            new SpinnerNumberModel(
                scrollPane.getVerticalScrollBar().getUnitIncrement(1), 1, 100000, 1));
    spinner.setEditor(new JSpinner.NumberEditor(spinner, "#####0"));
    spinner.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            JSpinner s = (JSpinner) e.getSource();
            scrollPane.getVerticalScrollBar().setUnitIncrement((Integer) s.getValue());
          }
        });
    Box box = Box.createHorizontalBox();
    box.add(new JLabel("Unit Increment:"));
    box.add(Box.createHorizontalStrut(2));
    box.add(spinner);
    box.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(box, BorderLayout.NORTH);
    add(scrollPane);
    setPreferredSize(new Dimension(320, 240));
  }
Example #5
0
  /**
   * Creates a dialog that is showing the histogram for the given node (if null one is selected for
   * you)
   */
  private JPanel createNormalityTestDialog(Node selected) {
    DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel();

    QQPlot qqPlot = new QQPlot(dataSet, selected);
    NormalityTestEditorPanel editorPanel = new NormalityTestEditorPanel(qqPlot, dataSet);

    JTextArea display =
        new JTextArea(
            NormalityTests.runNormalityTests(
                dataSet, (ContinuousVariable) qqPlot.getSelectedVariable()),
            20,
            65);
    display.setEditable(false);
    editorPanel.addPropertyChangeListener(new NormalityTestListener(display));

    Box box = Box.createHorizontalBox();
    box.add(display);

    box.add(Box.createHorizontalStrut(3));
    box.add(editorPanel);
    box.add(Box.createHorizontalStrut(5));
    box.add(Box.createHorizontalGlue());

    Box vBox = Box.createVerticalBox();
    vBox.add(Box.createVerticalStrut(15));
    vBox.add(box);
    vBox.add(Box.createVerticalStrut(5));

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(vBox, BorderLayout.CENTER);

    return panel;
  }
  private void initGui() {
    JComponent filler =
        new JComponent() {
          @Override
          public Dimension getPreferredSize() {
            return myTextLabel.getPreferredSize();
          }
        };
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(3, 20, 3, 20));

    add(myTextLabel, BorderLayout.WEST);
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    JPanel panel = new JPanel(new GridLayout(1, myLabels.size(), 0, 0));
    for (final JComponent myLabel : myLabels) {
      panel.add(myLabel);
    }
    panel.setMaximumSize(panel.getPreferredSize());
    box.add(panel);
    box.add(Box.createHorizontalGlue());
    add(box, BorderLayout.CENTER);

    add(filler, BorderLayout.EAST);
  }
  /** Performs the action of loading a session from a file. */
  public void actionPerformed(ActionEvent e) {
    DataModel dataModel = getDataEditor().getSelectedDataModel();

    if (!(dataModel instanceof DataSet)) {
      JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Must be a tabular data set.");
      return;
    }

    this.dataSet = (DataSet) dataModel;

    SpinnerNumberModel spinnerNumberModel = new SpinnerNumberModel(getNumLags(), 0, 20, 1);
    JSpinner jSpinner = new JSpinner(spinnerNumberModel);
    jSpinner.setPreferredSize(jSpinner.getPreferredSize());

    spinnerNumberModel.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            SpinnerNumberModel model = (SpinnerNumberModel) e.getSource();
            setNumLags(model.getNumber().intValue());
          }
        });

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    Box b = Box.createVerticalBox();
    Box b1 = Box.createHorizontalBox();
    b1.add(new JLabel("Number of time lags: "));
    b1.add(Box.createHorizontalGlue());
    b1.add(Box.createHorizontalStrut(15));
    b1.add(jSpinner);
    b1.setBorder(new EmptyBorder(10, 10, 10, 10));
    b.add(b1);

    panel.add(b, BorderLayout.CENTER);

    EditorWindow editorWindow = new EditorWindow(panel, "Create time series data", "Save", true);
    DesktopController.getInstance().addEditorWindow(editorWindow);
    editorWindow.setVisible(true);

    editorWindow.addInternalFrameListener(
        new InternalFrameAdapter() {
          public void internalFrameClosed(InternalFrameEvent e) {
            EditorWindow window = (EditorWindow) e.getSource();

            if (!window.isCanceled()) {
              if (dataSet.isContinuous()) {
                createContinuousTimeSeriesData();
              } else if (dataSet.isDiscrete()) {
                createDiscreteTimeSeriesData();
              } else {
                JOptionPane.showMessageDialog(
                    JOptionUtils.centeringComp(),
                    "Data set must be either continuous or discrete.");
              }
            }
          }
        });
  }
Example #8
0
 private void createMarginBox(Container c, Component comp) {
   c.add(Box.createVerticalStrut(10));
   Box lrMargins = Box.createHorizontalBox();
   lrMargins.add(Box.createHorizontalStrut(10));
   lrMargins.add(comp);
   lrMargins.add(Box.createHorizontalStrut(10));
   c.add(lrMargins);
   c.add(Box.createVerticalStrut(10));
 }
 // Center given button in a box, centered vertically and 6 pixels on left and right
 private Box createBoxForButton(JButton button) {
   Box buttonRow = Box.createHorizontalBox();
   buttonRow.add(Box.createHorizontalStrut(6));
   buttonRow.add(button);
   buttonRow.add(Box.createHorizontalStrut(6));
   Box buttonBox = Box.createVerticalBox();
   buttonBox.add(Box.createVerticalGlue());
   buttonBox.add(buttonRow);
   buttonBox.add(Box.createVerticalGlue());
   return buttonBox;
 }
  protected void instantiateFrame() {
    Box container = Box.createHorizontalBox();

    JLabel confirmation1 = new JLabel(areYouSureIcon);
    confirmation1.setHorizontalAlignment(SwingConstants.RIGHT);

    final JLabel noButton = new JLabel(noIcon);
    noButton.setHorizontalAlignment(SwingConstants.RIGHT);
    noButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent mouseEvent) {
            noButton.setIcon(noIconOver);
          }

          @Override
          public void mouseExited(MouseEvent mouseEvent) {
            noButton.setIcon(noIcon);
          }

          @Override
          public void mousePressed(MouseEvent mouseEvent) {
            noButton.setIcon(noIcon);
            firePropertyChange(NO, "noPressed", "");
          }
        });

    final JLabel yesButton = new JLabel(yesIcon);
    yesButton.setHorizontalAlignment(SwingConstants.RIGHT);
    yesButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent mouseEvent) {
            yesButton.setIcon(yesIconOver);
          }

          @Override
          public void mouseExited(MouseEvent mouseEvent) {
            yesButton.setIcon(yesIcon);
          }

          @Override
          public void mousePressed(MouseEvent mouseEvent) {
            yesButton.setIcon(yesIcon);
            firePropertyChange(YES, "yesPressed", "");
          }
        });

    container.add(confirmation1);
    container.add(noButton);
    container.add(yesButton);

    add(container);
  }
 private void init() {
   setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
   Box labelBox = Box.createHorizontalBox();
   labelBox.add(new JLabel("Initialize Variable: "));
   labelBox.add(varName);
   labelBox.add(Box.createHorizontalGlue());
   add(labelBox);
   add(Box.createVerticalStrut(10));
   varEditPane.setLayout(new BorderLayout());
   add(varEditPane);
   add(Box.createVerticalGlue());
 }
Example #12
0
  // Method to build the dialog box for help.
  private void buildDialogBox() {
    // Set the JDialog window properties.
    setTitle("Stack Trace Detail");
    setResizable(false);
    setSize(dialogWidth, dialogHeight);

    // Append the stack trace output to the display area.
    displayArea.append(eStackTrace);

    // Create horizontal and vertical scrollbars for box.
    displayBox = Box.createHorizontalBox();
    displayBox = Box.createVerticalBox();

    // Add a JScrollPane to the Box.
    displayBox.add(new JScrollPane(displayArea));

    // Define behaviors of container.
    c.setLayout(null);
    c.add(displayBox);
    c.add(okButton);

    // Set scroll pane bounds.
    displayBox.setBounds(
        (dialogWidth / 2) - ((displayAreaWidth / 2) + 2),
        (top + (offsetMargin / 2)),
        displayAreaWidth,
        displayAreaHeight);

    // Set the behaviors, bounds and action listener for the button.
    okButton.setBounds(
        (dialogWidth / 2) - (buttonWidth / 2),
        (displayAreaHeight + offsetMargin),
        buttonWidth,
        buttonHeight);

    // Set the font to the platform default Font for the object with the
    // properties of bold and font size of 11.
    okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11));

    // The class implements the ActionListener interface and therefore
    // provides an implementation of the actionPerformed() method.  When a
    // class implements ActionListener, the instance handler returns an
    // ActionListener.  The ActionListener then performs actionPerformed()
    // method on an ActionEvent.
    okButton.addActionListener(this);

    // Set the screen and display dialog window in relation to screen size.
    setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2));

    // Display JDialog.
    show();
  } // End of buildDialogBox method.
  /**
   * Create the pixel location panel
   *
   * @param labelFont the font for the labels
   * @return the location panel
   */
  public JPanel createLocationPanel(Font labelFont) {

    // create a location panel
    JPanel locationPanel = new JPanel();
    locationPanel.setLayout(new FlowLayout());
    Box hBox = Box.createHorizontalBox();

    // create the labels
    rowLabel = new JLabel("Row:");
    colLabel = new JLabel("Column:");

    // create the text fields
    colValue = new JTextField(Integer.toString(colIndex + numberBase), 6);
    colValue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayPixelInformation(colValue.getText(), rowValue.getText());
          }
        });
    rowValue = new JTextField(Integer.toString(rowIndex + numberBase), 6);
    rowValue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayPixelInformation(colValue.getText(), rowValue.getText());
          }
        });

    // set up the next and previous buttons
    setUpNextAndPreviousButtons();

    // set up the font for the labels
    colLabel.setFont(labelFont);
    rowLabel.setFont(labelFont);
    colValue.setFont(labelFont);
    rowValue.setFont(labelFont);

    // add the items to the vertical box and the box to the panel
    hBox.add(Box.createHorizontalGlue());
    hBox.add(rowLabel);
    hBox.add(rowPrevButton);
    hBox.add(rowValue);
    hBox.add(rowNextButton);
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(colLabel);
    hBox.add(colPrevButton);
    hBox.add(colValue);
    hBox.add(colNextButton);
    locationPanel.add(hBox);
    hBox.add(Box.createHorizontalGlue());

    return locationPanel;
  }
  private void init() {
    setLayout(new BorderLayout());

    tableModel = new NotesTableModel(getCharacter());
    table = new JTable(tableModel);
    table.setRowHeight(50);
    tableModel.updateColumns(table);
    table.setDefaultRenderer(String.class, new NotesCellRenderer());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                updateControls();
              }
            });

    add(new JScrollPane(table), "Center");

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    addNoteButton = new JButton("Add Custom");
    addNoteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            String note = JOptionPane.showInputDialog("Custom Note");
            getCharacter().addNote(getGameHandler().getClient().getClientName(), "Custom", note);
            updatePanel();
          }
        });
    box.add(addNoteButton);
    box.add(Box.createHorizontalGlue());
    deleteNoteButton = new JButton("Delete Custom");
    deleteNoteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            Note note = getSelectedNote();
            if (note != null) {
              getCharacter().deleteNote(note.getId());
              updatePanel();
            }
          }
        });
    box.add(deleteNoteButton);
    box.add(Box.createHorizontalGlue());
    add(box, "South");

    updateControls();
  }
Example #15
0
 public MainPanel() {
   super(new BorderLayout());
   BufferedImage bi = null;
   try {
     bi = ImageIO.read(getClass().getResource("test.jpg"));
   } catch (IOException ioe) {
     ioe.printStackTrace();
   }
   bufferedImage = bi;
   List<AbstractAction> list =
       Arrays.asList(
           new AbstractAction("NONE") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.NONE;
               repaint();
             }
           },
           new AbstractAction("VERTICAL") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.VERTICAL;
               repaint();
             }
           },
           new AbstractAction("HORIZONTAL") {
             @Override
             public void actionPerformed(ActionEvent e) {
               mode = Flip.HORIZONTAL;
               repaint();
             }
           });
   Box box = Box.createHorizontalBox();
   box.add(Box.createHorizontalGlue());
   box.add(new JLabel("Flip: "));
   for (AbstractAction a : list) {
     JRadioButton rb = new JRadioButton(a);
     if (bg.getButtonCount() == 0) {
       rb.setSelected(true);
     }
     box.add(rb);
     bg.add(rb);
     box.add(Box.createHorizontalStrut(5));
   }
   add(p);
   add(box, BorderLayout.SOUTH);
   setOpaque(false);
   setPreferredSize(new Dimension(320, 240));
 }
    public AppFrame() {
      JButton button = new JButton("Open VPF Database");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              showOpenDialog();
            }
          });

      Box box = Box.createHorizontalBox();
      box.setBorder(BorderFactory.createEmptyBorder(30, 30, 30, 30)); // top, left, bottom, right
      box.add(button);

      this.getLayerPanel().add(box, BorderLayout.SOUTH);
    }
  private void createGUIDialog() {
    JPanel mainPanel = new JPanel(new BorderLayout());
    setContentPane(mainPanel);
    mainPanel.add(new JLabel("Select dimensions to rulerender: "), BorderLayout.PAGE_START);

    JPanel combosPanel = new JPanel(new GridLayout(2, 2, 10, 10));
    mainPanel.add(combosPanel, BorderLayout.CENTER);

    combosPanel.add(new JLabel("Dimension 1:"));
    box1 = new JComboBox(choices.toArray());
    box1.setEditable(false);
    box1.setSelectedIndex(0);
    combosPanel.add(box1);

    combosPanel.add(new JLabel("Dimension 2:"));
    box2 = new JComboBox(choices.toArray());
    box2.setEditable(false);
    box2.setSelectedIndex(Math.min(choices.size(), 1));
    combosPanel.add(box2);

    Box h = Box.createHorizontalBox();
    mainPanel.add(h, BorderLayout.PAGE_END);
    h.add(Box.createHorizontalGlue());
    JButton okButton = new JButton("OK");
    h.add(okButton);
    okButton.setDefaultCapable(true);

    h.add(Box.createHorizontalStrut(10));

    JButton cancelButton = new JButton("Cancel");
    h.add(cancelButton);

    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            returnCode = OK_BUTTON;
            dispose();
          }
        });

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            returnCode = CANCEL_BUTTON;
            dispose();
          }
        });
  }
Example #18
0
/**
 * NewClass 2012.02.14
 *
 * @version $Rev$ : Last Changed $Date$
 * @author johnmay
 * @author $Author$ (this version)
 *     <p>Class description
 */
public class AuthorAnnotationEditor extends StringAnnotationEditor {

  private JTextField author = FieldFactory.newField(System.getProperty("user.name"));
  private JTextField value = FieldFactory.newField(20);

  private Box box = Box.createHorizontalBox();

  public AuthorAnnotationEditor() {

    // field is added in super constructor
    box.add(author);
    box.add(value);

    box.setBorder(Borders.EMPTY_BORDER);
  }

  public JTextField getAuthor() {
    return author;
  }

  public void setAnnotation(AuthorAnnotation annotation) {
    super.setAnnotation(annotation);
    author.setText(annotation.getAuthor());
  }

  @Override
  public void setAnnotation(StringAnnotation annotation) {
    setAnnotation((AuthorAnnotation) annotation);
  }

  @Override
  public AuthorAnnotation newAnnotation() {
    AuthorAnnotation a = (AuthorAnnotation) super.newAnnotation();
    a.setAuthor(author.getText());
    return a;
  }

  @Override
  public JComponent getComponent() {
    return box;
  }

  @Override
  public AbstractAnnotationEditor newInstance() {
    return new AuthorAnnotationEditor();
  }
}
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the
   * event-dispatching thread.
   */
  private static void createAndShowGUI() {
    //        String[] labels = {"Name: ", "Fax: ", "Email: ", "Address: "};
    //        int numPairs = labels.length;
    //
    //        //Create and populate the panel.
    JPanel p = new JPanel(new SpringLayout());
    //        for (int i = 0; i < numPairs; i++) {
    //            JLabel l = new JLabel(labels[i], JLabel.TRAILING);
    //            p.add(l);
    //            JTextField textField = new JTextField(10);
    //            l.setLabelFor(textField);
    //            p.add(textField);
    //        }

    p.add(new JLabel("aaaa"));
    p.add(new JTextField("aaaa"));
    p.add(new JLabel("bbbb"));
    p.add(new JTextField("bbbb"));

    p.add(Box.createHorizontalBox());
    p.add(Box.createVerticalBox());
    p.add(new JLabel("cccc"));
    p.add(new JTextField("cccc"));

    // Lay out the panel.
    SpringUtilities.makeCompactGrid(
        p, 2, 4, // rows, cols
        6, 6, // initX, initY
        6, 6); // xPad, yPad
    //        SpringUtilities.makeGrid(p,
    //                                        numPairs/2, 4, //rows, cols
    //                                        6, 6,        //initX, initY
    //                                        6, 6);       //xPad, yPad

    // Create and set up the window.
    JFrame frame = new JFrame("SpringForm");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set up the content pane.
    p.setOpaque(true); // content panes must be opaque
    frame.setContentPane(p);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
Example #20
0
  public ButtonsRenderer(DefaultListModel<E> model) {
    super(new BorderLayout());
    this.model = model;
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
    setOpaque(true);
    label.setLineWrap(true);
    label.setOpaque(false);
    add(label);

    Box box = Box.createHorizontalBox();
    for (JButton b : Arrays.asList(deleteButton, copyButton)) {
      b.setFocusable(false);
      b.setRolloverEnabled(false);
      box.add(b);
      box.add(Box.createHorizontalStrut(5));
    }
    add(box, BorderLayout.EAST);
  }
Example #21
0
 public MultiParameterPanel(
     Core core,
     DBObject data,
     int minNb,
     int maxNb,
     Dimension minimumSize,
     PanelDisplayer panelDisplayer,
     boolean enableTest,
     Class<T> clazz) {
   this.core = core;
   this.enableTest = enableTest;
   this.minNbRows = maxNb == 1 ? 1 : Math.max(2, minimumSize.height / 40);
   this.maxNb = maxNb;
   this.minNb = minNb;
   this.panelDisplayer = panelDisplayer;
   this.clazz = clazz;
   this.data = data;
   this.panelElements = new ArrayList<PanelElementAbstract>();
   listLayout = new GridLayout(0, 1, 5, 0);
   this.listPanel = new JPanel(listLayout);
   this.listPanel.setMinimumSize(minimumSize);
   this.add = new JButton("Add");
   if (maxNb > 1) {
     Box addJP = Box.createHorizontalBox();
     addJP.add(Box.createHorizontalStrut(5));
     addJP.add(add);
     addJP.add(Box.createHorizontalGlue());
     listPanel.add(addJP);
     add.addActionListener(this);
   }
   if (this.data != null && maxNb > 1) {
     BasicDBList list = (BasicDBList) data;
     for (int i = 0; i < list.size(); i++) {
       addElement((BasicDBObject) list.get(i), i);
     }
   } else if (maxNb == 1) {
     if (this.data != null) addElement((BasicDBObject) data, 0);
     else addElement(null, 0);
   } else if (minNb > 0) {
     for (int i = 0; i < minNb; i++) {
       addElement(null, i);
     }
   }
 }
Example #22
0
  /** 生成面板内容 */
  private void createContent() {
    contentPanel = new JPanel(new BorderLayout());
    panel.add(contentPanel, BorderLayout.CENTER);

    Box message = Box.createVerticalBox();
    message.setBorder(BorderFactory.createEtchedBorder());

    dateImg = new JLabel(new ImageIcon(TMFrame.class.getResource("/images/calendar.gif")));
    String today = Today.getYear() + "年" + Today.getMonth() + "月" + Today.getDate() + "日";
    date = new JLabel(today);
    date.setFont(font);
    week = new JLabel(Today.getWeek());
    week.setFont(font);
    nameImg = new JLabel(new ImageIcon(TMFrame.class.getResource("/images/role.png")));
    name = new JLabel(staffInfo.getStaffName());
    name.setFont(font);
    role = new JLabel("总经理");
    role.setFont(font);

    Box messageTop = Box.createVerticalBox();
    Box messageCenter = Box.createHorizontalBox();
    Box messageBottom = Box.createVerticalBox();

    messageTop.add(Box.createVerticalStrut(1));
    messageCenter.add(Box.createHorizontalStrut(5));
    messageCenter.add(dateImg);
    messageCenter.add(Box.createHorizontalStrut(2));
    messageCenter.add(date);
    messageCenter.add(Box.createHorizontalStrut(20));
    messageCenter.add(week);
    messageCenter.add(Box.createHorizontalStrut(50));
    messageCenter.add(nameImg);
    messageCenter.add(Box.createHorizontalStrut(2));
    messageCenter.add(name);
    messageCenter.add(Box.createHorizontalStrut(20));
    messageCenter.add(role);
    messageCenter.add(Box.createHorizontalGlue());
    messageBottom.add(Box.createVerticalStrut(1));

    message.add(messageTop);
    message.add(messageCenter);
    message.add(messageBottom);
    contentPanel.add(message, BorderLayout.NORTH);
  }
  /** Builds the panel. */
  public void setup() {
    SpinnerNumberModel model =
        new SpinnerNumberModel(this.params.getInt("numTimeLags", 1), 0, Integer.MAX_VALUE, 1);
    JSpinner jSpinner = new JSpinner(model);
    jSpinner.setPreferredSize(jSpinner.getPreferredSize());

    model.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            SpinnerNumberModel model = (SpinnerNumberModel) e.getSource();
            params.set("numTimeLags", model.getNumber().intValue());
          }
        });

    Box b1 = Box.createHorizontalBox();
    b1.add(new JLabel("Number of lags: "));
    b1.add(Box.createHorizontalGlue());
    b1.add(Box.createHorizontalStrut(15));
    b1.add(jSpinner);
    b1.setBorder(new EmptyBorder(10, 10, 10, 10));
    add(b1, BorderLayout.CENTER);
  }
Example #24
0
  /**
   * Creates a dialog that is showing the histogram for the given node (if null one is selected for
   * you)
   */
  private JPanel createScatterPlotDialog(
      ContinuousVariable yVariable, ContinuousVariable xVariable) {
    String dialogTitle = "Scatter Plots";
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    DataSet dataSet = (DataSet) dataEditor.getSelectedDataModel();

    ScatterPlotOld scatterPlot = new ScatterPlotOld(dataSet, yVariable, xVariable);
    ScatterPlotEditorPanel editorPanel = new ScatterPlotEditorPanel(scatterPlot, dataSet);
    ScatterPlotDisplayPanelOld display = new ScatterPlotDisplayPanelOld(scatterPlot);
    editorPanel.addPropertyChangeListener(new ScatterPlotListener(display));

    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.add(new JMenuItem(new SaveComponentImage(display, "Save Scatter Plot")));
    bar.add(menu);

    Box box = Box.createHorizontalBox();
    box.add(display);

    box.add(Box.createHorizontalStrut(3));
    box.add(editorPanel);
    box.add(Box.createHorizontalStrut(5));
    box.add(Box.createHorizontalGlue());

    Box vBox = Box.createVerticalBox();
    vBox.add(Box.createVerticalStrut(15));
    vBox.add(box);
    vBox.add(Box.createVerticalStrut(5));

    panel.add(bar, BorderLayout.NORTH);
    panel.add(vBox, BorderLayout.CENTER);

    //        dialog.getContentPane().add(bar, BorderLayout.NORTH);
    //        dialog.getContentPane().add(vBox, BorderLayout.CENTER);
    //        return dialog;
    return panel;
  }
Example #25
0
  /** Constructs a new GraphEditor for the given EdgeListGraph. */
  public TimeLagGraphEditor(TimeLagGraph graph) {
    setLayout(new BorderLayout());

    this.workbench = new TimeLagGraphWorkbench(graph);
    DagGraphToolbar toolbar = new DagGraphToolbar(getWorkbench());
    JMenuBar menuBar = createGraphMenuBar();
    JScrollPane scroll = new JScrollPane(getWorkbench());
    scroll.setPreferredSize(new Dimension(450, 450));

    add(scroll, BorderLayout.CENTER);
    add(toolbar, BorderLayout.WEST);
    add(menuBar, BorderLayout.NORTH);

    JLabel label = new JLabel("Double click variable to change name.");
    label.setFont(new Font("SansSerif", Font.PLAIN, 12));
    Box b = Box.createHorizontalBox();
    b.add(Box.createHorizontalStrut(2));
    b.add(label);
    b.add(Box.createHorizontalGlue());
    b.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY));

    add(b, BorderLayout.SOUTH);

    this.getWorkbench()
        .addPropertyChangeListener(
            new PropertyChangeListener() {
              public void propertyChange(PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();

                if ("graph".equals(propertyName)) {
                  TimeLagGraph _graph = (TimeLagGraph) evt.getNewValue();

                  if (getWorkbench() != null) {
                    getGraphWrapper().setGraph(_graph);
                  }
                }
              }
            });
  }
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   if (containerBox == null) {
     containerBox = Box.createHorizontalBox();
     checkBox = new JCheckBox();
     checkBox.setEnabled(isEnabled());
     checkBox.setFont(getFont());
     checkBox.setFocusPainted(false);
     checkBox.setBorderPainted(true);
     checkBox.setBorder(
         isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
     containerBox.add(checkBox);
   }
   checkBox.setBackground(isSelected ? getSelectionBackground() : getBackground());
   checkBox.setForeground(isSelected ? getSelectionForeground() : getForeground());
   if (value != null) {
     ListItem item = (ListItem) value;
     checkBox.setText(item.dataItem.toString());
     checkBox.setSelected(item.selected);
   }
   return containerBox;
 }
  private void drawComponents() {
    GridBagConstraints con = new GridBagConstraints();
    con.gridx = 0;
    con.gridy = 0;
    con.gridwidth = 1;
    con.gridheight = 1;
    con.anchor = GridBagConstraints.NORTH;
    con.fill = GridBagConstraints.HORIZONTAL;
    con.insets = new Insets(5, 5, 5, 5);
    con.weightx = 0;
    con.weighty = 0;

    Box btns = Box.createHorizontalBox();
    btns.add(btnDetails);
    btns.add(Box.createHorizontalGlue());
    btns.add(btnClose);

    // Set up content
    Container content = getContentPane();
    content.setLayout(new GridBagLayout());

    // Add message label
    con.weightx = 1;
    con.weighty = 1;
    content.add(lblMessage, con);

    // Add button box
    con.gridy = 1;
    con.weighty = 0;
    content.add(btns, con);

    // Add trace pane
    con.gridy = 2;

    content.add(srlTrace, con);

    // Set default button
    getRootPane().setDefaultButton(btnClose);
  }
  private void setUpA1(List<DataSet> dataSets, Box a1) {
    int[] shifts = params.getShifts();

    if (shifts.length != dataSets.get(0).getNumColumns()) {
      shifts = new int[dataSets.get(0).getNumColumns()];
      params.setShifts(shifts);
    }

    final int[] _shifts = shifts;

    for (int i = 0; i < dataSets.get(0).getNumColumns(); i++) {
      Node node = dataSets.get(0).getVariable(i);
      Box a5 = Box.createHorizontalBox();

      SpinnerModel shiftModel = new SpinnerNumberModel(_shifts[i], -50, 50, 1);
      JSpinner shiftSpinner = new JSpinner(shiftModel);
      shiftSpinner.setMaximumSize(shiftSpinner.getPreferredSize());
      final int nodeIndex = i;

      shiftSpinner.addChangeListener(
          new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
              JSpinner spinner = (JSpinner) e.getSource();
              SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel();
              int value = (Integer) model.getValue();
              _shifts[nodeIndex] = value;
              params.setShifts(_shifts);
            }
          });

      a5.add(new JLabel("    Shift for "));
      a5.add(new JLabel(node.getName()));
      a5.add(new JLabel(" is "));
      a5.add(shiftSpinner);
      a5.add(Box.createHorizontalGlue());
      a1.add(a5);
    }
  }
Example #29
0
  @Override
  protected JPanel createButtonPanel() {
    JButton cancel = new JButton("Storno");
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            actionCancel();
          }
        });

    JButton save = new JButton("Uložit změny");
    save.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              saveSettings();
              close();
            } catch (InvalidAttributeValueException ex) {
              MessageDialog.error("Nesprávně vyplněný formulář", ex.getMessage(), instance);
            }
          }
        });

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createRigidArea(new Dimension(WINDOW_WIDTH - 190, 0)));
    buttons.add(cancel);
    buttons.add(Box.createRigidArea(new Dimension(10, 0)));
    buttons.add(save);

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

    return buttonPanel;
  }
Example #30
0
  public MainPanel() {
    super(new BorderLayout());
    setSilderUI(slider1);
    setSilderUI(slider2);

    Box box1 = Box.createHorizontalBox();
    box1.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    box1.add(new JSlider(SwingConstants.VERTICAL, 0, 1000, 100));
    box1.add(Box.createHorizontalStrut(20));
    box1.add(slider1);
    box1.add(Box.createHorizontalGlue());

    Box box2 = Box.createVerticalBox();
    box2.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 20));
    box2.add(makeTitledPanel("Default", new JSlider(0, 1000, 100)));
    box2.add(Box.createVerticalStrut(20));
    box2.add(makeTitledPanel("Jump to clicked position", slider2));
    box2.add(Box.createVerticalGlue());

    add(box1, BorderLayout.WEST);
    add(box2);
    // setBorder(BorderFactory.createEmptyBorder(5, 20, 5, 10));
    setPreferredSize(new Dimension(320, 240));
  }