Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

help with Java Question is below?

Use the Swing package to construct a GUI like the picture and has the following behavior;

• When a selection is made from the Combo box, the selected item will be added to the Possibilities list

• When an item from the Possibilities list is single clicked, that item will be added to the Actualities list

• When the Clear button is pressed, a confirm dialog will pop up, allowing the user to change their mind; if the user clicks the yes button, the items will be cleared from the Actualities list

• When the Print button is pressed, the items in the Actualities list will be printed to the screen

• The program should exit when the close button (X) is pressed.

Update:

yeah this is my code so far

import javax.swing.*;

import javax.swing.event.*;

import java.awt.*;

import java.awt.event.*;

import java.util.*;

public class StartHere extends JFrame implements ActionListener

{

private JButton clearbtn;

public StartHere()

{

super("Your Title Here");

Container cp = this.getContentPane();

cp.setLayout(new ColumnLayout (2, 10, 10, ColumnLayout.WIDTH)); // 2 column layout

clearbtn = new JButton("Clear"); // creating the button object

clearbtn.addActionListener(this); //attaching the listener to the button

cp.add(clearbtn); // adding the button to the content pane

// either use setSize or pack but not both together

setSize(100,200);

// pack();

setVisible(true);

}

public static void main(String[] args)

{

// this just creates your GUI

new StartHere();

}

public void actionPerformed (ActionEvent e) {

if (e.getSource().equals(c

Update 2:

import javax.swing.*;

import javax.swing.event.*;

import java.awt.*;

import java.awt.event.*;

import java.util.*;

public class StartHere extends JFrame implements ActionListener

{

private JButton clearbtn;

public StartHere()

{

super("Your Title Here");

Container cp = this.getContentPane();

cp.setLayout(new ColumnLayout (2, 10, 10, ColumnLayout.WIDTH)); // 2 column layout

clearbtn = new JButton("Clear"); // creating the button object

clearbtn.addActionListener(this); //attaching the listener to the button

cp.add(clearbtn); // adding the button to the content pane

// either use setSize or pack but not both together

setSize(100,200);

// pack();

setVisible(true);

}

public static void main(String[] args)

{

// this just creates your GUI

new StartHere();

}

public void actionPerformed (ActionEvent e) {

if (e.getSource().equals(clearbtn)) {

// this is code thatshould execute when clear button is

}

}

}

2 Answers

Relevance
  • 5 years ago

    It means there is a 'dangling else' somewhere " an else somewhere that does not proceed an if statement. Also, the 'else' in the example is misspelled (it is 'esle'). That could be the problem.

  • 1 decade ago

    I don't mind answering Java questions, but did you put any effort into this at all before posting it here?

Still have questions? Get your answers by asking now.