File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
sources/net.sf.j2s.java.core/src Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 22
33
44import java .awt .Dimension ;
5+ import java .beans .PropertyChangeEvent ;
56
67import javax .swing .JComponent ;
78import javax .swing .JMenuItem ;
@@ -48,4 +49,17 @@ public void installUI(JComponent jc) {
4849 "MenuItem.font" );
4950 }
5051
52+ @ Override
53+ public void propertyChange (PropertyChangeEvent e ) {
54+ super .propertyChange (e );
55+ String prop = e .getPropertyName ();
56+ if (jc .isVisible ()) {
57+ if (prop == "ancestor" ) {
58+ if (jc .getParent () != null ) {
59+ ((JSComponentUI ) jc .getParent ().getUI ()).setHTMLElement ();
60+ }
61+ }
62+ }
63+ }
64+
5165}
Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ public static void main(String[] args)
4040 new JalviewJSTest ().doTest ();
4141 }
4242
43+ private JMenuItem mb5 ;
44+
4345 /**
4446 * Put some content in a JFrame and show it
4547 */
@@ -187,6 +189,11 @@ Container getVisualPaneContent(JMenu menu)
187189 mb4 .setComponentOrientation (ComponentOrientation .RIGHT_TO_LEFT );
188190 mb4 .setHorizontalTextPosition (SwingConstants .RIGHT );
189191
192+ mb5 = new JMenuItem ("added" );
193+ mb5 .setFont (font );
194+ mb5 .setComponentOrientation (ComponentOrientation .RIGHT_TO_LEFT );
195+ mb5 .setHorizontalTextPosition (SwingConstants .RIGHT );
196+
190197
191198 JMenu m1 = new JMenu ("left" );
192199 JMenu m2 = new JMenu ("right" );
@@ -227,8 +234,9 @@ private ImageIcon getImage(String name) {
227234@ Override
228235public void menuSelected (MenuEvent e ) {
229236 System .out .println ("menuSelected " + e .getSource ().toString ());
230-
231- }
237+ JMenu menu = (JMenu ) e .getSource ();
238+ menu .add (mb5 );
239+ }
232240
233241@ Override
234242public void menuDeselected (MenuEvent e ) {
You can’t perform that action at this time.
0 commit comments