1 7 8 package org.gjt.jclasslib.util; 9 10 import javax.swing.*; 11 import java.awt.*; 12 13 19 public class GUIHelper { 20 21 22 public static final String MESSAGE_TITLE = "jclasslib"; 23 24 25 public static final String [] YES_NO_OPTIONS = new String [] {"Yes", "No"}; 26 27 public static final Icon ICON_EMPTY = new EmptyIcon(16, 16); 28 29 37 public static int showOptionDialog(Component parent, String message, String [] options, int messageType) { 38 return JOptionPane.showOptionDialog(parent, 39 message, 40 MESSAGE_TITLE, 41 0, 42 messageType, 43 null, 44 options, 45 options[0]); 46 } 47 48 54 public static void showMessage(Component parent, String message, int messageType) { 55 JOptionPane.showMessageDialog(parent, 56 message, 57 MESSAGE_TITLE, 58 messageType, 59 null); 60 } 61 62 67 public static void centerOnParentWindow(Window window, Window parentWindow) { 68 window.setLocation( 69 parentWindow.getX() + (parentWindow.getWidth() - window.getWidth()) / 2, 70 parentWindow.getY() + (parentWindow.getHeight() - window.getHeight()) / 2 71 ); 72 } 73 74 79 public static void setDefaultScrollbarUnits(JScrollPane scrollPane) { 80 81 int unit = new JLabel().getFont().getSize() * 2; 82 scrollPane.getHorizontalScrollBar().setUnitIncrement(unit); 83 scrollPane.getVerticalScrollBar().setUnitIncrement(unit); 84 } 85 86 } 87 | Popular Tags |