Re: Alternative for deprecated method JFrame.show()



Mike a écrit :
I'm messing around with Java Swing. I'm also messing around with
Eclipse instead of a plain text editor such as TextPad.

When I create the following two classes in Eclipse, I get a persistent
warning that

The method show() from the type Window is deprecated

But I've checked the API docs (hence my looking for the 1.5.0 docs) and
it does NOT indicate that show() is deprecated. Any words of
guidance/advice?

Thanks

import javax.swing.*;

public class LoanCalculatorApp
{
	public static void main(String[] args)
	{
		JFrame frame = new LoanCalculatorFrame();
		frame.show();
	}
}


import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.text.*;


public class LoanCalculatorFrame extends JFrame { public LoanCalculatorFrame() { setTitle("Loan Calculator"); Toolkit tk = Toolkit.getDefaultToolkit(); Dimension d = tk.getScreenSize(); System.out.println("Screen:" + d.width + " by " + d.height + " pixels"); int height = 200; int width = 267; setBounds((d.width-width)/2, (d.height-height)/2, width, height); setResizable(false); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane = getContentPane(); JPanel panel = new JPanel(); contentPane.add(panel);

	}
}

in Swing components .show() is replaced by .setVisible(true) or ..setVisible(false).
to show or hide the component.


.



Relevant Pages

  • Re: Alternative for deprecated method JFrame.show()
    ... Eclipse instead of a plain text editor such as TextPad. ... JFrame frame = new LoanCalculatorFrame(); ... pixels"); int height = 200; ...
    (comp.lang.java.help)
  • Re: eclipse or NetBeans 4.0
    ... testing out ideas & trying small sample apps. ... eclipse was nice & had ... Anyhow - I would recommend trying both. ... the available Swing components. ...
    (comp.lang.java.programmer)