Example usage for javax.swing BoxLayout BoxLayout

List of usage examples for javax.swing BoxLayout BoxLayout

Introduction

In this page you can find the example usage for javax.swing BoxLayout BoxLayout.

Prototype

@ConstructorProperties({ "target", "axis" })
public BoxLayout(Container target, int axis) 

Source Link

Document

Creates a layout manager that will lay out components along the given axis.

Usage

From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java

/**
 * Build action buttons sub panel//  w ww  . jav  a  2 s  .  c om
 */
protected JPanel buildActionButtonSubPanel() {

    // Add the action buttons sub panel.
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

    JButton cancelButton = new JButton(resourceBundle.getString("Cancel"));
    cancelButton.setMnemonic('A');
    cancelButton.setToolTipText(resourceBundle.getString("ToolTip.Cancel_measurement"));
    panel.add(Box.createHorizontalGlue());
    panel.add(saveButton);
    panel.add(Box.createRigidArea(new Dimension(10, 0)));
    panel.add(cancelButton);

    // Save button listener.
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            sendOutputToServer();
        }
    });

    // Cancel button listener.
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            confirmOnExit();
        }
    });

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);

    return (panel);
}

From source file:cimat.tesis.sna.visualization.ClusteringDemo.java

private void setUpView(BufferedReader br) throws IOException {

    Factory<Number> vertexFactory = new Factory<Number>() {
        int n = 0;

        public Number create() {
            return n++;
        }/*from  www  .  jav a 2s . c o m*/
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int n = 0;

        public Number create() {
            return n++;
        }
    };

    PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>(
            vertexFactory, edgeFactory);

    final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>();

    pnr.load(br, graph);

    //Create a simple layout frame
    //specify the Fruchterman-Rheingold layout algorithm
    final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>(
            new FRLayout<Number, Number>(graph));

    vv = new VisualizationViewer<Number, Number>(layout);
    vv.setBackground(Color.white);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()
            .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() {
        public Paint transform(Number v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.cyan;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY)
                return THIN;
            else
                return THICK;
        }
    });

    //add restart button
    JButton scramble = new JButton("Restart");
    scramble.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Layout layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }

    });

    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    //Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(graph.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    //      edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):"));
    //I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    eastControls.setOpaque(true);
    eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS));
    eastControls.add(Box.createVerticalGlue());
    eastControls.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    eastControls.setBorder(sliderBorder);
    //eastControls.add(eastSize);
    eastControls.add(Box.createVerticalGlue());

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    grid.add(scramble);
    grid.add(groupVertices);
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    p.add(gm.getModeComboBox());
    south.add(p);
    content.add(south, BorderLayout.SOUTH);
}

From source file:medsavant.uhn.cancer.UserCommentApp.java

private JPanel getHeaderPanel(UserComment lc) {
    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.Y_AXIS));
    JPanel leftJustPanel = new JPanel();
    leftJustPanel.setLayout(new BoxLayout(leftJustPanel, BoxLayout.X_AXIS));
    leftJustPanel.add(new JLabel("Posted " + lc.getModificationDate().toString() + " by: "));
    leftJustPanel.add(Box.createHorizontalGlue());
    headerPanel.add(leftJustPanel);/*from   ww w. jav a2s.c  o m*/

    leftJustPanel = new JPanel();
    leftJustPanel.setLayout(new BoxLayout(leftJustPanel, BoxLayout.X_AXIS));
    leftJustPanel.add(new JLabel(lc.getUser()));
    leftJustPanel.add(Box.createHorizontalGlue());
    headerPanel.add(leftJustPanel);
    headerPanel.add(Box.createHorizontalGlue());
    return headerPanel;
}

From source file:io.github.jeremgamer.editor.panels.Others.java

public Others(final JFrame frame, final OtherPanel op, final PanelSave ps) {
    this.frame = frame;

    this.setBorder(BorderFactory.createTitledBorder(""));
    JButton add = null;//from   w w  w .  jav a 2s  .  c om
    try {
        add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JOptionPane jop = new JOptionPane();
                @SuppressWarnings("static-access")
                String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(otherList),
                        "Nommez le composant :", "Crer un composant", JOptionPane.QUESTION_MESSAGE);

                if (name != null) {
                    for (int i = 0; i < data.getSize(); i++) {
                        if (data.get(i).equals(name)) {
                            name += "1";
                        }
                    }
                    data.addElement(name);
                    new OtherSave(name);
                    ActionPanel.updateLists();
                    PanelsPanel.updateLists();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    });

    JButton remove = null;
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                if (otherList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/others/"
                            + otherList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(otherList),
                            "tes-vous sr de vouloir supprimer ce composant?", "Avertissement",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        File dir = new File("projects/" + Editor.getProjectName() + "/panels");
                        for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE,
                                TrueFileFilter.INSTANCE)) {
                            if (!f.isDirectory()) {
                                try {
                                    ps.load(f);
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }

                                OtherSave os = new OtherSave();
                                try {
                                    os.load(file);
                                } catch (IOException e1) {
                                    e1.printStackTrace();
                                }
                                String type = null;
                                switch (os.getInt("type")) {
                                case 0:
                                    type = "Zone de saisie";
                                    break;
                                case 1:
                                    type = "Zone de saisie de mot de passe";
                                    break;
                                case 2:
                                    type = "Zone de saisie (Grande)";
                                    break;
                                case 3:
                                    type = "Case  cocher";
                                    break;
                                case 4:
                                    type = "Menu droulant";
                                    break;
                                case 5:
                                    type = "Barre de progression";
                                    break;
                                case 6:
                                    type = "Slider";
                                    break;
                                case 7:
                                    type = "Spinner";
                                    break;
                                }
                                for (String section : ps.getSectionsContaining(
                                        otherList.getSelectedValue() + " (" + type + ")")) {
                                    ps.removeSection(section);
                                    try {
                                        ps.save(f);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                        if (otherList.getSelectedValue().equals(op.getFileName())) {
                            op.setFileName("");
                        }
                        op.hide();
                        file.delete();
                        data.remove(otherList.getSelectedIndex());
                        ActionPanel.updateLists();
                        OtherPanel.updateLists();
                        PanelsPanel.updateLists();
                    }
                }
            } catch (NullPointerException npe) {
                npe.printStackTrace();
            }

        }

    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.add(add);
    buttons.add(remove);

    updateList();
    otherList.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("unchecked")
        public void mouseClicked(MouseEvent evt) {
            JList<String> list = (JList<String>) evt.getSource();
            if (evt.getClickCount() == 2) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    op.show();
                    op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            op.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            op.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        op.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    op.show();
                    op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            op.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            op.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            op.load(new File("projects/" + Editor.getProjectName() + "/others/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        op.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(otherList);
    listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    this.add(buttons);
    this.add(listPane);
    OtherPanel.updateLists();
}

From source file:org.imos.abos.plot.JfreeChartDemo.java

public void createAndShowGUI() {
    JButton autoZoom = new JButton("Auto Scale");
    autoZoom.addActionListener(new ActionListener() {
        @Override//from w ww.  j  a v  a2  s  .  c  o m
        public void actionPerformed(ActionEvent e) {
            System.out.println("Auto Zoom");

            chart.getXYPlot().getDomainAxis().setAutoRange(true);
            chart.getXYPlot().getRangeAxis().setAutoRange(true);
        }
    });
    JButton pdfButton = new JButton("PDF");
    pdfButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("PDF");
            createPDF(pdfName);
        }
    });
    yMax = new JTextField(10);
    yMax.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("yMax Set " + yMax.getText());
            double max = new Double(yMax.getText());
            double min = chart.getXYPlot().getRangeAxis().getRange().getLowerBound();
            chart.getXYPlot().getRangeAxis().setRange(min, max);
        }
    });
    yMin = new JTextField(10);
    yMin.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("yMin Set " + yMin.getText());
            double min = new Double(yMin.getText());
            double max = chart.getXYPlot().getRangeAxis().getRange().getUpperBound();
            chart.getXYPlot().getRangeAxis().setRange(min, max);
        }
    });
    JCheckBox showPoints = new JCheckBox("Show Points");
    showPoints.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                XYItemRenderer r = plot.getRenderer();
                if (r instanceof XYLineAndShapeRenderer) {
                    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
                    renderer.setBaseShapesVisible(false);
                }
            } else if (e.getStateChange() == ItemEvent.SELECTED) {
                XYItemRenderer r = plot.getRenderer();
                if (r instanceof XYLineAndShapeRenderer) {
                    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
                    renderer.setBaseShapesVisible(true);
                }
            }
        }

    });

    final JPanel jpanel = new JPanel();
    jpanel.setLayout(new BorderLayout());
    jpanel.add(chartPanel, BorderLayout.CENTER);
    JPanel right = new JPanel();
    JPanel ypmax = new JPanel();
    ypmax.add(yMax);
    JPanel ypmin = new JPanel();
    ypmin.add(yMin);
    right.setLayout(new BoxLayout(right, BoxLayout.PAGE_AXIS));
    right.add(ypmax);
    right.add(ypmin);
    right.add(autoZoom);
    right.add(pdfButton);
    right.add(showPoints);
    jpanel.add(right, BorderLayout.LINE_END);

    setContentPane(jpanel);

    pack();
    setLocationRelativeTo(null);
    setVisible(true);
}

From source file:ch.zhaw.ias.dito.ui.AnalysisPanel.java

private JPanel createDecompositionPanel(String title, double[][] mdsValues) {
    JFreeChart chart = ChartFactory.createScatterPlot(title, null, null, new MdsXYDataset(mdsValues),
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRenderer().setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override//from   w  w  w.j a va 2 s.c o m
        public String generateToolTip(XYDataset dataset, int series, int item) {
            return "item #" + (item + 1);
        }
    });

    JPanel mdsPanel = new JPanel(new BorderLayout(0, 10));
    mdsPanel.add(new ChartPanel(chart), BorderLayout.CENTER);
    dimensionsCombo = new JComboBox(new Integer[] { 2, 3 });
    JButton exportButton = new JButton(Translation.INSTANCE.get("s4.bu.exportDecomposition"));
    exportButton.addActionListener(this);
    JPanel mdsInputPanel = new JPanel();
    mdsInputPanel.setLayout(new BoxLayout(mdsInputPanel, BoxLayout.LINE_AXIS));
    mdsInputPanel.add(Box.createHorizontalGlue());
    mdsInputPanel.add(Box.createHorizontalGlue());
    mdsInputPanel.add(new JLabel(Translation.INSTANCE.get("s4.lb.dimension")));
    mdsInputPanel.add(Box.createHorizontalStrut(10));
    mdsInputPanel.add(dimensionsCombo);
    mdsInputPanel.add(Box.createHorizontalStrut(10));
    mdsInputPanel.add(exportButton);
    mdsPanel.add(mdsInputPanel, BorderLayout.SOUTH);

    return mdsPanel;
}

From source file:eu.delving.sip.frames.AllFrames.java

public JComponent getSidePanel() {
    JPanel arrangements = new JPanel();
    arrangements.setLayout(new BoxLayout(arrangements, BoxLayout.Y_AXIS));
    for (Arrangement a : this.arrangements) {
        JButton b = new JButton(a);
        b.setHorizontalTextPosition(JButton.CENTER);
        b.setVerticalTextPosition(JButton.BOTTOM);
        b.setFont(new Font("Sans", Font.PLAIN, 10));
        arrangements.add(b);/*from w ww .  ja v  a  2  s  . co m*/
        arrangements.add(Box.createVerticalStrut(5));
    }
    arrangements.add(Box.createVerticalGlue());
    JPanel p = new JPanel(new BorderLayout());
    p.add(arrangements, BorderLayout.CENTER);
    return scrollV(p);
}

From source file:BeanContainer.java

  protected JMenuBar createMenuBar() {
  JMenuBar menuBar = new JMenuBar();
    //from   ww w .ja  va2 s. c  om
  JMenu mFile = new JMenu("File");

  JMenuItem mItem = new JMenuItem("New...");
  ActionListener lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {  
      Thread newthread = new Thread() {
        public void run() {
          String result = (String)JOptionPane.showInputDialog(
            BeanContainer.this, 
            "Please enter class name to create a new bean", 
            "Input", JOptionPane.INFORMATION_MESSAGE, null, 
            null, m_className);
          repaint();
          if (result==null)
            return;
          try {
            m_className = result;
            Class cls = Class.forName(result);
            Object obj = cls.newInstance();
            if (obj instanceof Component) {
              m_activeBean = (Component)obj;
              m_activeBean.addFocusListener(
                BeanContainer.this);
              m_activeBean.requestFocus();
              getContentPane().add(m_activeBean);
            }
            validate();
          }
          catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(
              BeanContainer.this, "Error: "+ex.toString(),
              "Warning", JOptionPane.WARNING_MESSAGE);
          }
        }
      };
      newthread.start();
    }
  };
  mItem.addActionListener(lst);
  mFile.add(mItem);

  mItem = new JMenuItem("Load...");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {  
      Thread newthread = new Thread() {
        public void run() {
          m_chooser.setCurrentDirectory(m_currentDir);
          m_chooser.setDialogTitle(
            "Please select file with serialized bean");
          int result = m_chooser.showOpenDialog(
            BeanContainer.this);
          repaint();
          if (result != JFileChooser.APPROVE_OPTION)
            return;
          m_currentDir = m_chooser.getCurrentDirectory();
          File fChoosen = m_chooser.getSelectedFile();
          try {
            FileInputStream fStream = 
              new FileInputStream(fChoosen);
            ObjectInput  stream  =  
              new ObjectInputStream(fStream);
            Object obj = stream.readObject();
            if (obj instanceof Component) {
              m_activeBean = (Component)obj;
              m_activeBean.addFocusListener(
                BeanContainer.this);
              m_activeBean.requestFocus();
              getContentPane().add(m_activeBean);
            }
            stream.close();
            fStream.close();
            validate();
          }
          catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(
              BeanContainer.this, "Error: "+ex.toString(),
              "Warning", JOptionPane.WARNING_MESSAGE);
          }
          repaint();
        }
      };
      newthread.start();
    }
  };
  mItem.addActionListener(lst);
  mFile.add(mItem);

  mItem = new JMenuItem("Save...");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      Thread newthread = new Thread() {
        public void run() {
          if (m_activeBean == null)
            return;
          m_chooser.setDialogTitle(
            "Please choose file to serialize bean");
          m_chooser.setCurrentDirectory(m_currentDir);
          int result = m_chooser.showSaveDialog(
            BeanContainer.this);
          repaint();
          if (result != JFileChooser.APPROVE_OPTION)
            return;
          m_currentDir = m_chooser.getCurrentDirectory();
          File fChoosen = m_chooser.getSelectedFile();
          try {
            FileOutputStream fStream = 
              new FileOutputStream(fChoosen);
            ObjectOutput stream  =  
              new ObjectOutputStream(fStream);
            stream.writeObject(m_activeBean);
            stream.close();
            fStream.close();
          }
          catch (Exception ex) {
            ex.printStackTrace();
          JOptionPane.showMessageDialog(
            BeanContainer.this, "Error: "+ex.toString(),
            "Warning", JOptionPane.WARNING_MESSAGE);
          }
        }
      };
      newthread.start();
    }
  };
  mItem.addActionListener(lst);
  mFile.add(mItem);

  mFile.addSeparator();

  mItem = new JMenuItem("Exit");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      System.exit(0);
    }
  };
  mItem.addActionListener(lst);
  mFile.add(mItem);
  menuBar.add(mFile);
    
  JMenu mEdit = new JMenu("Edit");

  mItem = new JMenuItem("Delete");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      if (m_activeBean == null)
        return;
      Object obj = m_editors.get(m_activeBean);
      if (obj != null) {
        BeanEditor editor = (BeanEditor)obj;
        editor.dispose();
        m_editors.remove(m_activeBean);
      }
      getContentPane().remove(m_activeBean);
      m_activeBean = null;
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  mEdit.add(mItem);

  mItem = new JMenuItem("Properties...");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      if (m_activeBean == null)
        return;
      Object obj = m_editors.get(m_activeBean);
      if (obj != null) {
        BeanEditor editor = (BeanEditor)obj;
        editor.setVisible(true);
        editor.toFront();
      }
      else {
        BeanEditor editor = new BeanEditor(m_activeBean);
        m_editors.put(m_activeBean, editor);
      }
    }
  };
  mItem.addActionListener(lst);
  mEdit.add(mItem);
  menuBar.add(mEdit);

  JMenu mLayout = new JMenu("Layout");
  ButtonGroup group = new ButtonGroup();

  mItem = new JRadioButtonMenuItem("FlowLayout");
  mItem.setSelected(true);
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e){
      getContentPane().setLayout(new FlowLayout());
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);

  mItem = new JRadioButtonMenuItem("GridLayout");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e){
      int col = 3;
      int row = (int)Math.ceil(getContentPane().
        getComponentCount()/(double)col);
      getContentPane().setLayout(new GridLayout(row, col, 10, 10));
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);
    
  mItem = new JRadioButtonMenuItem("BoxLayout - X");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      getContentPane().setLayout(new BoxLayout(
        getContentPane(), BoxLayout.X_AXIS));
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);
    
  mItem = new JRadioButtonMenuItem("BoxLayout - Y");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      getContentPane().setLayout(new BoxLayout(
        getContentPane(), BoxLayout.Y_AXIS));
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);
    
  mItem = new JRadioButtonMenuItem("DialogLayout");
  lst = new ActionListener() { 
    public void actionPerformed(ActionEvent e) {
      getContentPane().setLayout(new DialogLayout());
      validate();
      repaint();
    }
  };
  mItem.addActionListener(lst);
  group.add(mItem);
  mLayout.add(mItem);

  menuBar.add(mLayout);

  return menuBar;
}

From source file:jboost.visualization.HistogramFrame.java

private JSplitPane getJSplitPane1() {
    if (jSplitPane1 == null) {
        jSplitPane1 = new JSplitPane();
        jSplitPane1.setPreferredSize(new Dimension(546, 400));
        jSplitPane1.setDividerLocation(400);
        jSplitPane1.setDoubleBuffered(true);
        jSplitPane1.setLastDividerLocation(100);
        {/*from  w  ww  .j ava 2  s .  c om*/
            jPanel1 = new JPanel();
            jSplitPane1.add(jPanel1, JSplitPane.RIGHT);
            jPanel1.setPreferredSize(new Dimension(10, 406));

            BoxLayout jPanel1Layout = new BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS);
            jPanel1.setLayout(jPanel1Layout);
            {
                histogramDataset = new XYIntervalSeriesCollection();
                fluctDataset = new XYIntervalSeriesCollection();
                weightDataset = new XYSeriesCollection();
                potentialDataset = new XYSeriesCollection();

                updateHistogramDatasets();
                histogramChart = createHistogramChart();

                histogramPanel = new ChartPanel(histogramChart);
                jPanel1.add(histogramPanel);
                histogramPanel.setPopupMenu(null);
                histogramPanel.setPreferredSize(new Dimension(433, 374));
            }
        }
        {
            jPanel2 = new JPanel();
            jSplitPane1.add(jPanel2, JSplitPane.LEFT);
            jPanel2.setPreferredSize(new Dimension(10, 393));

            BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS);
            jPanel2.setLayout(jPanel2Layout);
            jPanel2.setOpaque(false);

            rocDataset = new XYSeriesCollection();
            XYSeries rocSeries = rawData.generateRoC(negLabel, posLabel);
            rocDataset.addSeries(rocSeries);
            rocChart = createRocChart(rocDataset);
            rocPanel = new ChartPanel(rocChart);
            jPanel2.add(rocPanel);
            rocPanel.setPopupMenu(null);
            rocPanel.setPreferredSize(new Dimension(10, 406));
        }
        {
            jSlider1 = new JSlider();
            jPanel1.add(jSlider1);
            jSlider1.setLayout(null);
            jSlider1.setPreferredSize(new Dimension(10, 16));
            jSlider1.addChangeListener(new ChangeListener() {

                public void stateChanged(ChangeEvent evt) {
                    updateUpperMarker();
                }
            });
        }
        {
            jSlider2 = new JSlider();
            jPanel1.add(jSlider2);
            jSlider2.setLayout(null);
            jSlider2.setPreferredSize(new Dimension(10, 16));
            jSlider2.addChangeListener(new ChangeListener() {

                public void stateChanged(ChangeEvent evt) {
                    updateLowerMarker();
                }
            });

        }
    }
    return jSplitPane1;
}

From source file:ImageComponentByReferenceTest.java

public void init() {
    if (texImage == null) {
        // the path to the image for an applet
        try {/*from   w  ww  .  j a v a  2 s  . com*/
            texImage = new java.net.URL(getCodeBase().toString() + "/one.jpg");
        } catch (java.net.MalformedURLException ex) {
            System.out.println(ex.getMessage());
            System.exit(1);
        }
    }

    Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
    BranchGroup scene = createSceneGraph();
    u = new SimpleUniverse(c);
    u.getViewingPlatform().setNominalViewingTransform();
    u.addBranchGraph(scene);
    Container contentPane = getContentPane();
    JPanel p = new JPanel();
    BoxLayout boxlayout = new BoxLayout(p, BoxLayout.Y_AXIS);
    p.setLayout(boxlayout);
    contentPane.add("Center", c);

    contentPane.add("South", p);

    p.add(createImagePanel());

}