Skip to content

Commit a6045ee

Browse files
committed
New SwingJS fixes, new tests in Test_Path, Test_Resource, Test_URL
1 parent 3c51477 commit a6045ee

File tree

14 files changed

+181
-7434
lines changed

14 files changed

+181
-7434
lines changed
5.08 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200409140611
1+
20200412183843
5.08 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200409140611
1+
20200412183843

sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
import org.eclipse.jdt.core.dom.WildcardType;
135135

136136
// TODO: superclass inheritance for JAXB XmlAccessorType
137+
// TODO: inner classes of interface are duplicated
137138

138139
//BH 2020.04.05 -- 3.2.9-v1f (Boolean ? ...) not unboxed
139140
//BH 2020.03.21 -- 3.2.9-v1e better v1c

sources/net.sf.j2s.core/unused/Java2ScriptVisitor.java

Lines changed: 0 additions & 7353 deletions
This file was deleted.
5.08 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
this is a testing RandomAccessFile
1+
this is a test
2+
it is a RandomAccessFile
Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package test;
22

3+
import java.awt.Color;
34
import java.awt.Component;
45
import java.awt.Dimension;
56
import java.awt.Font;
67
import java.awt.event.ActionEvent;
78
import java.awt.event.ActionListener;
89
import java.awt.event.ItemEvent;
910
import java.awt.event.ItemListener;
10-
import java.awt.event.MouseAdapter;
11-
import java.awt.event.MouseEvent;
1211
import java.util.Date;
1312

1413
import javax.swing.DefaultComboBoxModel;
@@ -21,41 +20,41 @@
2120
import javax.swing.JPanel;
2221
import javax.swing.JToolTip;
2322
import javax.swing.ToolTipManager;
23+
import javax.swing.border.EmptyBorder;
2424

2525
public class Test_Applet_Combo extends JApplet {
2626

2727
String[] optionsNew = new String[] { "optionnew1", "optionnew2verylong" };
2828
String[] options = new String[] { "option1", "option2", "option3long" };
2929
JLabel[] labels = new JLabel[] { new JLabel("option1"), new JLabel("option2"), new JLabel("option3") };
30-
31-
30+
3231
@Override
3332
public void init() {
3433

35-
MouseAdapter ma = new MouseAdapter() {
36-
@Override
37-
public void mouseEntered(MouseEvent e) {
38-
System.out.println("mouse entered: " + ((JLabel)e.getSource()).getText());
39-
}
40-
};
34+
// MouseAdapter ma = new MouseAdapter() {
35+
// @Override
36+
// public void mouseEntered(MouseEvent e) {
37+
// System.out.println("mouse entered: " + ((JLabel) e.getSource()).getText());
38+
// }
39+
// };
4140
// for (int i = labels.length; --i >= 0;) {
4241
// labels[i].addMouseListener(ma);
4342
// labels[i].addMouseMotionListener(ma);
4443
// }
4544
JPanel p = new JPanel() {
46-
@Override
45+
@Override
4746
public JToolTip createToolTip() {
48-
return new JMultiLineToolTip(20, false);
49-
}
50-
51-
@Override
47+
return new JMultiLineToolTip(20, new Color(0xccccff));
48+
}
49+
50+
@Override
5251
public String getToolTipText() {
53-
return new Date().toString();
54-
}
52+
return "The current date and time is: " + new Date().toString();
53+
}
5554
};
56-
55+
5756
ToolTipManager.sharedInstance().registerComponent(p);
58-
57+
5958
JComboBox c1 = new JComboBox(options) {
6059
@Override
6160
public void addNotify() {
@@ -65,32 +64,52 @@ public void addNotify() {
6564

6665
};
6766
c1.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 24));
68-
c1.setRenderer(new DefaultListCellRenderer() {
67+
c1.setRenderer(new DefaultListCellRenderer() {
6968

7069
@Override
71-
public Component getListCellRendererComponent(JList list, Object value, int index,
72-
boolean isSelected, boolean cellHasFocus) {
70+
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
71+
boolean cellHasFocus) {
7372
System.out.println("Test_Applet_Combo getLCR for list " + value);
7473
list.setToolTipText(isSelected ? "Item " + index + " is " + value : "");
7574
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
7675
}
77-
76+
7877
});
7978
c1.setToolTipText("combo1");
80-
79+
8180
JComboBox c2 = new JComboBox(labels);
8281
System.out.println(c2.getItemAt(2).toString());
83-
c2.setPreferredSize(new Dimension(70,20));
82+
c2.setPreferredSize(new Dimension(70, 20));
8483
p.add(c1);
8584
p.add(c2);
85+
86+
JLabel label = new JLabel("testing") {
87+
@Override
88+
public JToolTip createToolTip() {
89+
return new JMultiLineToolTip(20, Color.yellow);
90+
}
91+
92+
@Override
93+
public String getToolTipText() {
94+
return "The current date and time is: " + new Date().toString();
95+
}
96+
97+
};
98+
99+
ToolTipManager.sharedInstance().registerComponent(label);
100+
101+
label.setBorder(new EmptyBorder(0, 5, 0, 5));
102+
p.add(label);
103+
label.setBackground(Color.yellow);
104+
label.setOpaque(true);
86105
JButton b = new JButton("inc c1");
87106
b.addActionListener(new ActionListener() {
88107

89108
@Override
90109
public void actionPerformed(ActionEvent e) {
91-
c1.setSelectedIndex((c1.getSelectedIndex() + 1)%c1.getItemCount());
110+
c1.setSelectedIndex((c1.getSelectedIndex() + 1) % c1.getItemCount());
92111
}
93-
112+
94113
});
95114
p.add(b);
96115
b = new JButton("new model");
@@ -100,7 +119,7 @@ public void actionPerformed(ActionEvent e) {
100119
public void actionPerformed(ActionEvent e) {
101120
newModel(c1);
102121
}
103-
122+
104123
});
105124
p.add(b);
106125

@@ -110,7 +129,7 @@ public void actionPerformed(ActionEvent e) {
110129
public void itemStateChanged(ItemEvent e) {
111130
System.out.println("Test_Applet_Combo c2 change " + e.getID() + " " + c2.getSelectedIndex());
112131
}
113-
132+
114133
});
115134

116135
c1.addItemListener(new ItemListener() {
@@ -119,18 +138,18 @@ public void itemStateChanged(ItemEvent e) {
119138
public void itemStateChanged(ItemEvent e) {
120139
System.out.println("Test_Applet_Combo c1 change " + e.getID() + " " + c1.getSelectedIndex());
121140
}
122-
141+
123142
});
124-
143+
125144
c1.setFont(c1.getFont());
126145

127146
add(p);
128147
}
129148

130149
int test = 0;
131-
protected void newModel(JComboBox cb) {
132-
cb.setModel(new DefaultComboBoxModel((test = (1-test)) == 0 ? options: optionsNew));
133-
}
134150

151+
protected void newModel(JComboBox cb) {
152+
cb.setModel(new DefaultComboBoxModel((test = (1 - test)) == 0 ? options : optionsNew));
153+
}
135154

136155
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static JTextArea getArea() {
123123

124124
area.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 16));
125125
area.setText(test);
126-
area.setBackground(new Color(200, 200, 180));
126+
//area.setBackground(new Color(200, 200, 180));
127127
// // area.setEditable(false);
128128
// area.addCaretListener(new CaretListener() {
129129
//
@@ -155,7 +155,7 @@ public void setDocument(Document doc) {
155155
area.setEditorKit(new StyledEditorKit());
156156
area.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 16));
157157
area.setText(test);
158-
area.setBackground(new Color(200, 200, 180));
158+
//area.setBackground(new Color(200, 200, 180));
159159
return area;
160160
}
161161

0 commit comments

Comments
 (0)