FileDocCategorySizeDatePackage
LogFactor5Dialog.javaAPI DocApache log4j 1.2.155169Sat Aug 25 00:09:38 BST 2007org.apache.log4j.lf5.viewer

LogFactor5Dialog

public abstract class LogFactor5Dialog extends JDialog
LogFactor5Dialog
author
Richard Hurst
author
Brad Marlborough

Fields Summary
protected static final Font
DISPLAY_FONT
Constructors Summary
protected LogFactor5Dialog(JFrame jframe, String message, boolean modal)

  //--------------------------------------------------------------------------
  //   Protected Variables:
  //--------------------------------------------------------------------------

  //--------------------------------------------------------------------------
  //   Private Variables:
  //--------------------------------------------------------------------------

  //--------------------------------------------------------------------------
  //   Constructors:
  //--------------------------------------------------------------------------
         
    super(jframe, message, modal);
  
Methods Summary
protected voidcenterWindow(java.awt.Window win)

    Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();

    // If larger than screen, reduce window width or height
    if (screenDim.width < win.getSize().width) {
      win.setSize(screenDim.width, win.getSize().height);
    }

    if (screenDim.height < win.getSize().height) {
      win.setSize(win.getSize().width, screenDim.height);
    }

    // Center Frame, Dialogue or Window on screen
    int x = (screenDim.width - win.getSize().width) / 2;
    int y = (screenDim.height - win.getSize().height) / 2;
    win.setLocation(x, y);
  
protected java.awt.GridBagConstraintsgetDefaultConstraints()

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.gridheight = 1; // One row high
    // Insets() args are top, left, bottom, right
    constraints.insets = new Insets(4, 4, 4, 4);
    // fill of NONE means do not change size
    constraints.fill = GridBagConstraints.NONE;
    // WEST means align left
    constraints.anchor = GridBagConstraints.WEST;

    return constraints;
  
protected voidminimumSizeDialog(java.awt.Component component, int minWidth, int minHeight)

    // set the min width
    if (component.getSize().width < minWidth)
      component.setSize(minWidth, component.getSize().height);
    // set the min height
    if (component.getSize().height < minHeight)
      component.setSize(component.getSize().width, minHeight);
  
public voidshow()

    pack();
    minimumSizeDialog(this, 200, 100);
    centerWindow(this);
    super.show();
  
protected voidwrapStringOnPanel(java.lang.String message, java.awt.Container container)

    GridBagConstraints c = getDefaultConstraints();
    c.gridwidth = GridBagConstraints.REMAINDER;
    // Insets() args are top, left, bottom, right
    c.insets = new Insets(0, 0, 0, 0);
    GridBagLayout gbLayout = (GridBagLayout) container.getLayout();


    while (message.length() > 0) {
      int newLineIndex = message.indexOf('\n");
      String line;
      if (newLineIndex >= 0) {
        line = message.substring(0, newLineIndex);
        message = message.substring(newLineIndex + 1);
      } else {
        line = message;
        message = "";
      }
      Label label = new Label(line);
      label.setFont(DISPLAY_FONT);
      gbLayout.setConstraints(label, c);
      container.add(label);
    }