Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tbee committed May 18, 2023
1 parent 598ab3e commit 1396476
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
14 changes: 7 additions & 7 deletions demo/src/main/java/net/miginfocom/demo/SwingDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class SwingDemo extends JFrame
private JPanel contentPanel = DEBUG ? new JPanel(new BorderLayout()) : new JPanel(new MigLayout("wrap", "[]unrel[grow]", "[grow][pref]"));

private JTabbedPane layoutPickerTabPane = new JTabbedPane();
private JList pickerList = new JList(new DefaultListModel());
private JList<Object> pickerList = new JList<>(new DefaultListModel<Object>());

private JTabbedPane southTabPane = new JTabbedPane();
private JScrollPane descrTextAreaScroll = createTextAreaScroll("", 5, 80, true);
Expand Down Expand Up @@ -279,7 +279,7 @@ public void mouseClicked(MouseEvent e)
}

for (int i = 0; i < panels.length; i++)
((DefaultListModel) pickerList.getModel()).addElement(panels[i][0]);
((DefaultListModel<Object>) pickerList.getModel()).addElement(panels[i][0]);

try {
if (UIManager.getLookAndFeel().getID().equals("Aqua")) {
Expand Down Expand Up @@ -505,7 +505,7 @@ public JComponent createAPI_Constraints1()

// References to text fields not stored to reduce code clutter.

JScrollPane list2 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));
JScrollPane list2 = new JScrollPane(new JList<String>(new String[] {"Mouse, Mickey"}));
panel.add(list2, new CC().spanY().growY().minWidth("150").gapX(null, "10"));

panel.add(new JLabel("Last Name"));
Expand Down Expand Up @@ -671,7 +671,7 @@ public JComponent createLayout_Showdown()

JPanel p = createTabPanel(new MigLayout("", "[]15[][grow,fill]15[grow]"));

JScrollPane list1 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));
JScrollPane list1 = new JScrollPane(new JList<>(new String[] {"Mouse, Mickey"}));

p.add(list1, "spany, growy, wmin 150");
p.add(new JLabel("Last Name"));
Expand Down Expand Up @@ -710,7 +710,7 @@ public JComponent createLayout_Showdown()

// References to text fields not stored to reduce code clutter.

JScrollPane list2 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));
JScrollPane list2 = new JScrollPane(new JList<>(new String[] {"Mouse, Mickey"}));
p2.add(list2, "spany, growy, wmin 150");
p2.add(new JLabel("Last Name"));
p2.add(new JTextField());
Expand Down Expand Up @@ -3291,9 +3291,9 @@ private JLabel createLabel(String text, int align)
return b;
}

public JComboBox createCombo(String[] items)
public JComboBox<String> createCombo(String[] items)
{
JComboBox combo = new JComboBox(items);
JComboBox<String> combo = new JComboBox<>(items);

if (PlatformDefaults.getCurrentPlatform() == PlatformDefaults.MAC_OSX)
combo.setOpaque(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public VisualPaddingOSX()
add(new JTextField("A text"), cc);
add(new JScrollPane(new JTextPane()), cc);
add(new JScrollPane(new JTextArea("A text", 1, 20)), cc);
JList list = new JList(new Object[] {"A text"});
JList<Object> list = new JList<>(new Object[] {"A text"});
list.setVisibleRowCount(1);
add(new JScrollPane(list), cc);

Expand Down Expand Up @@ -160,9 +160,9 @@ private JButton createBorderButton(String name, Border border)
return button;
}

private JComboBox createCombo(String key, boolean editable)
private JComboBox<Object> createCombo(String key, boolean editable)
{
JComboBox comboBox = new JComboBox(new Object[]{ String.valueOf(key)});
JComboBox<Object> comboBox = new JComboBox<>(new Object[]{ String.valueOf(key)});
comboBox.setFocusable(editable);
comboBox.setEditable(editable);
if (key != null)
Expand Down
2 changes: 1 addition & 1 deletion ideutil/src/main/java/net/miginfocom/layout/IDEUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static String getConstraintString(AC ac, boolean asAPI, boolean isCols)
{
StringBuffer sb = new StringBuffer(32);

DimConstraint[] dims = ac.getConstaints();
DimConstraint[] dims = ac.getConstraints();
BoundSize defGap = isCols ? PlatformDefaults.getGridGapX() : PlatformDefaults.getGridGapY();

for (int i = 0; i < dims.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ protected double computeHeight(double refWidth, int type) {
private int getHorIns()
{
Insets insets = getInsets();
return (int) Math.ceil(snapSpace(insets.getLeft()) + snapSpace(insets.getRight()));
return (int) Math.ceil(snapSpaceX(insets.getLeft()) + snapSpaceX(insets.getRight()));
}

private int getVerIns()
{
Insets insets = getInsets();
return (int) Math.ceil(snapSpace(insets.getTop()) + snapSpace(insets.getBottom()));
return (int) Math.ceil(snapSpaceY(insets.getTop()) + snapSpaceY(insets.getBottom()));
}

private Orientation bias = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static public void sleep(int ms) {
*/
static public void runAndWait(final Runnable runnable) {
try {
FutureTask future = new FutureTask(runnable, null);
FutureTask<Void> future = new FutureTask<>(runnable, null);
Platform.runLater(future);
future.get();
}
Expand Down
4 changes: 3 additions & 1 deletion swing/src/main/java/net/miginfocom/swing/MigLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,9 @@ public static <E> E findType(Class<E> clazz, Component comp)
while (comp != null && !clazz.isInstance(comp))
comp = comp.getParent();

return (E) comp;
@SuppressWarnings("unchecked")
E compCasted = (E) comp;
return compCasted;
}


Expand Down

0 comments on commit 1396476

Please sign in to comment.