N+1 selects problem in Hibernate
hi guys,
Im a bit confused...does anyone have an example of the n+1 problem they have that they can give me, like what exactly will take n+1 steps?
Thanks
AU
This may help a bit:
One of the problems that plagued CMP engines with EJB 1.1 was the n+1 problem. This was caused by containers that required n+1 database queries and network invocations to load entity EJBs in a parent-child relationship. For example, if you had an Order entity EJB with 1,000 LineItem? children entity EJBs in a one-to-many relationship, EJB 1.1 CMP engines would require 1,001 database queries to load all of the EJBs. This is crazy, since it's likely that all of the data was stored in only two tables. "
Source: http://www.jboss.org/wiki/Wiki.jsp?page=AvoidBMP
Both CMP and Hibernate are O/R mapping technologies. So, the underlying problem should be the same.
- Saish
Similar Messages
-
Hello,
i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
I preffered the style from MS Outlook Express where you can select the email accounts to edit.
It is a table like this:
Account name | Type | ...
--------------|---------|---------------------
Hotmail | POP3 |
GMX | IMAP |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
Please help me!
Thanks.
WarlockMaybe this will helpimport java.awt.*;
import javax.swing.*;
public class Test3 extends JFrame {
public Test3() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
String[] head = {"One", "Two"};
String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
JTable jt = new JTable(data, head);
jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
content.add(new JScrollPane(jt), BorderLayout.CENTER);
jt.setCellSelectionEnabled(true);
jt.setRowSelectionAllowed(false);
jt.setColumnSelectionAllowed(false);
setSize(300, 300);
setVisible(true);
public static void main(String[] arghs) { new Test3(); }
class MyTableSelectionModel extends DefaultListSelectionModel {
public void setSelectionInterval(int index0, int index1) {
super.setSelectionInterval(0, 0);
} -
Select Problem For 'Back Menus' - Zen V P
Just got the Zen V Plus and tried to set the time/date. Followed the 'guide' and after the time/date screen pressed the 'back button'. Got the Set Alarm/Date/Time (etc) menu but when I selected an option (moved joystick down to desired option then pressed the joystick) the time/date display came up and I was NOT ABLE to set the date. Same thing occurred trying to set the date (tried it several times and it worked once .... then attempted again - several times (4) but it only worked once). Turns out I have the same problem with any option in ANY 'back' menu. Suggestion?
Do I have a defecti've unit (can't be the 'operator' who is defecti've! haha)? Should I return it and try another?
Actually not that interested in playing music .... it's more for playing .wma(DRM) book files.Latest ... updated my firmware (to ZENVPlus_PCFW_P4S_L2___0.exe) and it fixed the select problem for SET DATE/TIME etc however
the SELECT procedure doesn't always work for 'back button' menus. Example: tried to set a bookmark... following procedure in 'guide', pressed 'back button' and held it, from 'NOW PLAYING' screen - works 2 out of 5 times. Most of the time, pressing and holding takes you back to the previous menu - not to the 'back' (or in this case the SET BOOKMARK) menu. Sounds like something for the next version of firmware ... the code doesn't always set an internal timer correctly (am a programmer of 30 years ... part of that time pgmmng firmware). -
Problem in Hibernate 3.0. while configuring with Oracle 9i
Hi,
I have a problem in Hibernate 3.0. while configuring with Oracle 9i.
I make all necessary settings as per the requirement.
My code successfully running with MYSQL,
But if tried use Oracle 9i. then System generate the Following Exceptions.
Please let me know the solution
DEBUG - initializing class SessionFactoryObjectFactory
DEBUG - registered: 2c9834f115ccc9360115ccc937600000 (unnamed)
INFO - Not binding factory to JNDI, no JNDI name configured
DEBUG - instantiated session factory
INFO - Running hbm2ddl schema update
INFO - fetching database metadata
DEBUG - total checked-out connections: 0
DEBUG - using pooled JDBC connection, pool size: 0
ERROR - could not get database metadata
java.sql.SQLException: ORA-00600: internal error code, arguments: [ttcgcshnd-1],
[0], [], [], [], [], [], []Hi
I alreay make all necessary chagens in cfg.file but still i have problem
see the contenet fo .cgf file
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@sinpunap049:1521:esgdb</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="Student1.hbm.xml" />
</session-factory>
</hibernate-configuration> -
when i select a page to be print from my pc the page select in
Hello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
Click on Safari
Scroll down to services then slide to right
Scroll down to services preferences and click
Scroll down to the Text section
If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
I really hope that helps with your problem
I can now go to sleep. -
hi,
iam stuck up with AT LINE-SELECTION problem ie i designed a screen where they need month list on clicking F4. i got the month list using month_names_get in the screen but while clicking the relevant month no.it's not entering into the required parameter. i have attached the codings,
MODULE MONTH_DIS OUTPUT.
SUPPRESS DIALOG.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
SET PF-STATUS SPACE.
NEW-PAGE NO-TITLE.
WRITE:/ 'SELECT MONTH' COLOR COL_HEADING.
ULINE.
DATA: T_MNTH LIKE T247 OCCURS 12 WITH HEADER LINE.
refresh t_mnth.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE =
TABLES
MONTH_NAMES = T_MNTH
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at t_mnth.
write:/ t_mnth-mnr, t_mnth-ltx.
endloop.
CLEAR T_MNTH-MNR.
ENDMODULE. " MONTH_DIS OUTPUT
AT LINE-SELECTION.
p_period = t_mnth-mnr.
CHECK NOT p_period IS INITIAL.
LEAVE TO SCREEN 0.
here in the AT LINE-SELECTION, the selected month is not coming to the required parameter.
pls help me in this issue,
Thanks in advance,
Premnath.You need to set a "Hide" after the write... I suggest you also set your own dialog PF-STATUS too so you can have just a PF2 "pick" button and a Cancel button ( this will look better to the user).
loop at t_mnth.
write:/ t_mnth-mnr, t_mnth-ltx.
hide: t_mnth. "needs this
endloop.
clear: t_mnth. -
Weird BGP path selection problem
Hi, all,
I am seeing a weird BGP path selection problem on 4948 switch running cat4500-entservicesk9-mz.122-46.SG.bin code, this switch has two uplinks to the same ISP's different edge router, one circuit is primary the other one is strict backup, only default route is accepted from ISP. I am setting both local preference and weight to the default route advertised over backup link, however neither one is taking effect, BGP still thinks the backup link is better, what could be wrong?
rtr#sh ip bgp 0.0.0.0/0
BGP routing table entry for 0.0.0.0/0, version 105
Paths: (3 available, best #2, table Default-IP-Routing-Table, not advertised to EBGP peer)
Not advertised to any peer
17675, (received & used)
203.169.8.37 from 203.169.8.37 (61.211.160.150)
Origin IGP, localpref 100, valid, external
Community: 65001:0 no-export
17675
203.169.8.45 from 203.169.8.45 (61.211.160.151)
Origin IGP, localpref 90, weight 90, valid, external, best <====
Community: 65001:0 no-export
17675, (received-only)
203.169.8.45 from 203.169.8.45 (61.211.160.151)
Origin IGP, localpref 100, valid, external
Community: 65001:0 no-export
ThanksHi,
On cisco routers , weight is having highest preference to decide best path. By default for received route, weight is 0 but you are setting weight 90 to backup path and that is why it is getting preferred (higher is better). Please remove weight and let local preference be 90 (lesser than route on primary path)
--Pls dont forget to rate helpful posts--
Regards,
Akash -
Certificate selection problem in Safari
Hi ,
I have certifcates A,B,C,D for the same site , whenever i use the Mozilla it is asking which one to select , but somehow i dont know why Safari is asking the same option.
It is forcing me to accept Certifcate A to that paricular site. How to solve this problem in safari.
Regards
VikranthHello. I feel your pain and frustration with the print selection problem in safari, especially in Snow Leopard. I have spent hours trawling help pages and forums etc. BUT YEE HAA (sorry got a bit excited, but it really was hours) I found the answer. So here goes.
Click on Safari
Scroll down to services then slide to right
Scroll down to services preferences and click
Scroll down to the Text section
If you Tick the Text box it will choose all options for you. Or if you don't want all options in the Text list, then untick Text box and tick options you do want.
BUT for your print selection problem make sure you tick NEW TEXT EDIT WINDOW CONTAINING SELECTION.
Then when you want to select something in a web page you want to print (including pictures etc) then highlight it, then Right click. And low and behold, in the list is NEW TEXT EDIT WINDOW CONTAINING SELECTION. Click that, Then press cmd+p and your printing.
I really hope that helps with your problem
I can now go to sleep. -
Weblogic 10.3.5.0 problem with hibernate criteria
Hi,
I have problim with using Hibernate Criteria on Weblogic server. Everithing works fine on Tomcat.
On weblogic I can execute this on Weblogic :
Query query = sessionFactory.getCurrentSession().createSQLQuery("select sysdate from dual");//To get string date
String result = query.uniqueResult().toString();
,but I have problem with executing criteria which work on tomcat:
Criteria crit=sessionFactory.getCurrentSession().createCriteria(MyclassWithHibernate.class);
crit.setFirstResult(0);
crit.setMaxResults(1);
return (MyclassWithHibernate) crit.uniqueResult();
On weblogic, same criteria return me null and I get this exception:
java.lang.NullPointerException
at test.Rasa.getValueTest(Rasa.java:68)
at test.Rasa$$FastClassByCGLIB$$b6e6c0b9.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
at test.Rasa$$EnhancerByCGLIB$$e20363db.getValueTest(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:418)
at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1400)
at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:1005)
at flex.messaging.endpoints.AbstractEndpoint$$FastClassByCGLIB$$1a3ef066.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.flex.core.MessageInterceptionAdvice.invoke(MessageInterceptionAdvice.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:576)
at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$64941f01.serviceMessage(<generated>)
at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:103)
at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:166)
at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:291)
at flex.messaging.endpoints.AMFEndpoint$$EnhancerByCGLIB$$64941f01.service(<generated>)
at org.springframework.flex.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:101)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Enwironment is :
WebLogic Server 10.3.5.0
Hibernate 3.x
Spring 3.x
I am using this configuration i application context:
<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
<property name="connectionCachingEnabled" value="true" />
<property name="URL" value="jdbc:oracle:thin:@address:port:db" />
<property name="user" value="myuser"></property>
<property name="password" value="mypass"></property>
<property name="connectionCacheProperties">
<props merge="default">
<prop key="MinLimit">3</prop>
<prop key="MaxLimit">20</prop>
</props>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref ="dataSource"/>
<property name="packagesToScan" value="test*" />
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
</props>
</property>
</bean>
Thanks for any help.Which code snippet is throwing the nullpointerexception?
Does Spring create the SessionFactory?
Maybe it is related but when running Hibernate on WebLogic you have to take care of a classloading issue with the antlr libary,
more information can be found here: http://middlewaremagic.com/weblogic/?p=5861 -
Selection problem on ADRC Table.
Dear Exparts.
please see the Query:
select country city1 from adrc
into CORRESPONDING FIELDS OF wa_country
where
country = p_country
and
city1 = p_city.
append wa_country to it_country.
endselect.
In this selection, when I send p_country = AE and p_city = Dubai I cannot get any data. But there have data In DB.
But when I send p_country = DE and p_city = Berlin I can get porper data.
Can anybody solve this problem.
Your regards
rayhanJust paste the below code and check either getting value or not
DATA wa_country TYPE adrc.
PARAMETERS: p_city TYPE adrc-city1 DEFAULT 'Dubai',
p_countr TYPE adrc-country DEFAULT 'AE'.
SELECT SINGLE * FROM adrc INTO wa_country WHERE country = p_countr
AND city1 = p_city.
IF sy-subrc = 0.
WRITE : / wa_country-city1, / wa_country-country.
ENDIF.
Kanagaraja L -
Hello everyone,
I've a JTable,which I'm rendering using my own renderer.When the background of any cell within the table is rendered,that particular row does not get highlighted on mouseclick.However,when only the foreground is set (without setting the background),the row is highlighted.Can anyone suggest anything on this problem.I want the row to be highlighted on mouse click even if the background of the cell is rendered.
thanx in advance.
J.CMaybe u can use this, but you might want to extend your cell renderer.
[qouote from API docs]
setSelectionBackground
public void setSelectionBackground(Color selectionBackground)
Sets the background color for selected cells. Cell renderers can use this color to the fill selected cells.
The default value of this property is defined by the look and feel implementation. -
Selection problem in a JList !!!!
I am using a JList and on the selection of an item in this JList - I enable and disable some buttons.
I have currenlty added a ListSelectionListener that allows me to trap the valuechanged event and thus if any item in the list is selected / deselected, i can enable/ disable the buttons.
Now the abuv works fine with click and Ctrl clicking (to deselect),
However if i come into the JList from another control (a JCombo) by tabbing and then use the arrow keys once the control is in the JList, the up and down arrow keys allow me to change the selection in the list.
But, the valueChanged event does not come in the above case and hence the buttons do not enable/disable !!!
Can you tell me what can be the problem?????Add a key listener and handle the KeyEvent
Sachin -
Selection problem in rendered JtextArea.
I create a jtable by rendering one column using jTextarea. While selecting the row, color of selection not geting to the rendered Jtextarea. How can i solve this problem.
please help meDo you include code in your getTableCellRendererComponent method to change
the color depending on if the row is selected or not? You'll need something like
if ( isSelected ) {
setForeground( table.getSelectionForeground() );
setBackground( table.getSelectionBackground() );
} else {
setForeground( table.getForeground() );
setBackground( table.getBackground() );
}: jay -
Selection problem in JTextArea
hi all
i have a TextArea in which i have some coded charecters in a group of ten charactes i treet these ten characters as a single character ,so when i delete or insert these charactes all these charactes r deleted and no other character r inserted in between , i do it with the caretListener,
But the problem which i face is on the selection i want to select these characters as when we select some part of the URL then it is selected completely.
help in the prob.this might work
paste some text into the textArea (ensure it contains a sequence "12345")
click anywhere in area of 12345
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
class Testing extends JFrame
String specialChars = "12345";
boolean settingCaret = false;
public Testing()
setSize(200,200);
setLocation(300,200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
final JTextArea ta = new JTextArea(10,10);
JScrollPane sp = new JScrollPane(ta);
sp.setPreferredSize(new Dimension(175,150));
JPanel jp = new JPanel();
jp.add(sp);
getContentPane().add(jp);
pack();
ta.addCaretListener(new CaretListener(){
public void caretUpdate(CaretEvent ce){
if(settingCaret == false)
int startPos = ta.getText().indexOf(specialChars);
if(startPos > -1)
if(ta.getCaretPosition() >= startPos && ta.getCaretPosition() <= startPos+specialChars.length())
settingCaret = true;
ta.setSelectionStart(startPos);
ta.setSelectionEnd(startPos+specialChars.length());
settingCaret = false;
public static void main(String[] args){new Testing().setVisible(true);}
} -
Selection problem with JFormattedTextField
I encounter a problem to select the content of a JFormattedTextField.
Here is a class for a dialog containing 2 JFormattedTextFields :
* Created on 7 juin 2005
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
package cimpa.smartndtkit.dialog;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javax.swing.JTextField;
import cimpa.smartndtkit.utilities.Texts;
import cimpa.smartndtkit.utilities.basic_classes.MyButton;
import cimpa.smartndtkit.utilities.basic_classes.MyFormattedTextField;
import cimpa.smartndtkit.utilities.basic_classes.MyLabel;
import cimpa.smartndtkit.utilities.basic_classes.MyPanel;
* @author st08051
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
public class ChangePaletteLimitsDialog extends MyDialog {
private boolean isOK = false;
private float minValue, maxValue;
private MyButton bOK, bCancel;
private MyFormattedTextField txtMin, txtMax;
public ChangePaletteLimitsDialog(JFrame parent, float minValue, float maxValue){
super(parent, "Modification des limites", true);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new GridBagLayout());
/** Constantes */
Insets leftComponentInsets = new Insets(15,30,0,5);
Insets rightComponentInsets = new Insets(15,5,0,30);
Insets buttonsInsets = new Insets(8,5,8,5);
int txtWidth = 60;
int txtHeight = 22;
DecimalFormat format = Texts.formatFactory("###0.###");
/** Cr�ation des composants */
MyLabel labelMin = new MyLabel("Valeur minimale :");
txtMin = new MyFormattedTextField(format);
txtMin.setHorizontalAlignment(JTextField.RIGHT);
txtMin.setAlignmentX(JTextField.RIGHT_ALIGNMENT);
txtMin.setSizes(txtWidth, txtHeight);
txtMin.setText(""+minValue);
// txtMin.setValue(new Float(minValue));
txtMin.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
keyPressed_actionPerformed(ke);
txtMin.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent arg0) {
txtMin.selectAll();
// public void focusLost(FocusEvent arg0) {
// txtMin.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent arg0) {
// txtMin.selectAll();
MyLabel labelMax = new MyLabel("Valeur maximale :");
txtMax = new MyFormattedTextField(format);
txtMax.setHorizontalAlignment(JTextField.RIGHT);
txtMax.setAlignmentX(JTextField.RIGHT_ALIGNMENT);
txtMax.setSizes(txtWidth, txtHeight);
txtMax.setText(""+maxValue);
// txtMax.setValue(new Float(maxValue));
txtMax.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
keyPressed_actionPerformed(ke);
txtMax.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent arg0) {
txtMax.selectAll();
// public void focusLost(FocusEvent arg0) {
// txtMax.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent arg0) {
// txtMax.selectAll();
MyPanel panel = new MyPanel();
bOK = new MyButton("OK");
bOK.setSizes(60,25);
bOK.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
bOK_actionPerformed();
bCancel = new MyButton("Annuler");
bCancel.setSizes(60,25);
bCancel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
bCancel_actionPerformed();
/** Contraintes */
GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.CENTER;
/** Agencement des composants */
constraints.gridx = 1;
constraints.gridy = 0;
constraints.gridwidth = 2;
constraints.insets = leftComponentInsets;
getContentPane().add(labelMin, constraints);
constraints.gridx = 3;
constraints.insets = rightComponentInsets;
getContentPane().add(txtMin, constraints);
constraints.gridx = 1;
constraints.gridy = 1;
constraints.insets = leftComponentInsets;
getContentPane().add(labelMax, constraints);
constraints.gridx = 3;
constraints.insets = rightComponentInsets;
getContentPane().add(txtMax, constraints);
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridwidth = 1;
constraints.insets = buttonsInsets;
panel.add(bOK, constraints);
constraints.gridx = 1;
panel.setLayout(new GridBagLayout());
panel.add(bCancel, constraints);
constraints.gridx = 0;
constraints.gridy = 3;
constraints.gridwidth = 6;
constraints.anchor = GridBagConstraints.CENTER;
getContentPane().add(panel, constraints);
this.pack();
setLocationRelativeTo(parent);
txtMin.requestFocus();
// getRootPane().setDefaultButton(bOK);
setVisible(true);
* @return
public boolean isOK() {
return isOK;
public void bOK_actionPerformed(){
isOK=true;
minValue = new Float(txtMin.getText()).floatValue();
maxValue = new Float(txtMax.getText()).floatValue();
dispose(); //st11870 : � faire en dehors ou l�?
public void bCancel_actionPerformed(){
escapeActionPerformed();
private void keyPressed_actionPerformed(KeyEvent ke) {
if (ke.getKeyChar() == KeyEvent.VK_ESCAPE) {
escapeActionPerformed();
else if (ke.getKeyChar() == KeyEvent.VK_ENTER) {
bOK_actionPerformed();
protected void escapeActionPerformed() {
isOK=false;
dispose();
public float getMaxValue() {
return maxValue;
public float getMinValue() {
return minValue;
}The problem is that the first time I pass through a textfield, it selects its content. But once, it has been selected, it can't be selected anymore...
And if I make a setValue() during the initialization, it cannot be selected at all!
Does anyone know how to fix this?
Thanks!Should work now...
package cimpa.smartndtkit.dialog;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.text.DecimalFormat;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class ChangePaletteLimitsDialog extends JDialog {
private boolean isOK = false;
private float minValue, maxValue;
private JButton bOK, bCancel;
private JFormattedTextField txtMin, txtMax;
public ChangePaletteLimitsDialog(JFrame parent, float minValue, float maxValue){
super(parent, "Modification des limites", true);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getContentPane().setLayout(new GridBagLayout());
/** Constantes */
Insets leftComponentInsets = new Insets(15,30,0,5);
Insets rightComponentInsets = new Insets(15,5,0,30);
Insets buttonsInsets = new Insets(8,5,8,5);
int txtWidth = 60;
int txtHeight = 22;
DecimalFormat format = formatFactory("###0.###");
/** Cr�ation des composants */
JLabel labelMin = new JLabel("Valeur minimale :");
txtMin = new JFormattedTextField(format);
txtMin.setHorizontalAlignment(JTextField.RIGHT);
txtMin.setAlignmentX(JTextField.RIGHT_ALIGNMENT);
txtMin.setSize(txtWidth, txtHeight);
txtMin.setText(""+minValue);
// txtMin.setValue(new Float(minValue));
txtMin.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
keyPressed_actionPerformed(ke);
txtMin.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent arg0) {
txtMin.selectAll();
// public void focusLost(FocusEvent arg0) {
// txtMin.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent arg0) {
// txtMin.selectAll();
JLabel labelMax = new JLabel("Valeur maximale :");
txtMax = new JFormattedTextField(format);
txtMax.setHorizontalAlignment(JTextField.RIGHT);
txtMax.setAlignmentX(JTextField.RIGHT_ALIGNMENT);
txtMax.setSize(txtWidth, txtHeight);
txtMax.setText(""+maxValue);
// txtMax.setValue(new Float(maxValue));
txtMax.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
keyPressed_actionPerformed(ke);
txtMax.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent arg0) {
txtMax.selectAll();
// public void focusLost(FocusEvent arg0) {
// txtMax.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent arg0) {
// txtMax.selectAll();
JPanel panel = new JPanel();
bOK = new JButton("OK");
bOK.setSize(60,25);
bOK.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
bOK_actionPerformed();
bCancel = new JButton("Annuler");
bCancel.setSize(60,25);
bCancel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
bCancel_actionPerformed();
/** Contraintes */
GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.CENTER;
/** Agencement des composants */
constraints.gridx = 1;
constraints.gridy = 0;
constraints.gridwidth = 2;
constraints.insets = leftComponentInsets;
getContentPane().add(labelMin, constraints);
constraints.gridx = 3;
constraints.insets = rightComponentInsets;
getContentPane().add(txtMin, constraints);
constraints.gridx = 1;
constraints.gridy = 1;
constraints.insets = leftComponentInsets;
getContentPane().add(labelMax, constraints);
constraints.gridx = 3;
constraints.insets = rightComponentInsets;
getContentPane().add(txtMax, constraints);
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridwidth = 1;
constraints.insets = buttonsInsets;
panel.add(bOK, constraints);
constraints.gridx = 1;
panel.setLayout(new GridBagLayout());
panel.add(bCancel, constraints);
constraints.gridx = 0;
constraints.gridy = 3;
constraints.gridwidth = 6;
constraints.anchor = GridBagConstraints.CENTER;
getContentPane().add(panel, constraints);
this.pack();
setLocationRelativeTo(parent);
txtMin.requestFocus();
// getRootPane().setDefaultButton(bOK);
setVisible(true);
* @return
public boolean isOK() {
return isOK;
public void bOK_actionPerformed(){
isOK=true;
minValue = new Float(txtMin.getText()).floatValue();
maxValue = new Float(txtMax.getText()).floatValue();
dispose();
public void bCancel_actionPerformed(){
escapeActionPerformed();
private void keyPressed_actionPerformed(KeyEvent ke) {
if (ke.getKeyChar() == KeyEvent.VK_ESCAPE) {
escapeActionPerformed();
else if (ke.getKeyChar() == KeyEvent.VK_ENTER) {
bOK_actionPerformed();
protected void escapeActionPerformed() {
isOK=false;
dispose();
public float getMaxValue() {
return maxValue;
public float getMinValue() {
return minValue;
public static DecimalFormat formatFactory(String pattern){
DecimalFormat format = new DecimalFormat(pattern);
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator('.');
format.setDecimalFormatSymbols(dfs);
return format;
}
Maybe you are looking for
-
BI Java Installation: Clarification Needed!
I'm wondering if someone could help clear this up for me: We have installed NW2004s SPS08 on Solaris with only the usage type EP (AS Java/EP). Awhile back I was tasked with connecting our BW ABAP system to our Portal ("Integration into the Portal" -
-
TS3408 getting "error 503" when trying to access a particular site.
says "error 503 : service temporarily unavailable" when I try to access a particular site, if I use phone, access is ok. Thanks in advance
-
Is there a way programs can run if the screen/lid is closed
I would like to know if i can do something like have a torrent running if the lip on my MBP is closed. Ky
-
Can I use the `deny` statements is a SQL database
I have a web-app that I will need to scale to large proportions. In this web-app, I have a database in which some clients should not have access to specif tables. Can I use `deny` statements on an Azure SQL databases? Like this: deny select on a_tabl
-
Why can I no longer watch movies in itunes?
Downloaded a movie and had no problem watching it. Today I try to watch it again and no luck. What's going on? I purchased the movie from the Apple Store