1 import java.awt.BorderLayout;
2 import java.awt.Container;
3 import java.awt.Dimension;
5 import java.awt.GridLayout;
7 import javax.swing.JCheckBox;
8 import javax.swing.JFrame;
9 import javax.swing.JPanel;
10 import javax.swing.SwingConstants;
11 import javax.swing.border.TitledBorder;
14 * A class with a main method entry point for ad hoc tests of JalviewJS
15 * behaviour. The J2S transpiler should generate an html entry point for this
16 * class, allowing comparison between Java and Javascript execution.
18 public class JalviewJSTest extends JPanel
20 public static void main(String[] args)
22 new JalviewJSTest().doTest();
26 * Put some content in a JFrame and show it
30 JFrame main = new JFrame();
31 main.setContentPane(getVisualPaneContent());
33 main.setVisible(true);
37 * Builds a cut-down 'Preferences Visual tab' for a minimal test of layout
40 Container getVisualPaneContent()
42 JPanel panel = new JPanel();
43 panel.setPreferredSize(new Dimension(400, 300));
44 panel.setOpaque(true);
45 panel.setLayout(new BorderLayout());
47 JPanel firstColumn = new JPanel();
48 firstColumn.setLayout(new GridLayout(6, 1));
49 firstColumn.setBorder(new TitledBorder("column 1"));
53 * - checkbox label and text extend outside the enclosing panel in JS
55 JCheckBox cb1 = new JCheckBox();
56 Font font = new Font("Verdana", Font.PLAIN, 11);
58 cb1.setText("Maximise Window");
59 cb1.setHorizontalTextPosition(SwingConstants.LEADING);
60 cb1.setHorizontalAlignment(SwingConstants.RIGHT);
64 * - label should precede checkbox, but it doesn't
66 JCheckBox cb2 = new JCheckBox("Open Overview");
68 cb2.setHorizontalTextPosition(SwingConstants.LEADING);
69 // uncommenting this line gives 'leading text', but
70 // also results in label and checkbox outside container
71 //cb2.setHorizontalAlignment(SwingConstants.RIGHT);
75 firstColumn.setBounds(20, 20, 200, 200);
77 JPanel theTab = new JPanel();
78 theTab.setLayout(null);
79 theTab.add(firstColumn);