Skip to main content



      Home
Home » Newcomers » Newcomers » Eclipse wont create JLabels
Eclipse wont create JLabels [message #1405403] Thu, 07 August 2014 05:22 Go to next message
Eclipse UserFriend
I'm having this issue with Eclipse. I have an app window that has 3 JTextFields. I want everytime to check if the field has an acceptable value and if not, create under it a JLabel in red that will indicate the error. Because I used absolute layout, I needed to know the coordinates of the JLabel for the setBounds() method. So what i did was create the Jlabels from the Design Tab, then click on them and then I went to their code. With the design manager, the red JLabel would be visible right from the start and that is not what should happen. So i copied the code which created the JLabel via the Design Tab, and placed it inside a MouseEvent so everytime the user will hit the button to make something in my program, I will check the values and if something is wrong, i create the JLabel with the same code inside the " if clause" which checks for the input values. The thing is that my JLabel wont create it self and thats the issue with all of my "if" clauses inside my program.


For example, this JLabel never gets created,no matter what value I give:

String sql_year = year.getText();
// year is my JTextField()
if((sql_year.length()>5)||(sql_year.length()<4))
{
JLabel digit = new JLabel("Error. Year is a 4-5 digit number!!");
digit.setForeground(Color.RED);
digit.setBounds(221, 126, 222, 38);
frame.getContentPane().add(digit);
digit.setVisible(true);
year.setText("");
}
Re: Eclipse wont create JLabels [message #1405420 is a reply to message #1405403] Thu, 07 August 2014 06:02 Go to previous message
Eclipse UserFriend
frame.getContentPane().validate();
frame.getContentPane().repaint();


Problem solved by adding these on the end of the code

[Updated on: Thu, 07 August 2014 06:02] by Moderator

Previous Topic:WSDL
Next Topic:Relative path for dictionary in eclipse
Goto Forum:
  


Current Time: Wed Jul 16 00:31:10 EDT 2025

Powered by FUDForum. Page generated in 0.09820 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top