private ExampleList createSimpleComponentExamples() { ExampleList exampleList = new ExampleList("Simple Components"); exampleList.addExample("JLabel", new PSwing(new JLabel("JLabel Example"))); exampleList.addExample("JCheckBox ", new PSwing(new JCheckBox())); JRadioButton radio1 = new JRadioButton("Radio Option 1"); JRadioButton radio2 = new JRadioButton("Radio Option 1"); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(radio1); buttonGroup.add(radio2); exampleList.addExample("RadioButton 1", radio1); exampleList.addExample("RadioButton 2", radio2); JPanel examplePanel = new JPanel() { protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.RED); g.fillRect(0, 0, getWidth(), getHeight()); } }; examplePanel.setPreferredSize(new Dimension(50, 50)); exampleList.addExample("Custom JPanel ", examplePanel); return exampleList; }
private void addButtonOnPanelNoSizing(ExampleList exampleList) { JButton button = new JButton("Button"); JPanel panel = new JPanel(); panel.add(button); PSwing pPanel = new PSwing(panel); exampleList.addExample("On JPanel - No Sizing", pPanel); }
private void addButtonOnPanel200x50(ExampleList exampleList) { JButton button = new JButton("Button"); button.setPreferredSize(new Dimension(200, 50)); JPanel panel = new JPanel(); panel.add(button); PSwing pPanel = new PSwing(panel); exampleList.addExample("On JPanel - 200x50", pPanel); }
public void testDifferentListAnnotations() throws Exception { Persister persister = new Persister(); List<String> list = new ArrayList<String>(); ExampleList example = new ExampleList(list, "a"); list.add("1"); list.add("2"); list.add("3"); list.add("4"); StringWriter writer = new StringWriter(); persister.write(example, writer); String text = writer.toString(); ExampleList deserialized = persister.read(ExampleList.class, text); assertEquals(deserialized.getList().size(), 4); assertTrue(deserialized.getList().contains("1")); assertTrue(deserialized.getList().contains("2")); assertTrue(deserialized.getList().contains("3")); assertTrue(deserialized.getList().contains("4")); assertEquals(deserialized.getName(), "a"); validate(persister, deserialized); }
private void addButtonAlone10x10(ExampleList exampleList) { JButton button = new JButton("Button"); button.setPreferredSize(new Dimension(10, 10)); PSwing pButton = new PSwing(button); exampleList.addExample("Alone - 10x10", pButton); }
private void addButtonAlone200x50(ExampleList exampleList) { JButton button = new JButton("Button"); button.setPreferredSize(new Dimension(200, 50)); PSwing pButton = new PSwing(button); exampleList.addExample("Alone - 200x50", pButton); }
private void addButtonAloneNoSizing(ExampleList exampleList) { JButton button = new JButton("Button"); PSwing pButton = new PSwing(button); exampleList.addExample("Alone - No Sizing", pButton); }