Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Eclipse wont create JLabels
Eclipse wont create JLabels [message #1405403] Thu, 07 August 2014 09:22 Go to next message
Vangelis Michos is currently offline Vangelis MichosFriend
Messages: 6
Registered: July 2014
Junior Member
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 10:02 Go to previous message
Vangelis Michos is currently offline Vangelis MichosFriend
Messages: 6
Registered: July 2014
Junior Member
frame.getContentPane().validate();
frame.getContentPane().repaint();


Problem solved by adding these on the end of the code

[Updated on: Thu, 07 August 2014 10:02]

Report message to a moderator

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


Current Time: Wed Oct 23 13:40:16 GMT 2019

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

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

Back to the top