Skip to content

Commit 3e7b5c0

Browse files
hansonrhansonr
authored andcommitted
java.awt.List/javax.swing.JList implemented
JSTableUI refactoring
1 parent 3d820fa commit 3e7b5c0

File tree

13 files changed

+1146
-419
lines changed

13 files changed

+1146
-419
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,9 @@ public void update(Graphics g) { }
106106
* renderer components (CellRendererPane doesn't paint anyway).<
107107
*/
108108
@Override
109-
protected Component addImpl(Component x, Object constraints, int index) {
110-
if (x.getParent() == this) {
111-
return null;
112-
}
113-
else {
114-
return addImplCont(x, constraints, index);
115-
}
109+
protected void addImpl(Component x, Object constraints, int index) {
110+
if (x.getParent() != this)
111+
addImplCont(x, constraints, index);
116112
}
117113

118114

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import javax.swing.table.TableCellRenderer;
4141
import javax.swing.tree.TreeCellEditor;
4242

43+
import swingjs.plaf.CellHolder;
4344
import swingjs.plaf.JSComponentUI;
4445

4546
/**
@@ -105,11 +106,6 @@ public Object getCellEditorValue() {
105106
textField.addActionListener(delegate);
106107
}
107108

108-
private void setComponent(JComponent comp) {
109-
editorComponent = comp;
110-
((JSComponentUI) (Object) comp.getUI()).setRenderer(comp, 0, 0);
111-
}
112-
113109
/**
114110
* Constructs a <code>DefaultCellEditor</code> object that uses a check box.
115111
*
@@ -424,4 +420,9 @@ public void itemStateChanged(ItemEvent e) {
424420
}
425421
}
426422

423+
private void setComponent(JComponent comp) {
424+
CellHolder.setJ2SRendererComponent(editorComponent = comp);
425+
}
426+
427+
427428
} // End of class JCellEditor

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import javax.swing.border.EmptyBorder;
3636

3737
import sun.swing.DefaultLookup;
38-
import swingjs.plaf.JSComponentUI;
3938

4039

4140
/**
@@ -94,9 +93,9 @@ public DefaultListCellRenderer() {
9493
setOpaque(true);
9594
setBorder(getNoFocusBorder());
9695
setName("List.cellRenderer");
97-
// JavaScript is a little slow on painting selection backgrounds, so we instead
98-
// set the background using CSS
99-
((JSComponentUI)getUI()).setAllowPaintedBackground(false);
96+
// // JavaScript is a little slow on painting selection backgrounds, so we instead
97+
// // set the background using CSS
98+
// ((JSComponentUI)getUI()).setAllowPaintedBackground(false);
10099
}
101100

102101
private Border getNoFocusBorder() {
@@ -158,7 +157,7 @@ public JComponent getListCellRendererComponent(
158157

159158
setEnabled(list.isEnabled());
160159
setFont(list.getFont());
161-
160+
getUI().setFont(getFont()); // SwingJS because propertyChangeListener is shut down.
162161
Border border = null;
163162
if (cellHasFocus) {
164163
if (isSelected) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public void removeRange(int fromIndex, int toIndex) {
538538
fireIntervalRemoved(this, fromIndex, toIndex);
539539
}
540540

541-
/*
541+
/* (commented out in JDK8)
542542
public void addAll(Collection c) {
543543
}
544544

0 commit comments

Comments
 (0)