|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Hi there -
I'm trying to develop a regular Java program that has a window with a textfield and an image. When the user types something in the textbox, it is stored and then a new image replaces the old one. I'm having issues with just getting the text field on: a snippet of code: import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class TryIO extends JFrame implements ActionListener { static JFrame aWindow = new JFrame("This is the Window Title"); public TryIO() { Container content = getContentPane(); JPanel panel = JPanel(); JTextField textField = new JTextField("Default input", 20); panel.add(textField); content.add(panel, "test"); } and then when i use JDK to compile i get: TryIO.java:16: cannot resolve symbol symbol : method JPanel () location: class TryIO JPanel panel = JPanel(); plus i'm using the: DataInputStream imagesIn = new DataInputStream(new FileInputStream(myImages)); images[index] = imagesIn.readLine(); and when that compiles I get: java.io.DataInputStream has been deprecated. What does that mean and does anyone know how I can get my app to work? - A ![]() |
|
#2
|
|||
|
|||
|
I think the problem is here:
Code:
JPanel panel = JPanel(); You should create new instance of the JPanel class using it's constructor: Code:
JPanel panel = new JPanel(); Check out the JPanel class from URL. Something what is deprecated doesn't exist anymore in new releases of API-packages, although it has been part of the API-package. In this case, DataInputStream's readLine()-method is deprecated since JDK 1.1. To fix out this problem, replace Code:
DataInputStream imagesIn = new DataInputStream(new FileInputStream(myImages)); with Code:
BufferedReader imagesIn = new BufferedReader(new InputStreamReader(new FileInputStream(myImages))); |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Java app w/textfield & image problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|