[Java] what the hell am I doing wrong with this graphical interfaze?

  • Context: Java 
  • Thread starter Thread starter stonecoldgen
  • Start date Start date
  • Tags Tags
    Java
Click For Summary
SUMMARY

The discussion centers on a Java graphical user interface (GUI) issue involving the "FinalesCopaMundo" and "InterfazFinalesCopaMundo" classes. The user encounters an error when attempting to instantiate the "FinalesCopaMundo" class within the "InterfazFinalesMundiales" constructor. The solution provided involves adding a "throws Exception" declaration, which resolves the error, indicating that the constructor of "FinalesCopaMundo" likely throws an exception that must be handled or declared.

PREREQUISITES
  • Java programming language fundamentals
  • Understanding of Java Swing for GUI development
  • Exception handling in Java, including "throws" keyword
  • Basic knowledge of object-oriented programming concepts
NEXT STEPS
  • Review Java Exception Handling best practices
  • Explore Java Swing components and layout management
  • Investigate the implementation of constructors in Java classes
  • Learn about debugging techniques in Java applications
USEFUL FOR

Java developers, particularly those working on GUI applications, and anyone troubleshooting Java exception handling issues.

stonecoldgen
Messages
108
Reaction score
0
I have a package with all the classes needed to perform the functional recquirements (calculations, etc.). It's working perfectly. The "main" class is "FinalesCopaMundo"

I have another package with all the classes needed to perform the GUI. The "main" class is "InterfazFinalesCopaMundo".

I have:

Code:
package uniandes.cupi2.finalesCopaMundo.interfaz;
import javax.swing.*;

import java.awt.*;
import uniandes.cupi2.finalesCopaMundo.mundo.*;


public class InterfazFinalesMundiales extends JFrame{

	//Atributos
	
	private PanelEquipoA panelEquipoA;
	private PanelEquipoB panelEquipoB;
	private PanelImagen panelImagen;
	private PanelInformacion panelInformacion;
	private PanelOpciones panelOpciones;
	
	private FinalesCopaMundo finalesCopaMundo; //this line is not throwing an error
	
	
	//Constructor
	
	public InterfazFinalesMundiales(){
		
	finalesCopaMundo=new FinalesCopaMundo(); //this line is throwing an error



I don't know why this is, any tips?
 
Technology news on Phys.org


OK, for some reason adding a "throws Exception" was the solution, but I don't know why, any idea?
 


Can you pst your FinalesCopaMundo class? (I assume that is where you added the throws Exception statement?)
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
914
  • · Replies 1 ·
Replies
1
Views
1K
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 14 ·
Replies
14
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K