Skip to content

Commit ed91e5f

Browse files
hansonrhansonr
authored andcommitted
JTabbedPane tab look and feel not so tall
JScrollPane peer null issue. Not sure why this is not going through JComponent before -- issue with AWT?
1 parent 9f7ae09 commit ed91e5f

File tree

10 files changed

+39
-15
lines changed

10 files changed

+39
-15
lines changed
36.7 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190923090813
1+
20190924101854
36.7 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190923090813
1+
20190924101854
36.7 KB
Binary file not shown.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,9 +1495,10 @@ public void setWheelScrollingEnabled(boolean handleWheel) {
14951495

14961496
@Override
14971497
public Insets getInsets() {
1498-
ComponentPeer peer = this.peer;
1499-
Insets i = ((ContainerPeer)peer).getInsets();
1500-
return (i == null ? NULL_INSETS : i);
1498+
return super.getInsets();
1499+
// ComponentPeer peer = this.peer;
1500+
// Insets i = ((ContainerPeer)peer).getInsets();
1501+
// return (i == null ? NULL_INSETS : i);
15011502
}
15021503

15031504
}

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

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ public void setUI(TabbedPaneUI ui) {
282282
* the tabbedpane (instead of the model itself) as the event source.
283283
*/
284284
protected class ModelListener implements ChangeListener, Serializable {
285-
public void stateChanged(ChangeEvent e) {
285+
@Override
286+
public void stateChanged(ChangeEvent e) {
286287
fireStateChanged();
287288
}
288289
}
@@ -826,7 +827,8 @@ public void addTab(String title, Component component) {
826827
* @see #insertTab
827828
* @see #removeTabAt
828829
*/
829-
public Component add(Component component) {
830+
@Override
831+
public Component add(Component component) {
830832
if (!(component instanceof UIResource)) {
831833
addTab(component.getName(), component);
832834
} else {
@@ -846,7 +848,8 @@ public Component add(Component component) {
846848
* @see #insertTab
847849
* @see #removeTabAt
848850
*/
849-
public Component add(String title, Component component) {
851+
@Override
852+
public Component add(String title, Component component) {
850853
if (!(component instanceof UIResource)) {
851854
addTab(title, component);
852855
} else {
@@ -867,7 +870,8 @@ public Component add(String title, Component component) {
867870
* @see #insertTab
868871
* @see #removeTabAt
869872
*/
870-
public Component add(Component component, int index) {
873+
@Override
874+
public Component add(Component component, int index) {
871875
if (!(component instanceof UIResource)) {
872876
// Container.add() interprets -1 as "append", so convert
873877
// the index appropriately to be handled by the vector
@@ -892,7 +896,8 @@ public Component add(Component component, int index) {
892896
* @see #insertTab
893897
* @see #removeTabAt
894898
*/
895-
public void add(Component component, Object constraints) {
899+
@Override
900+
public void add(Component component, Object constraints) {
896901
if (!(component instanceof UIResource)) {
897902
if (constraints instanceof String) {
898903
addTab((String)constraints, component);
@@ -920,7 +925,8 @@ public void add(Component component, Object constraints) {
920925
* @see #insertTab
921926
* @see #removeTabAt
922927
*/
923-
public Component add(Component component, Object constraints, int index) {
928+
@Override
929+
public Component add(Component component, Object constraints, int index) {
924930
if (!(component instanceof UIResource)) {
925931

926932
Icon icon = constraints instanceof Icon? (Icon)constraints : null;
@@ -1853,7 +1859,8 @@ private void checkIndex(int index) {
18531859
*
18541860
* @return a string representation of this JTabbedPane.
18551861
*/
1856-
protected String paramString() {
1862+
@Override
1863+
protected String paramString() {
18571864
String tabPlacementString;
18581865
if (tabPlacement == TOP) {
18591866
tabPlacementString = "TOP";
@@ -2440,4 +2447,16 @@ public int indexOfTabComponent(Component tabComponent) {
24402447
}
24412448
return -1;
24422449
}
2450+
2451+
/**
2452+
* SwingJS added - needs this??
2453+
*
2454+
*/
2455+
@Override
2456+
public void addNotify() {
2457+
for(int i = 0; i < getTabCount(); i++) {
2458+
Component c = getTabComponentAt(i);
2459+
c.addNotify();
2460+
}
2461+
}
24432462
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ public Object createValue(UIDefaults table) {
821821
//
822822
// ** TabbedBane value objects
823823

824-
Object tabbedPaneTabInsets = new InsetsUIResource(4, 4, 8, 4);
824+
Object tabbedPaneTabInsets = new InsetsUIResource(2, 4, 2, 4);
825825

826826
Object tabbedPaneTabPadInsets = new InsetsUIResource(2, 2, 2, 1);// selected tab size
827827

sources/net.sf.j2s.java.core/src/test/TApp2_Swing.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.awt.Graphics2D;
1111
import java.awt.GridLayout;
1212
import java.awt.Image;
13+
import java.awt.Insets;
1314
import java.awt.Label;
1415
import java.awt.event.ActionEvent;
1516
import java.awt.event.ActionListener;
@@ -150,6 +151,8 @@ public void focusLost(FocusEvent e) {
150151
+ "A text\nwith some\nlines and\n no content.") {
151152
};
152153
JScrollPane jsp = new JScrollPane(ta);
154+
Insets insets = jsp.getInsets();
155+
System.out.println("jsp offsets " + insets + jsp.getPeer());
153156
add(jsp);
154157
jsp.setBounds(200, 70, 200, 200);
155158
ta.setWrapStyleWord(true);

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13773,6 +13773,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1377313773

1377413774
// TODO: still a lot of references to window[...]
1377513775

13776+
// BH 2019.09.24 missing isArray$() in Integer.class
1377613777
// BH 2019.09.26 superfast byte[] -> String using TextDecoder
1377713778
// BH 2019.08.16 adds cache for instanceof
1377813779
// BH 2019.07.27 fixes array(intArray).clone
@@ -17192,7 +17193,8 @@ var setJ2STypeclass = function(cl, type, paramCode) {
1719217193
// TODO -- should be a proper Java.lang.Class
1719317194
primTypes[paramCode] = cl;
1719417195
cl.TYPE = {
17195-
isPrimitive: function() { return true },
17196+
isArray$: function() { return false },
17197+
isPrimitive$: function() { return true },
1719617198
type:type,
1719717199
__PARAMCODE:paramCode,
1719817200
__PRIMITIVE:1 // referenced in java.lang.Class
@@ -19467,7 +19469,6 @@ if (!Clazz._loadcore || J2S._coreFiles.length == 0) {
1946719469

1946819470
})(Clazz, J2S);
1946919471
}; // called by external application
19470-
1947119472
// SwingJSApplet.js
1947219473

1947319474
// BH 8/1/2018 $-qualified Java methods

0 commit comments

Comments
 (0)