Skip to content

Commit 63a724d

Browse files
committed
Menu item visibility fixes; working on PDF printing
1 parent 9f95e6a commit 63a724d

3 files changed

Lines changed: 20 additions & 46 deletions

File tree

sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ public void updateUI() {
202202
public boolean isBackgroundPainted;
203203

204204

205+
protected JSGraphics2D getJSGraphic2D(Graphics g) {
206+
/**
207+
* @j2sNative
208+
*
209+
* return (g.mark ? g : null);
210+
*/
211+
{
212+
return null;
213+
}
214+
}
215+
205216
/**
206217
* This method is added to ensure that if a jpanel or other object's background
207218
* is painted to, that it becomes transparent -- since the actual painting is

sources/net.sf.j2s.java.core/src/javax/swing/JComponent.java

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ protected void paintComponent(Graphics g) {
626626
isBackgroundPainted = false;
627627
ui.update(scratchGraphics, this);
628628
// BH TODO CHECK THIS
629-
isBackgroundPainted = ((JSGraphics2D) (Object)scratchGraphics).isBackgroundPainted();
629+
JSGraphics2D jsg = getJSGraphic2D(scratchGraphics);
630+
isBackgroundPainted = (jsg != null && jsg.isBackgroundPainted());
630631
} finally {
631632
scratchGraphics.dispose();
632633
}
@@ -725,7 +726,7 @@ protected void paintChildren(Graphics g) {
725726
// if (!printing) {
726727
jc.checkBackgroundPainted(null);
727728
jc.paint((Graphics) (Object) jsg);
728-
jc.checkBackgroundPainted(jsg);
729+
jc.checkBackgroundPainted(getJSGraphic2D((Graphics) (Object) jsg));
729730
// } else {
730731
// if (!getFlag(IS_PRINTING_ALL)) {
731732
// comp.print(cg);
@@ -4575,7 +4576,7 @@ void _paintImmediately(int x, int y, int w, int h) {
45754576
// (so that the underlying JRootPane canvas can show).
45764577
checkBackgroundPainted(null);
45774578
paintingComponent.paint(g);
4578-
checkBackgroundPainted((JSGraphics2D) (Object) g);
4579+
checkBackgroundPainted(getJSGraphic2D(g));
45794580
}
45804581
} finally {
45814582
g.dispose();
@@ -4813,16 +4814,7 @@ public void dndDone() {
48134814
*/
48144815
@SuppressWarnings("unused")
48154816
private void paintComponentSafely(Graphics g) {
4816-
JSGraphics2D jsg = null;
4817-
4818-
/**
4819-
* @j2sNative
4820-
*
4821-
* jsg = (g.mark ? g : null);
4822-
*/
4823-
{
4824-
}
4825-
4817+
JSGraphics2D jsg = getJSGraphic2D(g);
48264818
int nSave = (jsg == null ? 0 : jsg.mark());
48274819
checkBackgroundPainted(null);
48284820
// note that paintComponent may be overridden.
@@ -4846,19 +4838,8 @@ private void paintComponentSafely(Graphics g) {
48464838
*
48474839
* @param g
48484840
*/
4849-
@SuppressWarnings("unused")
48504841
private void printComponentSafely(Graphics g) {
4851-
4852-
JSGraphics2D jsg = null;
4853-
4854-
/**
4855-
* @j2sNative
4856-
*
4857-
* jsg = (g.mark ? g : null);
4858-
*/
4859-
{
4860-
}
4861-
4842+
JSGraphics2D jsg = getJSGraphic2D(g);
48624843
int nSave = (jsg == null ? 0 : jsg.mark());
48634844
printComponent(g);
48644845
if (jsg != null)
@@ -4877,18 +4858,8 @@ private void printComponentSafely(Graphics g) {
48774858
*
48784859
* @param g
48794860
*/
4880-
@SuppressWarnings("unused")
48814861
private void paintBorderSafely(Graphics g) {
4882-
JSGraphics2D jsg = null;
4883-
4884-
/**
4885-
* @j2sNative
4886-
*
4887-
* jsg = (g.mark ? g : null);
4888-
*/
4889-
{
4890-
}
4891-
4862+
JSGraphics2D jsg = getJSGraphic2D(g);
48924863
int nSave = (jsg == null ? 0 : jsg.mark());
48934864
printBorder(g);
48944865
if (jsg != null)
@@ -4907,17 +4878,8 @@ private void paintBorderSafely(Graphics g) {
49074878
*
49084879
* @param g
49094880
*/
4910-
@SuppressWarnings("unused")
49114881
private void printBorderSafely(Graphics g) {
4912-
JSGraphics2D jsg = null;
4913-
/**
4914-
* @j2sNative
4915-
*
4916-
* jsg = (g.mark ? g : null);
4917-
*/
4918-
{
4919-
}
4920-
4882+
JSGraphics2D jsg = getJSGraphic2D(g);
49214883
int nSave = (jsg == null ? 0 : jsg.mark());
49224884
printBorder(g);
49234885
if (jsg != null)

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuItemUI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ protected DOMNode updateDOMNode() {
2323
domNode = createItem("_item", null);
2424
}
2525
// add code here for adjustments when changes in bounds or other properties occur.
26+
DOMNode.setStyles(domNode, "display", jc.isVisible() ? "block" : "none");
2627
return domNode;
2728
}
2829

0 commit comments

Comments
 (0)