Example usage for javax.swing JPanel getComponent

List of usage examples for javax.swing JPanel getComponent

Introduction

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

Prototype

public Component getComponent(int n) 

Source Link

Document

Gets the nth component in this container.

Usage

From source file:ome.formats.importer.gui.FileQueueChooser.java

/**
 * File chooser on the file picker tab of the importer
 * //from   w ww .  j av  a  2  s .  c  om
 * @param config ImportConfig
 * @param scanReader OmeroWrapper
 */
FileQueueChooser(ImportConfig config, OMEROWrapper scanReader) {

    try {
        JPanel fp = null;
        JToolBar tb = null;

        String refreshIcon = "gfx/recycled12.png";
        refreshBtn = GuiCommonElements.addBasicButton("Refresh ", refreshIcon, null);
        refreshBtn.setActionCommand(REFRESHED);
        refreshBtn.addActionListener(this);
        JPanel panel = new JPanel();

        // Set up the main panel for tPane, quit, and send buttons
        double mainTable[][] = { { 10, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.FILL, 10 }, // columns
                { TableLayout.PREFERRED } }; // rows

        TableLayout tl = new TableLayout(mainTable);
        panel.setLayout(tl);

        // Here's a nice little pieces of test code to find all components
        if (DEBUG) {
            try {
                Component[] components = this.getComponents();
                Component component = null;
                System.err.println("Components: " + components.length);
                for (int i = 0; i < components.length; i++) {
                    component = components[i];
                    System.err.println("Component " + i + " = " + component.getClass());
                }
            } catch (Exception e) {
                log.info("component exception ignore");
            }
        }

        if (laf.contains("AquaLookAndFeel")) {
            //Do Aqua implimentation
            fp = (JPanel) this.getComponent(1);
            fp.setLayout(new BoxLayout(fp, BoxLayout.X_AXIS));
            fp.add(refreshBtn);
        } else if (laf.contains("QuaquaLookAndFeel")) {
            //do Quaqua implimentation
            fp = (JPanel) this.getComponent(1);
            panel.add(refreshBtn, "1,0,C,C");
            panel.add(fp.getComponent(0), "2,0,C,C");
            fp.add(panel, BorderLayout.NORTH);
        } else if (laf.contains("Windows")) {
            try {
                //Do windows implimentation
                tb = (JToolBar) this.getComponent(1);
                refreshBtn.setToolTipText("Refresh");
                refreshBtn.setText(null);
                tb.add(refreshBtn, 8);
            } catch (Exception e) {
                log.info("Exception ignored.");
            }
        }
        /* Disabled temporarily */
        else if (laf.contains("MetalLookAndFeel")) {
            //Do Metal implimentation
            JPanel prefp = (JPanel) this.getComponent(0);
            fp = (JPanel) prefp.getComponent(0);
            refreshBtn.setToolTipText("Refresh");
            refreshBtn.setText(null);
            Dimension size = new Dimension(24, 24);
            refreshBtn.setMaximumSize(size);
            refreshBtn.setPreferredSize(size);
            refreshBtn.setMinimumSize(size);
            refreshBtn.setSize(size);
            fp.add(Box.createRigidArea(new Dimension(5, 0)));
            fp.add(refreshBtn);
        }

        else if (laf.contains("GTKLookAndFeel")) {
            //do GTK implimentation
            fp = (JPanel) this.getComponent(0);
            refreshBtn.setIcon(null);
            fp.add(refreshBtn);
        } else if (laf.contains("MotifLookAndFeel")) {
            //do Motif implimentation
            fp = (JPanel) this.getComponent(0);
            fp.add(refreshBtn);
        }

        if (fp != null && DEBUG == true) {
            fp.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                    fp.getBorder()));
            System.err.println(fp.getLayout());
        }

        if (tb != null && DEBUG == true) {
            tb.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
                    tb.getBorder()));
            System.err.println(tb.getLayout());
        }
    } catch (ArrayIndexOutOfBoundsException e) {
    }

    File dir = null;
    if (config != null)
        dir = config.savedDirectory.get();

    if (dir != null) {
        this.setCurrentDirectory(dir);
    } else {
        this.setCurrentDirectory(this.getFileSystemView().getHomeDirectory());
    }

    this.setControlButtonsAreShown(false);
    this.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    this.setMultiSelectionEnabled(true);
    this.setDragEnabled(true);

    setAcceptAllFileFilterUsed(false);

    FileFilter[] originalFF = null;
    int readerFFSize = 0;
    if (scanReader != null) {
        originalFF = loci.formats.gui.GUITools.buildFileFilters(scanReader.getImageReader());
        FileFilter filter;
        List<FileFilter> extensionFilters = new ArrayList<FileFilter>();
        for (int i = 0; i < originalFF.length; i++) {
            filter = originalFF[i];
            if (filter instanceof ComboFileFilter) {
                ComboFileFilter cff = (ComboFileFilter) filter;
                extensionFilters.add(cff);
                extensionFilters.addAll(Arrays.asList(cff.getFilters()));
                break;
            }
        }
        if (extensionFilters != null) {
            originalFF = extensionFilters.toArray(new FileFilter[extensionFilters.size()]);
        }
        readerFFSize = originalFF.length;
    }

    FileFilter[] ff = new FileFilter[readerFFSize + 7];
    ff[0] = new DashFileFilter();
    ff[readerFFSize + 1] = new DashFileFilter();
    ff[readerFFSize + 2] = new R3DNewFileFilter();
    ff[readerFFSize + 3] = new R3DOldFileFilter();
    ff[readerFFSize + 4] = new D3DNewFileFilter();
    ff[readerFFSize + 5] = new D3DOldFileFilter();
    ff[readerFFSize + 6] = new D3DNPrjFileFilter();

    if (originalFF != null)
        System.arraycopy(originalFF, 0, ff, 1, originalFF.length);

    //this.addChoosableFileFilter(new DashFileFilter());

    //FileFilter combo = null;
    for (int i = 0; i < ff.length; i++)
        this.addChoosableFileFilter(ff[i]);
    this.setFileFilter(ff[1]);

    //Retrieve all JLists and JTables from the fileChooser
    fileListObjects = getFileListObjects(this);

    //For now, assume the first list/table found is the correct one
    //(this will need to be adjusted if LAF bugs crop up)
    //Shouldn't break anything since dblclick will just stop working if
    //this changes for some reason
    if (fileListObjects.length > 0 && !laf.contains("Windows")) {
        fileList = fileListObjects[0];
        MouseCommand mc = new MouseCommand();
        fileList.addMouseListener(mc);
    }
}

From source file:org.broad.igv.hic.MainWindow.java

private void initComponents() {
    JPanel mainPanel = new JPanel();
    JPanel toolbarPanel = new JPanel();

    //======== this ========

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    mainPanel.setLayout(new BorderLayout());

    toolbarPanel.setBorder(null);/*from  ww w .ja  v  a  2 s  . c  o m*/
    toolbarPanel.setLayout(new GridLayout());

    JPanel chrSelectionPanel = new JPanel();
    chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder());
    chrSelectionPanel.setMinimumSize(new Dimension(130, 57));
    chrSelectionPanel.setPreferredSize(new Dimension(130, 57));
    chrSelectionPanel.setLayout(new BorderLayout());

    JPanel panel10 = new JPanel();
    panel10.setBackground(new Color(204, 204, 204));
    panel10.setLayout(new BorderLayout());

    JLabel label3 = new JLabel();
    label3.setText("Chromosomes");
    label3.setHorizontalAlignment(SwingConstants.CENTER);
    panel10.add(label3, BorderLayout.CENTER);

    chrSelectionPanel.add(panel10, BorderLayout.PAGE_START);

    JPanel panel9 = new JPanel();
    panel9.setBackground(new Color(238, 238, 238));
    panel9.setLayout(new BoxLayout(panel9, BoxLayout.X_AXIS));

    //---- chrBox1 ----
    chrBox1 = new JComboBox();
    chrBox1.setModel(new DefaultComboBoxModel(new String[] { "All" }));
    chrBox1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            chrBox1ActionPerformed(e);
        }
    });
    panel9.add(chrBox1);

    //---- chrBox2 ----
    chrBox2 = new JComboBox();
    chrBox2.setModel(new DefaultComboBoxModel(new String[] { "All" }));
    chrBox2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            chrBox2ActionPerformed(e);
        }
    });
    panel9.add(chrBox2);

    //---- refreshButton ----
    JideButton refreshButton = new JideButton();
    refreshButton
            .setIcon(new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif")));
    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            refreshButtonActionPerformed(e);
        }
    });
    panel9.add(refreshButton);

    chrSelectionPanel.add(panel9, BorderLayout.CENTER);

    toolbarPanel.add(chrSelectionPanel);

    //======== displayOptionPanel ========
    JPanel displayOptionPanel = new JPanel();
    JPanel panel1 = new JPanel();
    displayOptionComboBox = new JComboBox();

    displayOptionPanel.setBackground(new Color(238, 238, 238));
    displayOptionPanel.setBorder(LineBorder.createGrayLineBorder());
    displayOptionPanel.setLayout(new BorderLayout());

    //======== panel14 ========

    JPanel panel14 = new JPanel();
    panel14.setBackground(new Color(204, 204, 204));
    panel14.setLayout(new BorderLayout());

    //---- label4 ----
    JLabel label4 = new JLabel();
    label4.setText("Show");
    label4.setHorizontalAlignment(SwingConstants.CENTER);
    panel14.add(label4, BorderLayout.CENTER);

    displayOptionPanel.add(panel14, BorderLayout.PAGE_START);

    //======== panel1 ========

    panel1.setBorder(new EmptyBorder(0, 10, 0, 10));
    panel1.setLayout(new GridLayout(1, 0, 20, 0));

    //---- comboBox1 ----
    displayOptionComboBox
            .setModel(new DefaultComboBoxModel(new String[] { DisplayOption.OBSERVED.toString() }));
    displayOptionComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            displayOptionComboBoxActionPerformed(e);
        }
    });
    panel1.add(displayOptionComboBox);

    displayOptionPanel.add(panel1, BorderLayout.CENTER);

    toolbarPanel.add(displayOptionPanel);

    //======== colorRangePanel ========

    JPanel colorRangePanel = new JPanel();
    JLabel colorRangeLabel = new JLabel();
    colorRangeSlider = new RangeSlider();
    colorRangePanel.setBorder(LineBorder.createGrayLineBorder());
    colorRangePanel.setMinimumSize(new Dimension(96, 70));
    colorRangePanel.setPreferredSize(new Dimension(202, 70));
    colorRangePanel.setMaximumSize(new Dimension(32769, 70));
    colorRangePanel.setLayout(new BorderLayout());

    //======== panel11 ========

    JPanel colorLabelPanel = new JPanel();
    colorLabelPanel.setBackground(new Color(204, 204, 204));
    colorLabelPanel.setLayout(new BorderLayout());

    //---- colorRangeLabel ----
    colorRangeLabel.setText("Color Range");
    colorRangeLabel.setHorizontalAlignment(SwingConstants.CENTER);
    colorRangeLabel.setToolTipText("Range of color scale in counts per mega-base squared.");
    colorRangeLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    colorRangeLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider);
                rangeDialog.setVisible(true);
            }
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider);
            rangeDialog.setVisible(true);
        }
    });
    colorLabelPanel.add(colorRangeLabel, BorderLayout.CENTER);

    colorRangePanel.add(colorLabelPanel, BorderLayout.PAGE_START);

    //---- colorRangeSlider ----
    colorRangeSlider.setPaintTicks(true);
    colorRangeSlider.setPaintLabels(true);
    colorRangeSlider.setLowerValue(0);
    colorRangeSlider.setMajorTickSpacing(500);
    colorRangeSlider.setMaximumSize(new Dimension(32767, 52));
    colorRangeSlider.setPreferredSize(new Dimension(200, 52));
    colorRangeSlider.setMinimumSize(new Dimension(36, 52));
    colorRangeSlider.setMaximum(2000);
    colorRangeSlider.setUpperValue(500);
    colorRangeSlider.setMinorTickSpacing(100);
    colorRangeSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            colorRangeSliderStateChanged(e);
        }
    });
    colorRangePanel.add(colorRangeSlider, BorderLayout.PAGE_END);

    //        JPanel colorRangeTextPanel = new JPanel();
    //        colorRangeTextPanel.setLayout(new FlowLayout());
    //        JTextField minField = new JTextField();
    //        minField.setPreferredSize(new Dimension(50, 15));
    //        colorRangeTextPanel.add(minField);
    //        colorRangeTextPanel.add(new JLabel(" - "));
    //        JTextField maxField = new JTextField();
    //        maxField.setPreferredSize(new Dimension(50, 15));
    //        colorRangeTextPanel.add(maxField);
    //        colorRangeTextPanel.setPreferredSize(new Dimension(200, 52));
    //        colorRangePanel.add(colorRangeTextPanel, BorderLayout.PAGE_END);

    toolbarPanel.add(colorRangePanel);

    //======== resolutionPanel ========

    JLabel resolutionLabel = new JLabel();
    JPanel resolutionPanel = new JPanel();

    resolutionPanel.setBorder(LineBorder.createGrayLineBorder());
    resolutionPanel.setLayout(new BorderLayout());

    //======== panel12 ========

    JPanel panel12 = new JPanel();
    panel12.setBackground(new Color(204, 204, 204));
    panel12.setLayout(new BorderLayout());

    //---- resolutionLabel ----
    resolutionLabel.setText("Resolution");
    resolutionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    resolutionLabel.setBackground(new Color(204, 204, 204));
    panel12.add(resolutionLabel, BorderLayout.CENTER);

    resolutionPanel.add(panel12, BorderLayout.PAGE_START);

    //======== panel2 ========

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

    //---- resolutionSlider ----
    resolutionSlider = new JSlider();
    resolutionSlider.setMaximum(8);
    resolutionSlider.setMajorTickSpacing(1);
    resolutionSlider.setPaintTicks(true);
    resolutionSlider.setSnapToTicks(true);
    resolutionSlider.setPaintLabels(true);
    resolutionSlider.setMinorTickSpacing(1);

    Dictionary<Integer, JLabel> resolutionLabels = new Hashtable<Integer, JLabel>();
    Font f = FontManager.getFont(8);
    for (int i = 0; i < HiCGlobals.zoomLabels.length; i++) {
        if ((i + 1) % 2 == 0) {
            final JLabel tickLabel = new JLabel(HiCGlobals.zoomLabels[i]);
            tickLabel.setFont(f);
            resolutionLabels.put(i, tickLabel);
        }
    }
    resolutionSlider.setLabelTable(resolutionLabels);
    // Setting the zoom should always be done by calling resolutionSlider.setValue() so work isn't done twice.
    resolutionSlider.addChangeListener(new ChangeListener() {
        // Change zoom level while staying centered on current location.
        // Centering is relative to the bounds of the data, which might not be the bounds of the window

        public void stateChanged(ChangeEvent e) {
            if (!resolutionSlider.getValueIsAdjusting()) {
                int idx = resolutionSlider.getValue();
                idx = Math.max(0, Math.min(idx, MAX_ZOOM));

                if (hic.zd != null && idx == hic.zd.getZoom()) {
                    // Nothing to do
                    return;
                }

                if (hic.xContext != null) {
                    int centerLocationX = (int) hic.xContext
                            .getChromosomePosition(getHeatmapPanel().getWidth() / 2);
                    int centerLocationY = (int) hic.yContext
                            .getChromosomePosition(getHeatmapPanel().getHeight() / 2);
                    hic.setZoom(idx, centerLocationX, centerLocationY, false);
                }
                //zoomInButton.setEnabled(newZoom < MAX_ZOOM);
                //zoomOutButton.setEnabled(newZoom > 0);
            }
        }
    });
    panel2.add(resolutionSlider);

    resolutionPanel.add(panel2, BorderLayout.CENTER);

    toolbarPanel.add(resolutionPanel);

    mainPanel.add(toolbarPanel, BorderLayout.NORTH);

    //======== hiCPanel ========

    final JPanel hiCPanel = new JPanel();
    hiCPanel.setLayout(new HiCLayout());

    //---- rulerPanel2 ----
    rulerPanel2 = new HiCRulerPanel(hic);
    rulerPanel2.setMaximumSize(new Dimension(4000, 50));
    rulerPanel2.setMinimumSize(new Dimension(1, 50));
    rulerPanel2.setPreferredSize(new Dimension(1, 50));
    rulerPanel2.setBorder(null);

    JPanel panel2_5 = new JPanel();
    panel2_5.setLayout(new BorderLayout());
    panel2_5.add(rulerPanel2, BorderLayout.SOUTH);

    trackPanel = new TrackPanel(hic);
    trackPanel.setMaximumSize(new Dimension(4000, 50));
    trackPanel.setPreferredSize(new Dimension(1, 50));
    trackPanel.setMinimumSize(new Dimension(1, 50));
    trackPanel.setBorder(null);

    //        trackPanelScrollpane = new JScrollPane();
    //        trackPanelScrollpane.getViewport().add(trackPanel);
    //        trackPanelScrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    //        trackPanelScrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    //        trackPanelScrollpane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
    //        trackPanelScrollpane.setBackground(new java.awt.Color(237, 237, 237));
    //        trackPanelScrollpane.setVisible(false);
    //        panel2_5.add(trackPanelScrollpane, BorderLayout.NORTH);
    //
    trackPanel.setVisible(false);
    panel2_5.add(trackPanel, BorderLayout.NORTH);

    hiCPanel.add(panel2_5, BorderLayout.NORTH);

    //---- rulerPanel1 ----
    rulerPanel1 = new HiCRulerPanel(hic);
    rulerPanel1.setMaximumSize(new Dimension(50, 4000));
    rulerPanel1.setPreferredSize(new Dimension(50, 500));
    rulerPanel1.setBorder(null);
    rulerPanel1.setMinimumSize(new Dimension(50, 1));
    hiCPanel.add(rulerPanel1, BorderLayout.WEST);

    //---- heatmapPanel ----
    heatmapPanel = new HeatmapPanel(this, hic);
    heatmapPanel.setBorder(LineBorder.createBlackLineBorder());
    heatmapPanel.setMaximumSize(new Dimension(500, 500));
    heatmapPanel.setMinimumSize(new Dimension(500, 500));
    heatmapPanel.setPreferredSize(new Dimension(500, 500));
    heatmapPanel.setBackground(new Color(238, 238, 238));
    hiCPanel.add(heatmapPanel, BorderLayout.CENTER);

    //======== panel8 ========

    JPanel rightSidePanel = new JPanel();
    rightSidePanel.setMaximumSize(new Dimension(120, 100));
    rightSidePanel.setBorder(new EmptyBorder(0, 10, 0, 0));
    rightSidePanel.setLayout(null);

    //---- thumbnailPanel ----
    thumbnailPanel = new ThumbnailPanel(this, hic);
    thumbnailPanel.setMaximumSize(new Dimension(100, 100));
    thumbnailPanel.setMinimumSize(new Dimension(100, 100));
    thumbnailPanel.setPreferredSize(new Dimension(100, 100));
    thumbnailPanel.setBorder(LineBorder.createBlackLineBorder());
    thumbnailPanel.setPreferredSize(new Dimension(100, 100));
    thumbnailPanel.setBounds(new Rectangle(new Point(20, 0), thumbnailPanel.getPreferredSize()));
    rightSidePanel.add(thumbnailPanel);

    //======== xPlotPanel ========

    xPlotPanel = new JPanel();
    xPlotPanel.setPreferredSize(new Dimension(250, 100));
    xPlotPanel.setLayout(null);

    rightSidePanel.add(xPlotPanel);
    xPlotPanel.setBounds(10, 100, xPlotPanel.getPreferredSize().width, 228);

    //======== yPlotPanel ========

    yPlotPanel = new JPanel();
    yPlotPanel.setPreferredSize(new Dimension(250, 100));
    yPlotPanel.setLayout(null);

    rightSidePanel.add(yPlotPanel);
    yPlotPanel.setBounds(10, 328, yPlotPanel.getPreferredSize().width, 228);

    // compute preferred size
    Dimension preferredSize = new Dimension();
    for (int i = 0; i < rightSidePanel.getComponentCount(); i++) {
        Rectangle bounds = rightSidePanel.getComponent(i).getBounds();
        preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
        preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
    }
    Insets insets = rightSidePanel.getInsets();
    preferredSize.width += insets.right;
    preferredSize.height += insets.bottom;
    rightSidePanel.setMinimumSize(preferredSize);
    rightSidePanel.setPreferredSize(preferredSize);

    hiCPanel.add(rightSidePanel, BorderLayout.EAST);

    mainPanel.add(hiCPanel, BorderLayout.CENTER);

    contentPane.add(mainPanel, BorderLayout.CENTER);

    JMenuBar menuBar = createMenuBar(hiCPanel);
    contentPane.add(menuBar, BorderLayout.NORTH);

    // setup the glass pane to display a wait cursor when visible, and to grab all mouse events
    rootPane.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    rootPane.getGlassPane().addMouseListener(new MouseAdapter() {
    });

}

From source file:org.metawidget.integrationtest.swing.allwidgets.SwingAllWidgetsTest.java

protected void runTest(AdvancedWidgetProcessor<JComponent, SwingMetawidget> processor) throws Exception {

    // Model/*from   w  w w .  ja  v  a 2  s  .  co  m*/

    AllWidgets allWidgets = new AllWidgets$$EnhancerByCGLIB$$1234();

    // App

    SwingMetawidget metawidget = new SwingMetawidget();
    metawidget.setConfig("org/metawidget/integrationtest/swing/allwidgets/metawidget.xml");
    metawidget.addWidgetProcessor(processor);
    metawidget.addWidgetProcessor(new ReflectionBindingProcessor());
    metawidget.setMetawidgetLayout(new SeparatorLayoutDecorator(new SeparatorLayoutDecoratorConfig().setLayout(
            new org.metawidget.swing.layout.GridBagLayout(new GridBagLayoutConfig().setNumberOfColumns(2)))));

    metawidget.setToInspect(allWidgets);

    metawidget.add(new Stub("mystery"));

    // Test missing components

    try {
        metawidget.getValue("no-such-component");
        fail();
    } catch (MetawidgetException e1) {
        assertEquals("No component named 'no-such-component'", e1.getMessage());

        try {
            metawidget.getValue("textbox", "no-such-component");
            fail();
        } catch (MetawidgetException e2) {
            assertEquals("No component named 'textbox', 'no-such-component'", e2.getMessage());

            try {
                metawidget.getValue("textbox", "no-such-component1", "no-such-component2");
                fail();
            } catch (MetawidgetException e3) {
                assertEquals(
                        "No such component 'no-such-component1' of 'textbox', 'no-such-component1', 'no-such-component2'",
                        e3.getMessage());
            }
        }
    }

    try {
        metawidget.setValue(null, "no-such-component");
        fail();
    } catch (MetawidgetException e1) {
        assertEquals("No component named 'no-such-component'", e1.getMessage());

        try {
            metawidget.setValue(null, "textbox", "no-such-component");
            fail();
        } catch (MetawidgetException e2) {
            assertEquals("No component named 'textbox', 'no-such-component'", e2.getMessage());

            try {
                metawidget.setValue(null, "textbox", "no-such-component1", "no-such-component2");
                fail();
            } catch (MetawidgetException e3) {
                assertEquals(
                        "No such component 'no-such-component1' of 'textbox', 'no-such-component1', 'no-such-component2'",
                        e3.getMessage());
            }
        }
    }

    // Check what created, and edit it

    assertEquals("Textbox*:", ((JLabel) metawidget.getComponent(0)).getText());
    assertTrue(metawidget.getComponent(1) instanceof JTextField);
    assertEquals("Textbox", metawidget.getValue("textbox"));
    ((JTextField) metawidget.getComponent(1)).setText("Textbox1");

    assertEquals("Limited Textbox:", ((JLabel) metawidget.getComponent(2)).getText());
    assertTrue(metawidget.getComponent(3) instanceof JTextField);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(3)).gridx);
    assertEquals("Limited Textbox", metawidget.getValue("limitedTextbox"));
    ((JTextField) metawidget.getComponent(3)).setText("Limited Textbox1");

    assertEquals("Textarea:", ((JLabel) metawidget.getComponent(4)).getText());
    assertTrue(metawidget.getComponent(5) instanceof JScrollPane);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(5)).gridx);
    assertEquals("Textarea", metawidget.getValue("textarea"));

    JTextArea textarea = (JTextArea) ((JScrollPane) metawidget.getComponent(5)).getViewport().getView();
    assertEquals(2, textarea.getRows());
    assertEquals(true, textarea.getLineWrap());
    assertEquals(true, textarea.getWrapStyleWord());
    textarea.setText("Textarea1");

    assertEquals("Password:", ((JLabel) metawidget.getComponent(6)).getText());
    assertTrue(metawidget.getComponent(7) instanceof JPasswordField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(7)).gridx);
    assertEquals("Password", metawidget.getValue("password"));
    ((JPasswordField) metawidget.getComponent(7)).setText("Password1");

    // Primitives

    assertEquals("Byte Primitive:", ((JLabel) metawidget.getComponent(8)).getText());
    assertTrue(metawidget.getComponent(9) instanceof JSpinner);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(9)).gridx);
    assertTrue(Byte.MAX_VALUE == (Byte) metawidget.getValue("bytePrimitive"));
    assertTrue(-5 == (Byte) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(9)).getModel())
            .getMinimum());
    assertTrue(
            Byte.MAX_VALUE == (Byte) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(9)).getModel())
                    .getMaximum());
    assertEquals(0, ((JSpinner.DefaultEditor) ((JSpinner) metawidget.getComponent(9)).getEditor())
            .getTextField().getColumns());
    JSpinner spinner = (JSpinner) metawidget.getComponent(9);
    spinner.setValue(spinner.getModel().getPreviousValue());

    assertEquals("Byte Object:", ((JLabel) metawidget.getComponent(10)).getText());
    assertTrue(metawidget.getComponent(11) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(11)).gridx);
    assertEquals(String.valueOf(Byte.MIN_VALUE), metawidget.getValue("byteObject"));
    ((JTextField) metawidget.getComponent(11)).setText(String.valueOf(Byte.MIN_VALUE + 1));

    assertEquals("Short Primitive:", ((JLabel) metawidget.getComponent(12)).getText());
    assertTrue(metawidget.getComponent(13) instanceof JSpinner);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(13)).gridx);
    assertTrue(Short.MAX_VALUE == (Short) metawidget.getValue("shortPrimitive"));
    assertTrue(-6 == (Short) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(13)).getModel())
            .getMinimum());
    assertTrue(Short.MAX_VALUE == (Short) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(13))
            .getModel()).getMaximum());
    spinner = (JSpinner) metawidget.getComponent(13);
    assertEquals(0, ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getColumns());
    spinner.setValue(spinner.getModel().getPreviousValue());

    assertEquals("Short Object:", ((JLabel) metawidget.getComponent(14)).getText());
    assertTrue(metawidget.getComponent(15) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(15)).gridx);
    assertEquals(String.valueOf(Short.MIN_VALUE), metawidget.getValue("shortObject"));
    ((JTextField) metawidget.getComponent(15)).setText(String.valueOf(Short.MIN_VALUE + 1));

    assertEquals("Int Primitive:", ((JLabel) metawidget.getComponent(16)).getText());
    assertTrue(metawidget.getComponent(17) instanceof JSpinner);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(17)).gridx);
    assertTrue(Integer.MAX_VALUE == (Integer) metawidget.getValue("intPrimitive"));
    assertTrue(Integer.MIN_VALUE == (Integer) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(17))
            .getModel()).getMinimum());
    assertTrue(Integer.MAX_VALUE == (Integer) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(17))
            .getModel()).getMaximum());
    spinner = (JSpinner) metawidget.getComponent(17);
    assertEquals(0, ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getColumns());
    spinner.setValue(spinner.getModel().getPreviousValue());

    assertEquals("Integer Object:", ((JLabel) metawidget.getComponent(18)).getText());
    assertTrue(metawidget.getComponent(19) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(19)).gridx);
    assertEquals(String.valueOf(Integer.MIN_VALUE), metawidget.getValue("integerObject"));
    ((JTextField) metawidget.getComponent(19)).setText(String.valueOf(Integer.MIN_VALUE + 1));

    assertEquals("Ranged Int:", ((JLabel) metawidget.getComponent(20)).getText());
    assertTrue(metawidget.getComponent(21) instanceof JSlider);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(21)).gridx);
    assertEquals(1, ((JSlider) metawidget.getComponent(21)).getMinimum());
    assertEquals(100, ((JSlider) metawidget.getComponent(21)).getMaximum());
    assertTrue(32 == (Integer) metawidget.getValue("rangedInt"));
    ((JSlider) metawidget.getComponent(21)).setValue(33);

    assertEquals("Ranged Integer:", ((JLabel) metawidget.getComponent(22)).getText());
    assertTrue(metawidget.getComponent(23) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(23)).gridx);
    assertEquals("33", metawidget.getValue("rangedInteger"));
    ((JTextField) metawidget.getComponent(23)).setText(String.valueOf(34));

    assertEquals("Long Primitive:", ((JLabel) metawidget.getComponent(24)).getText());
    assertTrue(metawidget.getComponent(25) instanceof JSpinner);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(25)).gridx);
    assertTrue(42 == (Long) metawidget.getValue("longPrimitive"));
    assertTrue(-7 == (Long) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(25)).getModel())
            .getMinimum());
    assertTrue(
            Long.MAX_VALUE == (Long) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(25)).getModel())
                    .getMaximum());
    spinner = (JSpinner) metawidget.getComponent(25);
    assertEquals(0, ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getColumns());
    spinner.setValue(spinner.getModel().getNextValue());

    assertTrue(metawidget.getComponent(26) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(26)).gridx);
    assertEquals("43", metawidget.getValue("longObject"));
    ((JTextField) metawidget.getComponent(26)).setText("44");

    assertEquals("Float Primitive:", ((JLabel) metawidget.getComponent(27)).getText());
    assertTrue(metawidget.getComponent(28) instanceof JSpinner);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(28)).gridx);
    assertEquals(4.2f, metawidget.getValue("floatPrimitive"));
    assertEquals(-Float.MAX_VALUE,
            ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(28)).getModel()).getMinimum());
    assertTrue(2048 == (Float) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(28)).getModel())
            .getMaximum());
    spinner = (JSpinner) metawidget.getComponent(28);
    assertEquals(0, ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getColumns());
    spinner.setValue(spinner.getModel().getNextValue());

    assertEquals("nullInBundle:", ((JLabel) metawidget.getComponent(29)).getText());
    assertTrue(metawidget.getComponent(30) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(30)).gridx);
    assertEquals("4.3", metawidget.getValue("floatObject"));
    ((JTextField) metawidget.getComponent(30)).setText("5.4");

    assertEquals("Double Primitive:", ((JLabel) metawidget.getComponent(31)).getText());
    assertTrue(metawidget.getComponent(32) instanceof JSpinner);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(32)).gridx);
    assertEquals(42.2d, metawidget.getValue("doublePrimitive"));
    assertTrue(-8 == (Double) ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(32)).getModel())
            .getMinimum());
    assertEquals(Double.MAX_VALUE,
            ((SpinnerNumberModel) ((JSpinner) metawidget.getComponent(32)).getModel()).getMaximum());
    spinner = (JSpinner) metawidget.getComponent(32);
    assertEquals(0, ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getColumns());
    spinner.setValue(spinner.getModel().getNextValue());

    assertTrue(metawidget.getComponent(33) instanceof JTextField);
    assertEquals(0, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(33)).gridx);
    assertEquals(2,
            ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(33)).gridwidth);
    assertEquals("43.3", metawidget.getValue("doubleObject"));
    ((JTextField) metawidget.getComponent(33)).setText("54.4");

    assertEquals("Char Primitive:", ((JLabel) metawidget.getComponent(34)).getText());
    assertTrue(metawidget.getComponent(35) instanceof JTextField);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(35)).gridx);
    assertEquals("A", metawidget.getValue("charPrimitive"));
    ((JTextField) metawidget.getComponent(35)).setText("Z");

    assertEquals("Character Object:", ((JLabel) metawidget.getComponent(36)).getText());
    assertTrue(metawidget.getComponent(37) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(37)).gridx);
    assertEquals("Z", metawidget.getValue("characterObject"));
    ((JTextField) metawidget.getComponent(37)).setText("A");

    assertEquals("Boolean Primitive:", ((JLabel) metawidget.getComponent(38)).getText());
    assertTrue(metawidget.getComponent(39) instanceof JCheckBox);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(39)).gridx);
    assertTrue(false == (Boolean) metawidget.getValue("booleanPrimitive"));
    ((JCheckBox) metawidget.getComponent(39)).setSelected(true);

    assertEquals("Boolean Object:", ((JLabel) metawidget.getComponent(40)).getText());
    assertTrue(metawidget.getComponent(41) instanceof JComboBox);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(37)).gridx);
    assertEquals(3, ((JComboBox) metawidget.getComponent(41)).getItemCount());
    assertEquals(Boolean.TRUE, metawidget.getValue("booleanObject"));
    ((JComboBox) metawidget.getComponent(41)).setSelectedItem(Boolean.FALSE);

    assertEquals("Dropdown:", ((JLabel) metawidget.getComponent(42)).getText());
    assertTrue(metawidget.getComponent(43) instanceof JComboBox);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(43)).gridx);
    assertEquals(4, ((JComboBox) metawidget.getComponent(43)).getItemCount());
    assertEquals("dropdown1", metawidget.getValue("dropdown"));
    ((JComboBox) metawidget.getComponent(43)).setSelectedItem("foo1");

    assertEquals("Dropdown With Labels:", ((JLabel) metawidget.getComponent(44)).getText());
    assertTrue(metawidget.getComponent(45) instanceof JComboBox);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(45)).gridx);

    JComboBox combo = (JComboBox) metawidget.getComponent(45);
    assertEquals(5, combo.getItemCount());
    assertEquals("Foo #2",
            ((JLabel) combo.getRenderer().getListCellRendererComponent(new JList(), "foo2", 1, false, false))
                    .getText());
    assertEquals("Dropdown #2", ((JLabel) combo.getRenderer().getListCellRendererComponent(new JList(),
            "dropdown2", 1, false, false)).getText());
    assertEquals("Bar #2",
            ((JLabel) combo.getRenderer().getListCellRendererComponent(new JList(), "bar2", 1, false, false))
                    .getText());
    assertEquals("Baz #2",
            ((JLabel) combo.getRenderer().getListCellRendererComponent(new JList(), "baz2", 1, false, false))
                    .getText());
    assertEquals("dropdown2", metawidget.getValue("dropdownWithLabels"));
    ((JComboBox) metawidget.getComponent(45)).setSelectedItem("bar2");

    assertEquals("Not Null Dropdown:", ((JLabel) metawidget.getComponent(46)).getText());
    assertTrue(metawidget.getComponent(47) instanceof JComboBox);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(47)).gridx);
    assertEquals(3, ((JComboBox) metawidget.getComponent(47)).getItemCount());
    assertTrue(0 == (Byte) metawidget.getValue("notNullDropdown"));
    ((JComboBox) metawidget.getComponent(47)).setSelectedItem((byte) 1);

    assertEquals("Not Null Object Dropdown*:", ((JLabel) metawidget.getComponent(48)).getText());
    assertTrue(metawidget.getComponent(49) instanceof JComboBox);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(49)).gridx);
    assertEquals(6, ((JComboBox) metawidget.getComponent(49)).getItemCount());
    assertEquals("dropdown3", metawidget.getValue("notNullObjectDropdown"));
    ((JComboBox) metawidget.getComponent(49)).setSelectedIndex(0);

    assertEquals("Nested Widgets:", ((JLabel) metawidget.getComponent(50)).getText());
    assertTrue(metawidget.getComponent(51) instanceof SwingMetawidget);

    SwingMetawidget metawidgetNested = (SwingMetawidget) metawidget.getComponent(51);

    assertEquals("Further Nested Widgets:", ((JLabel) metawidgetNested.getComponent(0)).getText());
    assertEquals(1, ((GridBagLayout) metawidgetNested.getLayout())
            .getConstraints(metawidgetNested.getComponent(1)).gridx);

    SwingMetawidget metawidgetFurtherNested = (SwingMetawidget) metawidgetNested.getComponent(1);
    assertEquals("Further Nested Widgets:", ((JLabel) metawidgetFurtherNested.getComponent(0)).getText());
    assertTrue(metawidgetFurtherNested.getComponent(1) instanceof SwingMetawidget);
    assertEquals(((SwingMetawidget) metawidgetFurtherNested.getComponent(1)).getComponentCount(), 0);

    assertEquals("Nested Textbox 1:", ((JLabel) metawidgetFurtherNested.getComponent(2)).getText());
    assertTrue(metawidgetFurtherNested.getComponent(3) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidgetFurtherNested.getLayout())
            .getConstraints(metawidgetFurtherNested.getComponent(3)).gridx);
    assertEquals("Nested Textbox 1",
            metawidget.getValue("nestedWidgets", "furtherNestedWidgets", "nestedTextbox1"));
    ((JTextField) metawidgetFurtherNested.getComponent(3)).setText("Nested Textbox 1.1 (further)");

    assertEquals("Nested Textbox 2:", ((JLabel) metawidgetFurtherNested.getComponent(4)).getText());
    assertTrue(metawidgetFurtherNested.getComponent(5) instanceof JTextField);

    // (should be 1, as in next row, if getEffectiveNumberOfColumns is working)

    assertEquals(1, ((GridBagLayout) metawidgetFurtherNested.getLayout())
            .getConstraints(metawidgetFurtherNested.getComponent(5)).gridx);
    assertEquals("Nested Textbox 2",
            metawidget.getValue("nestedWidgets", "furtherNestedWidgets", "nestedTextbox2"));
    ((JTextField) metawidgetFurtherNested.getComponent(5)).setText("Nested Textbox 2.2 (further)");

    assertEquals("Nested Textbox 1:", ((JLabel) metawidgetNested.getComponent(2)).getText());
    assertTrue(metawidgetNested.getComponent(3) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidgetNested.getLayout())
            .getConstraints(metawidgetNested.getComponent(3)).gridx);
    assertEquals("Nested Textbox 1", metawidget.getValue("nestedWidgets", "nestedTextbox1"));
    ((JTextField) metawidgetNested.getComponent(3)).setText("Nested Textbox 1.1");

    assertEquals("Nested Textbox 2:", ((JLabel) metawidgetNested.getComponent(4)).getText());
    assertTrue(metawidgetNested.getComponent(5) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidgetNested.getLayout())
            .getConstraints(metawidgetNested.getComponent(5)).gridx);
    assertEquals("Nested Textbox 2", metawidget.getValue("nestedWidgets", "nestedTextbox2"));
    ((JTextField) metawidgetNested.getComponent(5)).setText("Nested Textbox 2.2");

    assertEquals("Read Only Nested Widgets:", ((JLabel) metawidget.getComponent(52)).getText());
    assertTrue(metawidget.getComponent(53) instanceof SwingMetawidget);

    metawidgetNested = (SwingMetawidget) metawidget.getComponent(53);
    assertEquals("Nested Textbox 1:", ((JLabel) metawidgetNested.getComponent(2)).getText());
    assertTrue(metawidgetNested.getComponent(3) instanceof JLabel);
    assertEquals(1, ((GridBagLayout) metawidgetNested.getLayout())
            .getConstraints(metawidgetNested.getComponent(3)).gridx);
    assertEquals("Nested Textbox 1", metawidget.getValue("readOnlyNestedWidgets", "nestedTextbox1"));

    assertEquals("Nested Textbox 2:", ((JLabel) metawidgetNested.getComponent(4)).getText());
    assertTrue(metawidgetNested.getComponent(5) instanceof JLabel);
    assertEquals(1, ((GridBagLayout) metawidgetNested.getLayout())
            .getConstraints(metawidgetNested.getComponent(5)).gridx);
    assertEquals("Nested Textbox 2", metawidget.getValue("readOnlyNestedWidgets", "nestedTextbox2"));

    assertEquals("Nested Widgets Dont Expand:", ((JLabel) metawidget.getComponent(54)).getText());
    assertEquals("Nested Textbox 1, Nested Textbox 2", ((JTextField) metawidget.getComponent(55)).getText());
    ((JTextField) metawidget.getComponent(55)).setText("Nested Textbox 1.01, Nested Textbox 2.02");

    assertEquals("Read Only Nested Widgets Dont Expand:", ((JLabel) metawidget.getComponent(56)).getText());
    assertEquals("Nested Textbox 1, Nested Textbox 2", ((JLabel) metawidget.getComponent(57)).getText());

    assertEquals("Date:", ((JLabel) metawidget.getComponent(58)).getText());
    assertTrue(metawidget.getComponent(59) instanceof JTextField);
    assertEquals(1, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(59)).gridx);

    DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    assertEquals(dateFormat.format(allWidgets.getDate()), metawidget.getValue("date"));
    ((JTextField) metawidget.getComponent(59)).setText("bad date");

    JPanel separatorPanel = (JPanel) metawidget.getComponent(60);
    assertEquals("Section Break", ((JLabel) separatorPanel.getComponent(0)).getText());
    assertEquals(GridBagConstraints.REMAINDER,
            ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(60)).gridwidth);
    assertTrue(separatorPanel.getComponent(1) instanceof JSeparator);

    assertEquals("Read Only:", ((JLabel) metawidget.getComponent(61)).getText());
    assertTrue(metawidget.getComponent(62) instanceof JLabel);
    assertEquals("Read Only", metawidget.getValue("readOnly"));

    assertTrue(metawidget.getComponent(63) instanceof JButton);
    assertEquals(3, ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(63)).gridx);
    assertEquals(GridBagConstraints.NONE,
            ((GridBagLayout) metawidget.getLayout()).getConstraints(metawidget.getComponent(63)).fill);
    JButton button = ((JButton) metawidget.getComponent(63));
    assertEquals("Do Action", button.getText());
    assertTrue(button.isEnabled());
    try {
        button.doClick();
        fail();
    } catch (Exception e) {
        assertEquals("doAction called", e.getCause().getCause().getMessage());
    }

    assertEquals(64, metawidget.getComponentCount());

    // Check painting

    JFrame frame = new JFrame();
    metawidget.paint(frame.getGraphics());

    // Check MetawidgetException

    try {
        processor.getClass().getMethod("save", SwingMetawidget.class).invoke(processor, metawidget);
        fail();
    } catch (Exception e) {
        assertEquals("Could not parse 'bad date'", e.getCause().getCause().getMessage());
    }

    // Check saving

    String now = dateFormat.format(new GregorianCalendar().getTime());
    ((JTextField) metawidget.getComponent(59)).setText(now);
    processor.getClass().getMethod("save", SwingMetawidget.class).invoke(processor, metawidget);

    // Check read-only

    metawidget.setReadOnly(true);

    assertEquals("Textbox:", ((JLabel) metawidget.getComponent(0)).getText());
    assertEquals("Textbox1", ((JLabel) metawidget.getComponent(1)).getText());
    assertEquals("Limited Textbox:", ((JLabel) metawidget.getComponent(2)).getText());
    assertEquals("Limited Textbox1", ((JLabel) metawidget.getComponent(3)).getText());
    assertEquals("Textarea:", ((JLabel) metawidget.getComponent(4)).getText());
    assertEquals("Textarea1",
            ((JTextArea) ((JScrollPane) metawidget.getComponent(5)).getViewport().getView()).getText());
    assertEquals("Password:", ((JLabel) metawidget.getComponent(6)).getText());
    assertTrue(metawidget.getComponent(7) instanceof JPanel);
    assertEquals("Byte Primitive:", ((JLabel) metawidget.getComponent(8)).getText());
    assertEquals("126", ((JLabel) metawidget.getComponent(9)).getText());
    assertEquals("Byte Object:", ((JLabel) metawidget.getComponent(10)).getText());
    assertEquals("-127", ((JLabel) metawidget.getComponent(11)).getText());
    assertEquals("Short Primitive:", ((JLabel) metawidget.getComponent(12)).getText());
    assertEquals("32766", ((JLabel) metawidget.getComponent(13)).getText());
    assertEquals("Short Object:", ((JLabel) metawidget.getComponent(14)).getText());
    assertEquals("-32767", ((JLabel) metawidget.getComponent(15)).getText());
    assertEquals("Int Primitive:", ((JLabel) metawidget.getComponent(16)).getText());
    assertEquals("2147483646", ((JLabel) metawidget.getComponent(17)).getText());
    assertEquals("Integer Object:", ((JLabel) metawidget.getComponent(18)).getText());
    assertEquals("-2147483647", ((JLabel) metawidget.getComponent(19)).getText());
    assertEquals("Ranged Int:", ((JLabel) metawidget.getComponent(20)).getText());
    assertEquals("33", ((JLabel) metawidget.getComponent(21)).getText());
    assertEquals("Ranged Integer:", ((JLabel) metawidget.getComponent(22)).getText());
    assertEquals("34", ((JLabel) metawidget.getComponent(23)).getText());
    assertEquals("Long Primitive:", ((JLabel) metawidget.getComponent(24)).getText());
    assertEquals("43", ((JLabel) metawidget.getComponent(25)).getText());
    assertEquals("44", ((JLabel) metawidget.getComponent(26)).getText());
    assertEquals("Float Primitive:", ((JLabel) metawidget.getComponent(27)).getText());
    assertTrue(((JLabel) metawidget.getComponent(28)).getText().startsWith("4.3")
            || ((JLabel) metawidget.getComponent(28)).getText().startsWith("4.299"));
    assertEquals("nullInBundle:", ((JLabel) metawidget.getComponent(29)).getText());
    assertEquals("5.4", ((JLabel) metawidget.getComponent(30)).getText());
    assertEquals("Double Primitive:", ((JLabel) metawidget.getComponent(31)).getText());
    assertTrue(((JLabel) metawidget.getComponent(32)).getText().startsWith("42.3")
            || ((JLabel) metawidget.getComponent(32)).getText().startsWith("42.299"));
    assertEquals("54.4", ((JLabel) metawidget.getComponent(33)).getText());
    assertEquals("Char Primitive:", ((JLabel) metawidget.getComponent(34)).getText());
    assertEquals("Z", ((JLabel) metawidget.getComponent(35)).getText());
    assertEquals("Character Object:", ((JLabel) metawidget.getComponent(36)).getText());
    assertEquals("A", ((JLabel) metawidget.getComponent(37)).getText());
    assertEquals("Boolean Primitive:", ((JLabel) metawidget.getComponent(38)).getText());
    assertEquals("true", ((JLabel) metawidget.getComponent(39)).getText());
    assertEquals("Boolean Object:", ((JLabel) metawidget.getComponent(40)).getText());
    assertEquals("No", ((JLabel) metawidget.getComponent(41)).getText());
    assertEquals("Dropdown:", ((JLabel) metawidget.getComponent(42)).getText());
    assertEquals("foo1", ((JLabel) metawidget.getComponent(43)).getText());
    assertEquals("Dropdown With Labels:", ((JLabel) metawidget.getComponent(44)).getText());
    assertEquals("Bar #2", ((JLabel) metawidget.getComponent(45)).getText());
    assertEquals("Not Null Dropdown:", ((JLabel) metawidget.getComponent(46)).getText());
    assertEquals("1", ((JLabel) metawidget.getComponent(47)).getText());
    assertEquals("Not Null Object Dropdown:", ((JLabel) metawidget.getComponent(48)).getText());
    assertEquals("foo3", ((JLabel) metawidget.getComponent(49)).getText());
    assertEquals("Nested Widgets:", ((JLabel) metawidget.getComponent(50)).getText());
    assertEquals("Further Nested Widgets:",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(0)).getText());
    assertEquals("Further Nested Widgets:",
            ((JLabel) ((SwingMetawidget) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(1))
                    .getComponent(0)).getText());
    assertEquals("Nested Textbox 1:",
            ((JLabel) ((SwingMetawidget) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(1))
                    .getComponent(2)).getText());
    assertEquals("Nested Textbox 1.1 (further)",
            ((JLabel) ((SwingMetawidget) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(1))
                    .getComponent(3)).getText());
    assertEquals("Nested Textbox 2:",
            ((JLabel) ((SwingMetawidget) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(1))
                    .getComponent(4)).getText());
    assertEquals("Nested Textbox 2.2 (further)",
            ((JLabel) ((SwingMetawidget) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(1))
                    .getComponent(5)).getText());
    assertEquals("Nested Textbox 1:",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(2)).getText());
    assertEquals("Nested Textbox 1.1",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(3)).getText());
    assertEquals("Nested Textbox 2:",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(4)).getText());
    assertEquals("Nested Textbox 2.2",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(51)).getComponent(5)).getText());
    assertEquals("Read Only Nested Widgets:", ((JLabel) metawidget.getComponent(52)).getText());
    assertEquals("Further Nested Widgets:",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(53)).getComponent(0)).getText());
    assertEquals("Nested Textbox 1:",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(53)).getComponent(2)).getText());
    assertEquals("Nested Textbox 1",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(53)).getComponent(3)).getText());
    assertEquals("Nested Textbox 2:",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(53)).getComponent(4)).getText());
    assertEquals("Nested Textbox 2",
            ((JLabel) ((SwingMetawidget) metawidget.getComponent(53)).getComponent(5)).getText());
    assertEquals("Nested Widgets Dont Expand:", ((JLabel) metawidget.getComponent(54)).getText());
    assertEquals("Nested Textbox 1.01, Nested Textbox 2.02", ((JLabel) metawidget.getComponent(55)).getText());
    assertEquals("Read Only Nested Widgets Dont Expand:", ((JLabel) metawidget.getComponent(56)).getText());
    assertEquals("Nested Textbox 1, Nested Textbox 2", ((JLabel) metawidget.getComponent(57)).getText());
    assertEquals("Date:", ((JLabel) metawidget.getComponent(58)).getText());
    assertEquals(now, ((JLabel) metawidget.getComponent(59)).getText());
    assertEquals("Section Break", ((JLabel) ((JPanel) metawidget.getComponent(60)).getComponent(0)).getText());
    assertEquals("Read Only:", ((JLabel) metawidget.getComponent(61)).getText());
    assertEquals("Read Only", ((JLabel) metawidget.getComponent(62)).getText());
    assertEquals("Do Action", ((JButton) metawidget.getComponent(63)).getText());
    assertTrue(!((JButton) metawidget.getComponent(63)).isEnabled());

    assertEquals(metawidget.getComponentCount(), 64);

    // Test Binding.onStartBuild clears the state

    assertTrue(null != metawidget.getClientProperty(processor.getClass()));
    processor.onStartBuild(metawidget);
    assertEquals(null, metawidget.getClientProperty(processor.getClass()));
}

From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java

public JComponent getComponent(String key) {
    JPanel valuePanel = keyValueComponentMap.get(key);
    if (valuePanel.getComponentCount() > 0) {
        return (JComponent) valuePanel.getComponent(0);
    }//from  w w  w .j a va  2  s.c  o m
    return null;
}

From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java

public JComponent getAdditionalColumn(String key, int index) {
    JPanel p = keyExtraComponentsMap.get(key)[index];
    if (p.getComponentCount() > 0) {
        return (JComponent) p.getComponent(0);
    }/*  ww  w .  ja va2s  . c  o  m*/
    return null;
}

From source file:org.ut.biolab.medsavant.client.view.Menu.java

public void addSection(SectionView section) {

    final JPanel sectionPanel = ViewUtil.getClearPanel();
    sectionPanel.setLayout(new BoxLayout(sectionPanel, BoxLayout.Y_AXIS));
    sectionPanel.setVisible(false);/*ww  w . ja v  a 2 s  . c  o m*/

    //HoverButton sectionButton = new SectionButton(section, sectionPanel);
    //sectionButton.setSelectedColor(ViewUtil.getSecondaryMenuColor());

    final JToggleButton sectionButton = ViewUtil.getTogglableIconButton(section.getIcon());
    sectionButton.setName(section.getName());
    sectionButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    sectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            primaryMenuButtons.setSelected(sectionButton.getModel(), true);
            if (previousSectionPanel != null) {
                previousSectionPanel.setVisible(false);
            }
            // Act as if we clicked the first sub-section button.
            ((SubSectionButton) sectionPanel.getComponent(0)).subSectionClicked();
            sectionPanel.setVisible(true);

            previousSectionPanel = sectionPanel;
            primaryMenu.invalidate();
        }
    });

    ButtonGroup subSectionsGroup = new ButtonGroup();

    for (SubSectionView v : section.getSubSections()) {
        subSectionViews.add(v);

        SubSectionButton subSectionButton = new SubSectionButton(v, subSectionsGroup);
        sectionPanel.add(subSectionButton);
        subSectionsGroup.add(subSectionButton);

        map.put(v, subSectionButton);
    }

    primaryMenuButtons.add(sectionButton);

    sectionPanel.add(Box.createVerticalStrut(50));

    secondaryMenu.add(sectionPanel);

    primaryMenuSectionButtonContainer.add(ViewUtil.subTextComponent(sectionButton, section.getName()));
    primaryMenuSectionButtonContainer.add(ViewUtil.getLargeSeparator());

}

From source file:rita.ui.component.DialogSelectEnemies.java

private void enablePositionOptions(boolean enable) {
    if (!enable) {
        canSelectPosition = false;//ww  w  . ja  va2s .  co m
        for (Component comp : positionComponents) {
            comp.setEnabled(false);
        }
    } else {
        canSelectPosition = true;
        buttonPos.setEnabled(true);
        for (Component compPanel : panelSelectRobots.getComponents()) {
            JPanel parent = (JPanel) compPanel;
            // para cada panel la primer componente es el check y el segundo
            // es el boton
            JCheckBox check = (JCheckBox) parent.getComponent(0);
            if (check.isSelected()) {
                JButton button = (JButton) parent.getComponent(1);
                button.setEnabled(true);
            }
        }
    }
}

From source file:savant.snp.SNPFinderPlugin.java

/**
 * Retrieve canvases./*from w w  w .j a va  2  s .c  o  m*/
 *
 * @return
 */
private List<PileupPanel> getPileupPanels() {
    List<PileupPanel> panels = new ArrayList<PileupPanel>();
    if (viewTrackToCanvasMap != null) {
        for (JPanel p : this.viewTrackToCanvasMap.values()) {
            try {
                panels.add((PileupPanel) p.getComponent(0));
            } catch (ArrayIndexOutOfBoundsException e) {
            }
        }
    }
    return panels;
}