Exemplo n.º 1
0
/**
 * 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();
  }
}
  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;
  }
Exemplo n.º 3
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));
  }
Exemplo n.º 4
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.");
              }
            }
          }
        });
  }
Exemplo n.º 7
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;
 }
 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());
 }
Exemplo n.º 10
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;
  }
Exemplo n.º 12
0
  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();
  }
Exemplo n.º 13
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));
 }
Exemplo n.º 14
0
    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);
    }
Exemplo n.º 15
0
  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();
          }
        });
  }
Exemplo n.º 16
0
  /**
   * 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);
  }
Exemplo n.º 17
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);
  }
Exemplo n.º 18
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);
     }
   }
 }
  /** 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);
  }
Exemplo n.º 20
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;
  }
Exemplo n.º 21
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;
 }
Exemplo n.º 23
0
  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);
  }
Exemplo n.º 24
0
  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);
    }
  }
Exemplo n.º 25
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;
  }
  /**
   * Create a tool window for the given project.
   *
   * @param project the project.
   */
  public CheckStyleToolWindowPanel(final ToolWindow toolWindow, final Project project) {
    super(new BorderLayout());

    this.toolWindow = toolWindow;
    this.project = project;

    checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
      throw new IllegalStateException("Couldn't get checkstyle plugin");
    }

    configurationChanged();
    checkStylePlugin.getConfiguration().addConfigurationListener(this);

    final ActionGroup mainActionGroup =
        (ActionGroup) ActionManager.getInstance().getAction(MAIN_ACTION_GROUP);
    final ActionToolbar mainToolbar =
        ActionManager.getInstance().createActionToolbar(ID_TOOLWINDOW, mainActionGroup, false);

    final ActionGroup treeActionGroup =
        (ActionGroup) ActionManager.getInstance().getAction(TREE_ACTION_GROUP);
    final ActionToolbar treeToolbar =
        ActionManager.getInstance().createActionToolbar(ID_TOOLWINDOW, treeActionGroup, false);

    final Box toolBarBox = Box.createHorizontalBox();
    toolBarBox.add(mainToolbar.getComponent());
    toolBarBox.add(treeToolbar.getComponent());

    setBorder(new EmptyBorder(1, 1, 1, 1));
    add(toolBarBox, BorderLayout.WEST);
    add(createToolPanel(), BorderLayout.CENTER);

    expandTree();

    mainToolbar.getComponent().setVisible(true);
  }
Exemplo n.º 27
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));
  }
Exemplo n.º 28
0
  /** Constructs all components of the frame and makes the frame visible to the user. */
  public void build() {

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    resolution = new JComboBox<Resolution>();
    for (Resolution res : Resolution.values()) {
      resolution.addItem(res);
    }

    resolution.setSelectedItem(prefs.getResolution());

    bitrateLabel = new JLabel("Maximum Bitrate = " + prefs.getBitrate() + " Mbps", JLabel.CENTER);
    bitrate = new JSlider(JSlider.HORIZONTAL, 0, 100, prefs.getBitrate());
    bitrate.setMajorTickSpacing(20);
    bitrate.setMinorTickSpacing(1);
    bitrate.setPaintLabels(true);
    bitrate.setPaintTicks(true);
    bitrate.setToolTipText(Integer.toString(bitrate.getValue()) + " Mbps");

    bitrate.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent ce) {
            bitrate.setToolTipText(Integer.toString(bitrate.getValue()) + " Mbps");
            bitrateLabel.setText("Maximum Bitrate = " + bitrate.getValue() + " Mbps");
          }
        });

    resolution.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            Resolution newRes = (Resolution) resolution.getSelectedItem();
            bitrate.setValue(newRes.defaultBitrate);
          }
        });

    fullscreen = new JCheckBox("Fullscreen");
    fullscreen.setSelected(prefs.getFullscreen());

    openGlRenderer = new JCheckBox("Use OpenGL Renderer (Experimental)");
    openGlRenderer.setSelected(prefs.getUseOpenGlRenderer());

    localAudio = new JCheckBox("Play audio on host PC");
    localAudio.setSelected(prefs.getLocalAudio());

    Box resolutionBox = Box.createHorizontalBox();
    resolutionBox.add(Box.createHorizontalGlue());
    resolutionBox.add(resolution);
    resolutionBox.add(Box.createHorizontalGlue());

    Box bitrateLabelBox = Box.createHorizontalBox();
    bitrateLabelBox.add(Box.createHorizontalGlue());
    bitrateLabelBox.add(bitrateLabel);
    bitrateLabelBox.add(Box.createHorizontalGlue());

    Box bitrateBox = Box.createHorizontalBox();
    bitrateBox.add(Box.createHorizontalGlue());
    bitrateBox.add(bitrate);
    bitrateBox.add(Box.createHorizontalGlue());

    Box fullscreenBox = Box.createHorizontalBox();
    fullscreenBox.add(Box.createHorizontalGlue());
    fullscreenBox.add(fullscreen);
    fullscreenBox.add(Box.createHorizontalGlue());

    Box openGlRendererBox = Box.createHorizontalBox();
    openGlRendererBox.add(Box.createHorizontalGlue());
    openGlRendererBox.add(openGlRenderer);
    openGlRendererBox.add(Box.createHorizontalGlue());

    Box localAudioBox = Box.createHorizontalBox();
    localAudioBox.add(Box.createHorizontalGlue());
    localAudioBox.add(localAudio);
    localAudioBox.add(Box.createHorizontalGlue());

    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(resolutionBox);
    mainPanel.add(Box.createVerticalStrut(5));
    mainPanel.add(bitrateLabelBox);
    mainPanel.add(Box.createVerticalStrut(5));
    mainPanel.add(bitrateBox);
    mainPanel.add(Box.createVerticalStrut(5));
    mainPanel.add(fullscreenBox);
    mainPanel.add(Box.createVerticalStrut(5));
    mainPanel.add(openGlRendererBox);
    mainPanel.add(Box.createVerticalStrut(5));
    mainPanel.add(localAudioBox);
    mainPanel.add(Box.createVerticalGlue());

    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (prefsChanged()) {
              writePreferences();
            }
          }
        });

    this.getContentPane().add(mainPanel);

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    // center on screen
    this.setLocation(
        (int) dim.getWidth() / 2 - this.getWidth() / 2,
        (int) dim.getHeight() / 2 - this.getHeight() / 2);

    this.setVisible(true);
  }
Exemplo n.º 29
0
  /**
   * Standard constructor: it needs the parent frame.
   *
   * @param parent the dialog's parent
   */
  public DialogPrint(JFrame parent) {
    super(400, 350, parent, Globals.messages.getString("Print_dlg"), true);
    addComponentListener(this);
    export = false;

    // Ensure that under MacOSX >= 10.5 Leopard, this dialog will appear
    // as a document modal sheet

    getRootPane().putClientProperty("apple.awt.documentModalSheet", Boolean.TRUE);

    GridBagLayout bgl = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    Container contentPane = getContentPane();
    contentPane.setLayout(bgl);

    constraints.insets.right = 30;

    JLabel empty = new JLabel("  ");
    constraints.weightx = 100;
    constraints.weighty = 100;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    contentPane.add(empty, constraints); // Add "   " label

    JLabel empty1 = new JLabel("  ");
    constraints.weightx = 100;
    constraints.weighty = 100;
    constraints.gridx = 3;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    contentPane.add(empty1, constraints); // Add "   " label

    mirror_CB = new JCheckBox(Globals.messages.getString("Mirror"));
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(mirror_CB, constraints); // Add Print Mirror cb

    fit_CB = new JCheckBox(Globals.messages.getString("FitPage"));
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(fit_CB, constraints); // Add Fit to page cb

    bw_CB = new JCheckBox(Globals.messages.getString("B_W"));
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(bw_CB, constraints); // Add BlackWhite cb

    landscape_CB = new JCheckBox(Globals.messages.getString("Landscape"));
    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.gridwidth = 2;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.WEST;
    contentPane.add(landscape_CB, constraints); // Add landscape cb

    // Put the OK and Cancel buttons and make them active.
    JButton ok = new JButton(Globals.messages.getString("Ok_btn"));
    JButton cancel = new JButton(Globals.messages.getString("Cancel_btn"));

    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.gridwidth = 4;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.EAST;

    // Put the OK and Cancel buttons and make them active.
    Box b = Box.createHorizontalBox();
    b.add(Box.createHorizontalGlue());
    ok.setPreferredSize(cancel.getPreferredSize());

    if (Globals.okCancelWinOrder) {
      b.add(ok);
      b.add(Box.createHorizontalStrut(12));
      b.add(cancel);

    } else {
      b.add(cancel);
      b.add(Box.createHorizontalStrut(12));
      b.add(ok);
    }

    ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            export = true;
            setVisible(false);
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
    // Here is an action in which the dialog is closed

    AbstractAction cancelAction =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        };
    contentPane.add(b, constraints); // Add OK/cancel dialog

    DialogUtil.addCancelEscape(this, cancelAction);
    pack();
    DialogUtil.center(this);
    getRootPane().setDefaultButton(ok);
  }
  private void buildKitData(Kits selectedKit) {
    final int ST_SPACE = 25;
    kitDataPanel.removeAll();
    Box container = Box.createVerticalBox();
    setComponentSize(container, 400, PAGE_HEIGHT);
    JLabel kitID = new JLabel(Integer.toString(selectedKit.getKitID()));
    JLabel kitName = new JLabel(selectedKit.getName());
    JLabel kitDesc = new JLabel(selectedKit.getDescription());
    JLabel lp = new JLabel("----- Listed Parts -----");

    // align elements to the left collum
    // all the arguments can be left as KitID.LEFT because we only need any instance of a JComponent
    // to use the LEFT keyword
    kitID.setHorizontalAlignment(kitID.LEFT);
    kitName.setHorizontalAlignment(kitID.LEFT);
    kitDesc.setHorizontalAlignment(kitID.LEFT);
    lp.setHorizontalAlignment(kitID.LEFT);

    // add elements to container
    container.add(kitID);
    container.add(kitName);
    container.add(kitDesc);
    container.add(Box.createVerticalStrut(ST_SPACE));
    container.add(lp);

    // add part data
    TreeMap<Integer, Parts> kitParts = selectedKit.getListOfParts();
    for (Integer i : kitParts.keySet()) {
      Parts selectedPart = kitParts.get(i);
      Box holder = Box.createHorizontalBox();
      Box section1 = Box.createVerticalBox();
      Box section2 = Box.createVerticalBox();
      int imageIndex = selectedPart.getImageIndex();
      String PID = Integer.toString(selectedPart.getPartNumber());
      String PName = selectedPart.getName();
      String PDesc = selectedPart.getDesc();

      setComponentSize(holder, 400, 60);

      // add elements to section1
      section1.add(new JLabel("Part " + i));
      section1.add(new JLabel(images.getIcon(imageIndex - 1)));

      // add elements to section2
      section2.add(new JLabel("Part #: " + PID));
      section2.add(new JLabel("Part name: " + PName));
      section2.add(new JLabel("Part desc: " + PDesc));

      // add sections to holder
      holder.add(section1);
      holder.add(Box.createHorizontalStrut(ST_SPACE));
      holder.add(section2);

      // add holder to container
      container.add(holder);
    }

    // add the build items to the container
    buildQuantity = new JTextField("Enter number of kits to build");
    build = new JButton("Add to build queue");
    setComponentSize(buildQuantity, 400, 20);
    setComponentSize(buildQuantity, 400, 20);
    build.addActionListener(this);
    container.add(buildQuantity);
    container.add(build);

    // add container to kitDataPanel
    kitDataPanel.add(container);
    kitDataPanel.revalidate();
  }