2 import java.awt.BorderLayout;
3 import java.awt.ComponentOrientation;
4 import java.awt.Container;
5 import java.awt.Dimension;
7 import java.awt.GridLayout;
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 @SuppressWarnings("serial")
22 public class JalviewJSTest extends JPanel
24 public static void main(String[] args)
26 new JalviewJSTest().doTest();
30 * Put some content in a JFrame and show it
34 JFrame main = new JFrame();
35 main.setContentPane(getVisualPaneContent());
37 main.setVisible(true);
41 * Builds a cut-down 'Preferences Visual tab' for a minimal test of layout
44 Container getVisualPaneContent()
46 JPanel panel = new JPanel();
47 panel.setPreferredSize(new Dimension(400, 500));
48 panel.setOpaque(true);
49 panel.setLayout(new BorderLayout());
51 JPanel firstColumn = new JPanel();
52 firstColumn.setLayout(new GridLayout(10, 1));
53 firstColumn.setBorder(new TitledBorder("column 1"));
57 * - checkbox label and text extend outside the enclosing panel in JS
59 JCheckBox cb1 = new JCheckBox();
60 Font font = new Font("Verdana", Font.PLAIN, 11);
62 cb1.setText("Maximise Window");
63 cb1.setHorizontalTextPosition(SwingConstants.LEADING);
64 cb1.setHorizontalAlignment(SwingConstants.LEFT);
68 * - label should precede checkbox, but it doesn't
70 JCheckBox cb2 = new JCheckBox("Open Overview");
72 cb2.setHorizontalTextPosition(SwingConstants.LEADING);
73 // uncommenting this line gives 'leading text', but
74 // also results in label and checkbox outside container
75 //cb2.setHorizontalAlignment(SwingConstants.RIGHT);
78 // ImageIcon icon = new ImageIcon(getClass()
80 // .getResource("test2.png"), "test");
82 JCheckBox cb3 = new JCheckBox("leading,left-to-right");
84 cb3.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
85 cb3.setHorizontalTextPosition(SwingConstants.LEADING);
87 JCheckBox cb4 = new JCheckBox("leading,right-to-left");
89 cb4.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
90 cb4.setHorizontalTextPosition(SwingConstants.LEADING);
92 JCheckBox cb5 = new JCheckBox("trailing,left-to-right");
94 cb5.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
95 cb5.setHorizontalTextPosition(SwingConstants.TRAILING);
97 JCheckBox cb6 = new JCheckBox("trailing,right-to-left");
99 cb6.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
100 cb6.setHorizontalTextPosition(SwingConstants.TRAILING);
102 JRadioButton rb1 = new JRadioButton("trailing,right-to-left");
104 rb1.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
105 rb1.setHorizontalTextPosition(SwingConstants.TRAILING);
107 JRadioButton rb2 = new JRadioButton("right,left-to-right");
109 rb2.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
110 rb2.setHorizontalTextPosition(SwingConstants.RIGHT);
112 JRadioButton rb3 = new JRadioButton("right,right-to-left");
114 rb3.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
115 rb3.setHorizontalTextPosition(SwingConstants.RIGHT);
119 firstColumn.add(cb1);
120 firstColumn.add(cb2);
121 firstColumn.add(cb3);
122 firstColumn.add(cb4);
123 firstColumn.add(cb5);
124 firstColumn.add(cb6);
125 firstColumn.add(rb1);
126 firstColumn.add(rb2);
127 firstColumn.add(rb3);
128 firstColumn.setBounds(20, 20, 200, 500);
130 JPanel theTab = new JPanel();
131 theTab.setLayout(null);
132 theTab.add(firstColumn);