📄 remindutils.java
字号:
package com.liming.remind.common;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import com.liming.remind.dto.Remind;
/**
* Function : Remind Utils
*
* @author Liming
* @time Dec 17, 2008 8:40:48 PM
* @version 1.0
*/
public class RemindUtils {
/**
* Function : Validate Time pattern
*
* @param time
* @return
*/
public static boolean validateTimePattern(String time) {
// Compile regular expression
Pattern pattern = Pattern
.compile("(([0-1][0-9])|([0-9])|([2][0-3])):(([0-5][0-9])|[0-9])");
Matcher matcher = pattern.matcher(time);
return matcher.matches();
}
/**
* Function : Parse loose time pattern
*
* @param time
* @return
*/
public static String changeToStrictPatter(String time) {
int hour = Integer.parseInt(time.split(":")[0]);
int minute = Integer.parseInt(time.split(":")[1]);
String h = hour < 10 ? "0" + hour : hour + "";
String m = minute < 10 ? "0" + minute : minute + "";
return h + ":" + m;
}
/**
* Function : Generate an id to a new remind
*
* @param list
* @return
*/
public static int getMaxIdFromList(List<Remind> list) {
int maxId = 1;
if (list == null) {
return maxId;
}
int temp;
int listSize = list.size();
for (int i = 0;i < listSize;i++) {
temp = list.get(i).getId();
maxId = maxId > temp ? maxId : temp;
}
return maxId + 1;
}
/**
* Function : Set UI Face to the center of the windows
*
* @param ui
*/
public static void setUIMiddleOfTheWindow(Component ui) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension size = ui.getSize();
ui.setLocation((screenSize.width - size.width) / 2,
(screenSize.height - size.height) / 2);
}
/**
* Function : Get windows LookAndFeel
*
* @param ui
*/
public static void getWindowsLookAndFeel(Component ui) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(ui);
} catch (Exception e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -