private void buildExternalsPanel() {

    FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:pref:grow", "p"));
    int row = 1;
    for (ExternalFileEntry efe : externals) {
      builder.add(efe.getPanel()).xy(1, row);
      builder.appendRows("2dlu, p");
      row += 2;
    }
    builder.add(Box.createVerticalGlue()).xy(1, row);
    builder.appendRows("2dlu, p, 2dlu, p");
    builder.add(addExtPan).xy(1, row + 2);
    builder.add(Box.createVerticalGlue()).xy(1, row + 2);

    // builder.getPanel().setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.green));
    // externalFilesPanel.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red));
    JScrollPane pane = new JScrollPane(builder.getPanel());
    pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    externalFilesPanel.setMinimumSize(new Dimension(400, 400));
    externalFilesPanel.setPreferredSize(new Dimension(400, 400));
    externalFilesPanel.removeAll();
    externalFilesPanel.add(pane, BorderLayout.CENTER);
    externalFilesPanel.revalidate();
    externalFilesPanel.repaint();
  }
Beispiel #2
0
  /** OptionPaneDemo Constructor */
  public OptionPaneDemo(SwingSet2 swingset) {
    // Set the title for this demo, and an icon used to represent this
    // demo inside the SwingSet2 app.
    super(swingset, "OptionPaneDemo", "toolbar/JOptionPane.gif");

    JPanel demo = getDemoPanel();

    demo.setLayout(new BoxLayout(demo, BoxLayout.X_AXIS));

    JPanel bp =
        new JPanel() {
          public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
          }
        };
    bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS));

    bp.add(Box.createRigidArea(VGAP30));
    bp.add(Box.createRigidArea(VGAP30));

    bp.add(createInputDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createWarningDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createMessageDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createComponentDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createConfirmDialogButton());
    bp.add(Box.createVerticalGlue());

    demo.add(Box.createHorizontalGlue());
    demo.add(bp);
    demo.add(Box.createHorizontalGlue());
  }
Beispiel #3
0
  private void setupUI() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    mainPanel.add(createCurrentDirectoryPanel());
    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(createLogLevelPanel());
    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(createStackTracePanel());
    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(createOptionsPanel());
    mainPanel.add(Box.createVerticalStrut(10));
    mainPanel.add(createCustomExecutorPanel());
    mainPanel.add(Box.createVerticalStrut(10));

    // add a panel that can be used to add custom things to the setup tab
    customPanelPlaceHolder = new JPanel(new BorderLayout());
    mainPanel.add(customPanelPlaceHolder);

    // Glue alone doesn't work in this situation. This forces everything to the top.
    JPanel expandingPanel = new JPanel(new BorderLayout());
    expandingPanel.add(Box.createVerticalGlue(), BorderLayout.CENTER);
    mainPanel.add(expandingPanel);

    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  }
  public void createFileChooserDemo() {
    theImage = new JLabel("");
    jpgIcon = createImageIcon("filechooser/jpgIcon.jpg", "jpg image");
    gifIcon = createImageIcon("filechooser/gifIcon.gif", "gif image");

    JPanel demoPanel = getDemoPanel();
    demoPanel.setLayout(new BoxLayout(demoPanel, BoxLayout.Y_AXIS));

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

    demoPanel.add(Box.createRigidArea(VGAP20));
    demoPanel.add(innerPanel);
    demoPanel.add(Box.createRigidArea(VGAP20));

    innerPanel.add(Box.createRigidArea(HGAP20));

    // Create a panel to hold buttons
    JPanel buttonPanel =
        new JPanel() {
          public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
          }
        };
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));

    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createPlainFileChooserButton());
    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createPreviewFileChooserButton());
    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createCustomFileChooserButton());
    buttonPanel.add(Box.createVerticalGlue());

    // Create a panel to hold the image
    JPanel imagePanel = new JPanel();
    imagePanel.setLayout(new BorderLayout());
    imagePanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
    JScrollPane scroller = new JScrollPane(theImage);
    scroller.getVerticalScrollBar().setUnitIncrement(10);
    scroller.getHorizontalScrollBar().setUnitIncrement(10);
    imagePanel.add(scroller, BorderLayout.CENTER);

    // add buttons and image panels to inner panel
    innerPanel.add(buttonPanel);
    innerPanel.add(Box.createRigidArea(HGAP30));
    innerPanel.add(imagePanel);
    innerPanel.add(Box.createRigidArea(HGAP20));
  }
  public MainPanel() {
    super(new BorderLayout());
    l1.setToolTipText("Test1");
    l2.setToolTipText("Test2");
    l3.setToolTipText("<html><img src='" + url + "'>Test3</html>");

    JPanel p1 = new JPanel(new BorderLayout());
    p1.setBorder(BorderFactory.createTitledBorder("javax.swing.Timer"));
    p1.add(l1);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.setBorder(BorderFactory.createTitledBorder("Animated Gif"));
    p2.add(l2, BorderLayout.NORTH);
    p2.add(l3, BorderLayout.SOUTH);

    Box box = Box.createVerticalBox();
    box.add(p1);
    box.add(Box.createVerticalStrut(20));
    box.add(p2);
    box.add(Box.createVerticalGlue());
    add(box);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setPreferredSize(new Dimension(320, 240));
  }
Beispiel #6
0
public class ListPanel extends JPanel {
  private java.util.List<JPanel> rows = new ArrayList<>();
  private java.util.List<Component> struts = new ArrayList<>();
  private Gui gui;
  private Component puff = Box.createVerticalGlue();

  public ListPanel(Gui gui) {
    this.gui = gui;
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(puff);
  }

  public void addRow(Component... components) {
    remove(puff);
    final JPanel row = new JPanel();
    row.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent event) {
            gui.notifyObserver("/use " + rows.indexOf(event.getSource()));
          }
        });
    row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
    // row.add(Box.createHorizontalStrut(3));
    row.setMinimumSize(new Dimension(10, 30));
    row.setMaximumSize(new Dimension(250, 30));
    for (Component component : components) {
      row.add(component);
    }
    JButton red = new JButton("x");
    red.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            int deleted = rows.indexOf(row);
            gui.notifyObserver("/use " + deleted);
            gui.notifyObserver("/disconnect");
          }
        });
    red.setBackground(Color.PINK.darker());
    red.setForeground(Color.WHITE);
    row.add(Box.createHorizontalGlue());
    row.add(red);
    rows.add(row);
    Component strut = Box.createVerticalStrut(5);
    struts.add(strut);
    add(row);
    add(strut);
    add(puff);
    repaint();
    updateUI();
  }

  public void removeRow(int index) {
    remove(rows.get(index));
    remove(struts.get(index));
    rows.remove(index);
    struts.remove(index);
    repaint();
    updateUI();
  }

  public void selectRow(int index) {
    int count = 0;
    for (JPanel row : rows) {
      if (count % 2 == 0) {
        row.setBackground(new Color(200, 200, 230));
      } else {
        row.setBackground(new Color(240, 240, 240));
      }
      ++count;
    }
    if (index != -1) {
      rows.get(index).setBackground(new Color(170, 250, 170));
    }
    repaint();
    updateUI();
  }
}
  public SketchProperties(Editor e, Sketch s) {
    super();

    editor = e;
    sketch = s;

    fields = new HashMap<String, JComponent>();

    this.setPreferredSize(new Dimension(500, 400));
    this.setMinimumSize(new Dimension(500, 400));
    this.setMaximumSize(new Dimension(500, 400));
    this.setSize(new Dimension(500, 400));
    Point eLoc = editor.getLocation();
    int x = eLoc.x;
    int y = eLoc.y;

    Dimension eSize = editor.getSize();
    int w = eSize.width;
    int h = eSize.height;

    int cx = x + (w / 2);
    int cy = y + (h / 2);

    this.setLocation(new Point(cx - 250, cy - 200));
    this.setModal(true);

    outer = new JPanel(new BorderLayout());
    outer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    this.add(outer);

    win = new JPanel();
    win.setLayout(new BorderLayout());
    outer.add(win, BorderLayout.CENTER);

    buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    saveButton = new JButton("OK");
    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            save();
            SketchProperties.this.dispose();
          }
        });

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SketchProperties.this.dispose();
          }
        });

    buttonBar.add(saveButton);
    buttonBar.add(cancelButton);

    win.add(buttonBar, BorderLayout.SOUTH);

    tabs = new JTabbedPane();

    overviewPane = new JPanel();
    overviewPane.setLayout(new BoxLayout(overviewPane, BoxLayout.PAGE_AXIS));
    overviewPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    addTextField(overviewPane, "author", "Sketch author:");
    addTextArea(overviewPane, "summary", "Summary:");
    addTextArea(overviewPane, "license", "Copyright / License:");
    tabs.add("Overview", overviewPane);

    objectsPane = new JPanel();
    objectsPane.setLayout(new BoxLayout(objectsPane, BoxLayout.PAGE_AXIS));
    objectsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    addTextField(objectsPane, "board", "Board:");
    addTextField(objectsPane, "core", "Core:");
    addTextField(objectsPane, "compiler", "Compiler:");
    addTextField(objectsPane, "port", "Serial port:");
    addTextField(objectsPane, "programmer", "Programmer:");
    JButton setDef = new JButton("Set to current IDE values");
    setDef.setMaximumSize(setDef.getPreferredSize());
    setDef.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setObjectValues();
          }
        });
    objectsPane.add(Box.createVerticalGlue());
    objectsPane.add(setDef);

    tabs.add("Objects", objectsPane);

    win.add(tabs, BorderLayout.CENTER);

    this.setTitle("Sketch Properties");

    this.pack();
    this.setVisible(true);
  }
  /** Construct a new panel. */
  public JUnixPanel(ConfigApp app) {
    super(app, "Linux Paths:");

    /* initialize UI components */
    {
      pHomeDirComp = new JAbsoluteDirComp("Home Directory", sSize);
      add(pHomeDirComp);

      add(Box.createRigidArea(new Dimension(0, 20)));

      pTempDirComp = new JAbsoluteDirComp("Temporary Directory", sSize);
      add(pTempDirComp);

      add(Box.createRigidArea(new Dimension(0, 20)));

      pJavaHomeDirComp = new JAbsoluteDirComp("Java Home Directory", sSize);
      add(pJavaHomeDirComp);

      add(Box.createRigidArea(new Dimension(0, 40)));

      pJavadocDirComp = new JAbsoluteDirComp("Local Vendor Javadoc Directory", sSize);
      add(pJavadocDirComp);

      add(Box.createRigidArea(new Dimension(0, 20)));

      pExtraJavaLibsComp = new JAbsoluteJarsComp("Local Java Libraries", sSize);
      add(pExtraJavaLibsComp);

      add(Box.createRigidArea(new Dimension(0, 20)));
      add(Box.createVerticalGlue());

      pNotesDialog.setMessage(
          "Linux Parameters:",
          "The Home Directory is the absolute path to the parent directory of all user "
              + "home directories.  Usually this directory resides on a network file system and "
              + "may not be (/home) at your site.\n"
              + "\n"
              + "The Temporary Directory is absolute path to the directory used to write various "
              + "temporary files generated by Pipeline programs.  For optimal performance, this "
              + "directory should reside on a local file system.\n"
              + "\n"
              + "The Java Home Directory is the path to the root directory of the local Java "
              + "Runtime Environment (JRE) installed on Linux artist workstations used to run "
              + "Pipeline client programs.  By default, this is set to the JRE used to run this "
              + "configuration tool and the Pipeline server daemons in the Java Runtime section "
              + "above.  If you wish to use a different JRE for workstation clients than is used "
              + "for the server daemons, you can specify the location of the alternative JRE "
              + "here.\n"
              + "\n"
              + "The Local Vendor Javadoc Directory is the path to the root directory where the "
              + "documentation generated by javadoc for locally created Pipeline plugins and "
              + "standalone utils is located.  Providing this will allow users to easily access "
              + "the documentation for locally created plugins from Pipeline's user interface.\n"
              + "\n"
              + "The Local Java Libraries is a optional set of JAR files containing common Java "
              + "class shared by a large number of locally created plugins and/or standalone "
              + "utils.  Any JARs provided will be added to the Java classpath for all Pipeline "
              + "programs.  This is typically used for relatively large 3rd party libraries for "
              + "things such as XML parsing or SQL database connections which would otherwise "
              + "need to be embedded in many different plugin JARs.  Since these libraries "
              + "be dynamically updated (like plugins can), they are not suitable for anything "
              + "which might need to modified without a Pipeline shutdown.  This feature is "
              + "only an optimization to reduce plugin size and memory footprint but is not "
              + "required in order to use 3rd party Java libraries with Pipeline.");
    }
  }