1 import java.awt.BorderLayout;
2 import java.awt.ComponentOrientation;
3 import java.awt.Container;
4 import java.awt.Dimension;
6 import java.awt.GridLayout;
8 import javax.swing.ImageIcon;
9 import javax.swing.JCheckBox;
10 import javax.swing.JFrame;
11 import javax.swing.JPanel;
12 import javax.swing.JRadioButton;
13 import javax.swing.SwingConstants;
14 import javax.swing.border.TitledBorder;
17 * A class with a main method entry point for ad hoc tests of JalviewJS
18 * behaviour. The J2S transpiler should generate an html entry point for this
19 * class, allowing comparison between Java and Javascript execution.
21 public class JalviewJSTest extends JPanel
23 public static void main(String[] args)
25 new JalviewJSTest().doTest();
29 * Put some content in a JFrame and show it
33 JFrame main = new JFrame();
34 main.setContentPane(getVisualPaneContent());
36 main.setVisible(true);
40 * Builds a cut-down 'Preferences Visual tab' for a minimal test of layout
43 Container getVisualPaneContent()
45 JPanel panel = new JPanel();
46 panel.setPreferredSize(new Dimension(400, 500));
47 panel.setOpaque(true);
48 panel.setLayout(new BorderLayout());
50 JPanel firstColumn = new JPanel();
51 firstColumn.setLayout(new GridLayout(10, 1));
52 firstColumn.setBorder(new TitledBorder("column 1"));
56 * - checkbox label and text extend outside the enclosing panel in JS
58 JCheckBox cb1 = new JCheckBox();
59 Font font = new Font("Verdana", Font.PLAIN, 11);
61 cb1.setText("Maximise Window");
62 cb1.setHorizontalTextPosition(SwingConstants.LEADING);
63 cb1.setHorizontalAlignment(SwingConstants.LEFT);
67 * - label should precede checkbox, but it doesn't
69 JCheckBox cb2 = new JCheckBox("Open Overview");
71 cb2.setHorizontalTextPosition(SwingConstants.LEADING);
72 // uncommenting this line gives 'leading text', but
73 // also results in label and checkbox outside container
74 //cb2.setHorizontalAlignment(SwingConstants.RIGHT);
77 // ImageIcon icon = new ImageIcon(getClass()
79 // .getResource("test2.png"), "test");
81 JCheckBox cb3 = new JCheckBox("leading,left-to-right");
83 cb3.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
84 cb3.setHorizontalTextPosition(SwingConstants.LEADING);
86 JCheckBox cb4 = new JCheckBox("leading,right-to-left");
88 cb4.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
89 cb4.setHorizontalTextPosition(SwingConstants.LEADING);
91 JCheckBox cb5 = new JCheckBox("trailing,left-to-right");
93 cb5.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
94 cb5.setHorizontalTextPosition(SwingConstants.TRAILING);
96 JCheckBox cb6 = new JCheckBox("trailing,right-to-left");
98 cb6.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
99 cb6.setHorizontalTextPosition(SwingConstants.TRAILING);
101 JRadioButton rb1 = new JRadioButton("trailing,right-to-left");
103 rb1.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
104 rb1.setHorizontalTextPosition(SwingConstants.TRAILING);
106 JRadioButton rb2 = new JRadioButton("right,left-to-right");
108 rb2.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
109 rb2.setHorizontalTextPosition(SwingConstants.RIGHT);
111 JRadioButton rb3 = new JRadioButton("right,right-to-left");
113 rb3.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
114 rb3.setHorizontalTextPosition(SwingConstants.RIGHT);
118 firstColumn.add(cb1);
119 firstColumn.add(cb2);
120 firstColumn.add(cb3);
121 firstColumn.add(cb4);
122 firstColumn.add(cb5);
123 firstColumn.add(cb6);
124 firstColumn.add(rb1);
125 firstColumn.add(rb2);
126 firstColumn.add(rb3);
127 firstColumn.setBounds(20, 20, 200, 500);
129 JPanel theTab = new JPanel();
130 theTab.setLayout(null);
131 theTab.add(firstColumn);