Añado los fuentes de java
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package com.tarisan.chipcard.gui;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author jjrider
|
||||
*
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class UtilGUI {
|
||||
|
||||
// Center a dialog on screen
|
||||
public static void centerDialog(Window frame) {
|
||||
Dimension dialogSize = frame.getSize();
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
frame.setLocation(screenSize.width/2 - dialogSize.width/2,
|
||||
screenSize.height/2 - dialogSize.height/2);
|
||||
}
|
||||
|
||||
public static void centerOnWindow(Window dialog, Window frame){
|
||||
if(dialog==null)
|
||||
return;
|
||||
if(frame==null)
|
||||
return;
|
||||
Dimension dimDialog=dialog.getSize();
|
||||
Dimension dimFrame=frame.getSize();
|
||||
/*int intFrameX=frame.getX();
|
||||
int intFrameY=frame.getY();*/
|
||||
int distanceWidth=dimFrame.width-dimDialog.width;
|
||||
distanceWidth=distanceWidth/2;
|
||||
int distanceHeight=dimFrame.height-dimDialog.height;
|
||||
distanceHeight=distanceHeight/2;
|
||||
dialog.setBounds(frame.getX()+distanceWidth,frame.getY()+distanceHeight,dimDialog.width,dimDialog.height);
|
||||
}
|
||||
|
||||
public static void centerOnScreen(Window dialog){
|
||||
if(dialog==null)
|
||||
return;
|
||||
Dimension dimFrame=java.awt.Toolkit.getDefaultToolkit().getScreenSize();
|
||||
Dimension dimDialog=dialog.getSize();
|
||||
int distanceWidth=dimFrame.width-dimDialog.width;
|
||||
distanceWidth=distanceWidth/2;
|
||||
int distanceHeight=dimFrame.height-dimDialog.height;
|
||||
distanceHeight=distanceHeight/2;
|
||||
dialog.setBounds(distanceWidth,distanceHeight,dimDialog.width,dimDialog.height);
|
||||
}
|
||||
|
||||
public static Icon getIconForType(int iconType) {
|
||||
try{
|
||||
switch (iconType) {
|
||||
case JOptionPane.ERROR_MESSAGE:
|
||||
return UIManager.getIcon("OptionPane.errorIcon");
|
||||
case JOptionPane.INFORMATION_MESSAGE:
|
||||
return UIManager.getIcon("OptionPane.informationIcon");
|
||||
case JOptionPane.WARNING_MESSAGE:
|
||||
return UIManager.getIcon("OptionPane.warningIcon");
|
||||
case JOptionPane.QUESTION_MESSAGE:
|
||||
return UIManager.getIcon("OptionPane.questionIcon");
|
||||
}
|
||||
}catch(Exception err){}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getInputValue(Component parentComponent,Object message){
|
||||
return JOptionPane.showInputDialog(parentComponent,message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user