tag:blogger.com,1999:blog-7651160756792394744.post730889256862118654..comments2024-03-13T00:17:01.732-07:00Comments on Be better...: Common Validation Module for Swing ApplicationAnonymoushttp://www.blogger.com/profile/14421783975563206833noreply@blogger.comBlogger22125tag:blogger.com,1999:blog-7651160756792394744.post-85658709592554779632022-09-07T12:15:53.441-07:002022-09-07T12:15:53.441-07:00https://lookobeauty.com/makeup-artist-institute-ma...<a href="https://lookobeauty.com/makeup-artist-institute-makeup-artist-course-in-gurgaon/" rel="nofollow">https://lookobeauty.com/makeup-artist-institute-makeup-artist-course-in-gurgaon/</a><br /><br />Looking For Best Makeup Artist Course In Gurgaon. Best Makeup Artist Institute With Affordable Fees, Best Placement Record By Top Makeup Teachers In Gurgaon.affordable interior designer https://www.blogger.com/profile/12834240570603361949noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-5951814490969404892021-05-18T22:03:40.474-07:002021-05-18T22:03:40.474-07:00thanks for this informative article.
Angular-train...thanks for this informative article.<br /><a href="https://www.credosystemz.com/training-in-chennai/best-angularjs-training-in-chennai//%22" rel="nofollow">Angular-training in Chennai</a>salomehttps://www.blogger.com/profile/13401814543672733034noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-19231475174869838972019-01-18T22:44:22.544-08:002019-01-18T22:44:22.544-08:00It was worth visiting your blog and I have bookmar...It was worth visiting your blog and I have bookmarked your blog. Hope to visit again<br /><a href="https://www.besanttechnologies.com/data-science-training-in-indira-nagar-bangalore" rel="nofollow">Data Science Course in Indira nagar</a><br /><a href="https://www.besanttechnologies.com/data-science-training-in-btm-layout" rel="nofollow">Data Science Course in btm layout</a><br /><a href="https://www.besanttechnologies.com/python-training-in-kalyan-nagar" rel="nofollow">Python course in Kalyan nagar</a> <br /><a href="http://www.besanttechnologies.in/data-science-training-indira-nagar.html" rel="nofollow">Data Science course in Indira nagar</a><br /><a href="http://www.besanttechnologies.in/data-science-training-in-marathahalli.html" rel="nofollow">Data Science Course in Marathahalli</a><br /><a href="http://www.besanttechnologies.in/data-science-training-in-btm-layout.html" rel="nofollow"> Data Science Course in BTM Layout</a>priyahttps://www.blogger.com/profile/02698383969608187902noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-31866578455732107672018-01-22T22:31:50.105-08:002018-01-22T22:31:50.105-08:00Hi, Great.. Tutorial is just awesome..It is really...Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. <br />I am a regular follower of your blog. Really very informative post you shared here.<br /> Kindly keep blogging. If anyone wants to become a Front end developer learn from <a href="http://wisentechnologies.com/it-courses/html-css-javascript-jquery-training.aspx" title="Javascript Training in Chennai" rel="nofollow">Javascript Training in Chennai</a> .<br /> or <a href="http://javascripttrainingcourses.com" title="Javascript Training in Chennai" rel="nofollow">Javascript Training in Chennai</a>. <br />Nowadays JavaScript has tons of job opportunities on various vertical industry. <a href="http://wisenitsolutions.com/IT-Courses/JavaScript-Training" title="ES6 Training in Chennai" rel="nofollow">ES6 Training in Chennai</a><br />johnhttps://www.blogger.com/profile/05762753151698049652noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-59828363503395653272010-05-11T05:53:28.852-07:002010-05-11T05:53:28.852-07:00hi Jing
thank you for your perfect job
where i can...hi Jing<br />thank you for your perfect job<br />where i can found the source and the jar's ??Al-Ajwehhttps://www.blogger.com/profile/15365480893347053674noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-35650972543567583172009-04-28T03:52:00.000-07:002009-04-28T03:52:00.000-07:00Could you please give me the spring project?
Or b...Could you please give me the spring project?<br /><br />Or built jar file with libraries (netbeans project dist folder)?MethoDhttps://www.blogger.com/profile/16164068429040342200noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-75271307291392657282008-07-22T06:59:00.000-07:002008-07-22T06:59:00.000-07:00ok, got it. Thanks for the suggestion.Jingok, got it. Thanks for the suggestion.<BR/><BR/>JingAnonymoushttps://www.blogger.com/profile/14421783975563206833noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-44938211497371076982008-07-22T05:27:00.000-07:002008-07-22T05:27:00.000-07:00Hello JingAs I mentioned, changing component's sta...Hello Jing<BR/><BR/>As I mentioned, changing component's state in any paint() methods is considered a bad style in Swing team.<BR/><BR/>For example if in my fix I set a tooltip in a paint() method, it will never be approved by my colleagues.<BR/><BR/>Anyway, it is up to you to follow this rule or not<BR/><BR/>Thanks<BR/>alexpUnknownhttps://www.blogger.com/profile/10859193956257017355noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-130743754383331092008-07-22T03:00:00.000-07:002008-07-22T03:00:00.000-07:00Hello Alexp,I have read the JXLayer source code ag...Hello Alexp,<BR/><BR/>I have read the JXLayer source code again. and find that I just set the tooltip of the managed JTextField not the JXlayer itself in the paintlayer() method. In another word: the tooltip of component A is set when the component B is (re)painted. There should be no such problems like you said.Anonymoushttps://www.blogger.com/profile/14421783975563206833noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-31458354108316903832008-07-18T08:21:00.000-07:002008-07-18T08:21:00.000-07:00Hello Jing1. Saving jxlayer reference is a good id...Hello Jing<BR/><BR/>1. Saving jxlayer reference is a good idea, this will also allow you to check that no one incorrectly sets an instance of the HibernateValidationUI to the multiple layer's <BR/><BR/>I think your HibernateValidationUI is not shareable by its nature<BR/><BR/>2. You'll need a paintLayer() at least to draw the error icon if message is invalid<BR/><BR/>3. Even for non-shareable layers, setDirty(true) is recommended technique to repaint the layer<BR/><BR/>alexpUnknownhttps://www.blogger.com/profile/10859193956257017355noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-75489630254686254062008-07-18T07:42:00.000-07:002008-07-18T07:42:00.000-07:00I understood what you mean. But doing it like you ...I understood what you mean. But doing it like you said, I have the following troubles:<BR/><BR/>1. A reference of the jxlayer should be saved in the UI class. because the propertyStateChange() method need it.<BR/>2. All code in the paint() method should be moved into the propertyStateChanged() method, otherwise, each property change will force calling the hibernate validator twice, one for painting the error icon in the paint() method and the other for setting the tooltip, since I can not make sure that paint() method is called before the setTooltip() method is called.<BR/>3. The benefit of the jxlayer (setDirty()) will not be used. I do not even need to override the paintlayer() method. Everything is done in the propertyStateChange() method.<BR/><BR/>thanks<BR/>JingAnonymoushttps://www.blogger.com/profile/14421783975563206833noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-85801533697184297582008-07-18T07:26:00.000-07:002008-07-18T07:26:00.000-07:00let me say it once again,you need invokeLater only...let me say it once again,<BR/>you need invokeLater only in the main() method of the ValidationApplicaton <BR/><BR/>don't set the tooltip in the paint() method, set it in the installUI(), propertyChangeListener, but not in paint()<BR/><BR/>alexpUnknownhttps://www.blogger.com/profile/10859193956257017355noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-3402801282164342922008-07-18T07:23:00.000-07:002008-07-18T07:23:00.000-07:00Hello Alexp,I got it. I mean setting the tooltip l...Hello Alexp,<BR/><BR/>I got it. I mean setting the tooltip like this:<BR/><BR/> protected void paintLayer(Graphics2D g2, JXLayer<JTextComponent> l) {<BR/> super.paintLayer(g2, l);<BR/> InvalidValue[] validationMessages = validator.getInvalidValues(object,<BR/> propertyName);<BR/> if (validationMessages.length > 0) {<BR/> BufferedImage image = Java2DIconFactory.createErrorIcon();<BR/> g2.drawImage(image, l.getWidth() - image.getWidth() - 1,<BR/> l.getHeight() - 8, null);<BR/> setToolTipText(l.getView(), validationMessages[0].getMessage());<BR/> return;<BR/> }<BR/>setToolTipText(l.getView(), null);<BR/> }<BR/> <BR/> private void setToolTipText(final JComponent c, final String text) {<BR/> SwingUtilities.invokeLater(new Runnable() {<BR/> public void run() {<BR/> c.setToolTipText(text);<BR/> }<BR/> });<BR/> }<BR/><BR/>does it make sure that setTooltip() is called outside the paint()?Anonymoushttps://www.blogger.com/profile/14421783975563206833noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-50574699347733144802008-07-18T07:15:00.000-07:002008-07-18T07:15:00.000-07:00Hello JingI meant that you should not change any c...Hello Jing<BR/><BR/>I meant that you should not change any component's properties in the paint method, including the tooltip<BR/><BR/>the setTooltip() should be placed outside the paint method<BR/><BR/>The main method of the ValidationApplicaton must create and use Swing components inside the invokeLater<BR/><BR/>that's it<BR/><BR/>Thanks<BR/>alexpUnknownhttps://www.blogger.com/profile/10859193956257017355noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-53258509677273718112008-07-18T07:02:00.000-07:002008-07-18T07:02:00.000-07:00Hello Alexp,In the main method? In the main method...Hello Alexp,<BR/><BR/>In the main method? In the main method of the ValidationApplication?<BR/><BR/>I don't catch it. what should I call in the invokeLater() method in the main method? You mean the tooltip can be set in the paint() method, if the invokeLater() is used?<BR/><BR/>JingAnonymoushttps://www.blogger.com/profile/14421783975563206833noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-74362053479342924892008-07-18T06:46:00.000-07:002008-07-18T06:46:00.000-07:00Hello JingIn your code, you should only use invoke...Hello Jing<BR/><BR/>In your code, you should only use invokeLater in the main method, when you create your components<BR/>everything else is automatically called on EDT<BR/><BR/>alexpUnknownhttps://www.blogger.com/profile/10859193956257017355noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-26583113035531890572008-07-18T06:37:00.000-07:002008-07-18T06:37:00.000-07:00Hello Alexp,thank you! It's very nice of you. :-)c...Hello Alexp,<BR/><BR/>thank you! It's very nice of you. :-)<BR/><BR/>could I call SwingUtilities.invokeLater in the paint() method? Doing it like this will make sure that the tooltip will be set after the paint() is called. Is that right?Anonymoushttps://www.blogger.com/profile/14421783975563206833noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-63638425362211493012008-07-18T06:17:00.000-07:002008-07-18T06:17:00.000-07:00Hello JingI missed that,you certainly should (I wo...Hello Jing<BR/><BR/>I missed that,you certainly should (I would even say must) create Swing Gui on the Event Dispatch Thread<BR/><BR/>SwingUtilities.invokeLater in the main method will work well<BR/><BR/>alexpUnknownhttps://www.blogger.com/profile/10859193956257017355noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-30605256522697409382008-07-18T06:14:00.000-07:002008-07-18T06:14:00.000-07:00Hello Alexp,How about calling it in the thread of ...Hello Alexp,<BR/><BR/>How about calling it in the thread of the SwingUtilities.invokeLater(doRun)?<BR/><BR/>thanks<BR/>JingAnonymoushttps://www.blogger.com/profile/14421783975563206833noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-45210766166697025542008-07-18T06:00:00.000-07:002008-07-18T06:00:00.000-07:00Hello JingGeChanging the state of the component in...Hello JingGe<BR/><BR/>Changing the state of the component in the paint() methods is considered as a bad style, we follow this rule in the Swing team.<BR/><BR/>First, most of JComponent setters cause repaint() which is not desirable when you paint the component<BR/><BR/>Second, programmers don't expect the component changes after paint() is called, it may lead to a difficult-to-find bugs<BR/><BR/>So I'd recommend you to add a line of code and set the tooltip when domain object is instantiated<BR/><BR/>Thanks<BR/>alexpUnknownhttps://www.blogger.com/profile/10859193956257017355noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-16126945126359850902008-07-18T05:44:00.000-07:002008-07-18T05:44:00.000-07:00Hello Alexp,Thank you for your comments. :-)))I ha...Hello Alexp,<BR/><BR/>Thank you for your comments. :-)))<BR/><BR/>I have changed the blog on your recommendation.<BR/><BR/>-"JTextcomponent". The blogger has ist own tag called also "jtextcomponent". I had some trouble while posting the blog. And I have change it manually......<BR/><BR/>- setBorder() is removed.<BR/><BR/>- @SuppressWarnings("unchecked"). I built this module firstly with eclipse. this annotation will remove the "warning" message in the eclipse. They are now removed from the code.<BR/><BR/>- If I set the tooltip in the propertyStateChanged() method, it will only work when the property is changed. That means, at the first time, when the domain object is instantiated, no tooltip is set. Which problem would I face, if the tooltip is set in the pain() method?<BR/><BR/>- The text is changed. I said that because I did not called the setUI() method and the setUI() will only be called when the JXLayer is first instantiated.<BR/><BR/>- I knew it, but calling frame.setLocationRelativeTo(null) will not (100%) set the window on the center of the screen.<BR/><BR/>- the reference of the TextValidationDemo is added.Anonymoushttps://www.blogger.com/profile/14421783975563206833noreply@blogger.comtag:blogger.com,1999:blog-7651160756792394744.post-47606135012733259812008-07-18T04:58:00.000-07:002008-07-18T04:58:00.000-07:00Hello JingGeThank you for your great blog, I reall...Hello JingGe<BR/><BR/>Thank you for your great blog, I really like it!<BR/><BR/>Here is some comments about the code:<BR/><BR/>- "jTextcomponent" looks like a format error, must be "JTextComponent"<BR/><BR/>- in the installUI() sets the empty border with the empty insets which is equal to the null border<BR/><BR/>- Is it possible to reduce the number of @SuppressWarnings("unchecked") annotations? <BR/>I don't see why they are necessary for the constructor, paintLayer(), isValid() methods and suspect the fields can be properly generified to make this annotation unnecessary<BR/><BR/>- The recommended Swing pattern is never change the state of a component in its paint() methods;<BR/>so tooltip should be set outside it (the propertyStateChanged() looks like a proper place)<BR/><BR/>- "The installUI(JComponent c) method will be called when the jxlayer is first instantiated."<BR/><BR/>I would say that installUI() is called when layer.setUI(ui) is called, in your code it happens indirectly when you pass the ui to the layer's constructor.<BR/><BR/>- existing frame.setLocationRelativeTo(null); is shorter than setCenter() method<BR/><BR/>- Could you add a note that HibernateValidationUI is based on the TextValidationDemo from the jxlayer's demo package<BR/><BR/>Thanks<BR/>alexpUnknownhttps://www.blogger.com/profile/10859193956257017355noreply@blogger.com