Question

Note: Fall_2e17.java uses or overrides a deprecated API Note: Recompile with -Xlint:deprecation for details.

I am getting this Error can you please fix my Java code.

import java.awt.Dialog;

import java.awt.Label;

import java.awt.TextArea;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map.Entry;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

public class Fall_2017 {
  
public TextArea courseInput;
  
public Label textAreaLabel;
  
public JButton addData;
  
public Dialog confirmDialog;
  
HashMap<Integer, ArrayList<String>> students;
  
public Fall_2017(){
  
courseInput = new TextArea(20, 40);
  
textAreaLabel = new Label("Student's data:");
  
addData = new JButton("Add Data");
  
addData.addActionListener(new ActionListener()
{
  
@Override
  
public void actionPerformed(ActionEvent e) {
  
confirmDialog.show();
  
}
  
});

createGUI();
  
}
  
public void createGUI(){
  
JFrame frame = new JFrame("Student's Data");
  
frame.setVisible(true);
  
frame.setSize(500, 500);
  
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
JPanel panel = new JPanel();
  
panel.add(textAreaLabel);
  
panel.add(courseInput);
  
panel.add(addData);
  
frame.getContentPane().add(panel);
  
initialiseConfirmDialog(frame);
  
}
  
private void initialiseConfirmDialog(JFrame frame) {
  
confirmDialog = new Dialog(frame);
  
JPanel panel = new JPanel();
  
panel.add(new Label("Do you want to add more students?"));
  
JButton yesButton = new JButton("Yes");
  
JButton noButton = new JButton("No");
  
yesButton.addActionListener(new ActionListener()
{
  
@Override
  
public void actionPerformed(ActionEvent e) {

confirmDialog.hide();
  
}
  
});
  
noButton.addActionListener(new ActionListener()
{
  
@Override
  
public void actionPerformed(ActionEvent e) {
  
confirmDialog.hide();

String text = courseInput.getText();
  
processCourse(text);
  
courseInput.setText("");
}
} );
  
panel.add(yesButton);
  
panel.add(noButton);
  
confirmDialog.add(panel);
  
confirmDialog.setSize(200, 100);
  
}
  
private void processCourse(String text) {
  
students = new HashMap<>();
  
for(String studentData:text.split("\n")){
  
String[] data = studentData.split(" ");
  
if(students.containsKey(Integer.parseInt(data[0]))){
  
students.get(Integer.parseInt(data[0])).add(data[1]);
  
}else{
  
ArrayList<String> courses = new ArrayList<>();
  
courses.add(data[1]);
  
students.put(Integer.parseInt(data[0]), courses);
  
}
  
}
  
for(Entry<Integer,ArrayList<String>> entry:students.entrySet()){
  
System.out.println(entry.getKey());
  
System.out.println(entry.getValue());
  
System.out.println();
  
}
  
}
  
public static void main(String[] args) {
  
Fall_2017 gui = new Fall_2017();
  
}

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

This is not an error , its a warning message.

recompiler with the below syntax

javac -Xlint xzy.java //provide java file name
you can also try below option.

javac -Xlint:deprecation xyz.java
Add a comment
Know the answer?
Add Answer to:
I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • With the Code below, how would i add a "Back" Button to the bottom of the...

    With the Code below, how would i add a "Back" Button to the bottom of the history page so that it takes me back to the main function and continues to work? import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; public class RecipeFinder { public static void main(String[]...

  • I have currently a functional Java progam with a gui. Its a simple table of contacts...

    I have currently a functional Java progam with a gui. Its a simple table of contacts with 3 buttons: add, remove, and edit. Right now the buttons are in the program but they do not work yet. I need the buttons to actually be able to add, remove, or edit things on the table. Thanks so much. Here is the working code so far: //PersonTableModel.java import java.util.List; import javax.swing.table.AbstractTableModel; public class PersonTableModel extends AbstractTableModel {     private static final int...

  • In Java Swing, in my ButtonHandler class, I need to have 2 different showDialog messages show...

    In Java Swing, in my ButtonHandler class, I need to have 2 different showDialog messages show when my acceptbutton1 is pressed. One message is if the mouse HAS been dragged. One is if the mouse HAS NOT been dragged. /// I tried to make the Points class or the Mouse Dragged function return a boolean of true, so that I could construct an IF/THEN statement for the showDialog messages, but my boolean value was never accepted by ButtonHandler. *************************ButtonHandler class************************************...

  • Re-write this program into a javafx program, using javafx components only. NO awt or swing. import...

    Re-write this program into a javafx program, using javafx components only. NO awt or swing. import java.awt.Button; import java.awt.Label; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JPanel; public class DecimalBinary { public static void main(String[] args) { JFrame frame=new JFrame(); //Create a frame frame.setTitle("Decimal-Binary Converter"); //Set its label frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 300); //Set size fo frame JPanel panel=new JPanel(); //Create a panel to contain controls frame.add(panel); //add panel to frame panel.setLayout(null); Label decimalLabel=new Label("Decimal"); //Create label for decimal decimalLabel.setBounds(10,...

  • I have been messing around with java lately and I have made this calculator. Is there...

    I have been messing around with java lately and I have made this calculator. Is there any way that I would be able to get a different sound to play on each different button 1 - 9 like a nokia phone? Thank you. *SOURCE CODE* import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class Calculator extends JFrame { private final Font BIGGER_FONT = new Font("monspaced",Font.PLAIN, 20); private JTextField textfield; private boolean number = true; private String equalOp = "="; private...

  • Add a timer to the lightbulb ON/OFF program such that the bulb stays on for 10...

    Add a timer to the lightbulb ON/OFF program such that the bulb stays on for 10 seconds after the ON button is pushed and then goes off.   Put a new label on the lightbulb panel that counts the number of seconds the bulb is on and displays the number of seconds as it counts up from 0 to 10. THIS IS A JAVA PROGRAM. The image above is what it should look like. // Demonstrates mnemonics and tool tips. //********************************************************************...

  • import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.BorderFactory; import javax.swing.border.Border; public class Q1 extends JFrame {...

    import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.BorderFactory; import javax.swing.border.Border; public class Q1 extends JFrame {    public static void createAndShowGUI() {        JFrame frame = new JFrame("Q1");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        Font courierFont = new Font("Courier", Font.BOLD, 40);        Font arialFont = new Font("Arial", Font.BOLD, 40);        Font sansFont = new Font("Sans-serif", Font.BOLD, 20);        JLabel label = new JLabel("Enter a word"); label.setFont(sansFont);        Font font1 = new Font("Sans-serif", Font.BOLD, 40);       ...

  • Swing File Adder: Build a GUI that contains an input file, text box and Infile button....

    Swing File Adder: Build a GUI that contains an input file, text box and Infile button. It also must contain and output file, text box and Outfile button. Must also have a process button must read the infile and write to the outfile if not already written that is already selected and clear button. It must pull up a JFile chooser that allows us to brows to the file and places the full path name same with the output file.  Program...

  • How can i make the java class seperate into an MVC pattern? public class ChatView implements Acti...

    How can i make the java class seperate into an MVC pattern? public class ChatView implements ActionListener {    public static void main(String[] args)    {        JFrame chatFrame = new JFrame();        JFrame chatFrame1 = new JFrame();        JFrame chatFrame2 = new JFrame();               JPanel chatPanel = new JPanel();        JPanel chatPanel1 = new JPanel();        JPanel chatPanel2 = new JPanel();        chatFrame.setContentPane(chatPanel);        chatFrame1.setContentPane(chatPanel1);        chatFrame2.setContentPane(chatPanel2);        chatFrame.setLayout(new FlowLayout());        chatFrame1.setLayout(new FlowLayout());        chatFrame2.setLayout(new FlowLayout());        JTextField chatWrite = new JTextField();        JTextField chatWrite1 = new JTextField();        JTextField chatWrite2 = new JTextField();        JTextArea chatDisplay...

  • tart from the following code, and add Action Listener to make it functional to do the...

    tart from the following code, and add Action Listener to make it functional to do the temperature conversion in the direction of the arrow that is clicked. . (Need about 10 lines) Note: import javax.swing.*; import java.awt.GridLayout; import java.awt.event.*; import java.text.DecimalFormat; public class temperatureConverter extends JFrame { public static void main(String[] args) {     JFrame frame = new temperatureConverter();     frame.setTitle("Temp");     frame.setSize(200, 100);     frame.setLocationRelativeTo(null);     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     frame.setVisible(true); }    public temperatureConverter() {     JLabel lblC = new...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT