There are cases when you want to select all or highlight the characters inside a textfield or password field in your Java desktop app. Here's a sample code to do that:
int i = textfield.getText().length();
textfield.setSelectionStart(0);
textfield.setSelectionEnd(i);
Put this in the action or wherever you want it. Replace...
Sunday, March 6, 2016
How to change any date format to DATE datatype in MySQL (Insert or Update)
Use this function: STR_TO_DATE('date', 'format')
This accepts two parameters: date and format where date is the input raw date you want to change and format is the corresponding format relative to date that you want to change.
For example:
INSERT INTO table(date_field) VALUES(STR_TO_DATE('December 8, 2010','%M %d,%Y'));
Note:...
How to maximize frame or window in Java (JFrame)
There are multiple ways but I recommend these lines of code:
GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
Frame fr= new Frame();
fr.setMaximizedBounds(e.getMaximumWindowBounds());
fr.setExtendedState(main.getExtendedState() | JFrame.MAXIMIZED_BOTH);
fr.setVisible(true);
The...