Design Patterns Java™ Workbook

(Michael S) #1
Chapter 4. Facade

y[i] = (int) (4 apogee (t - .5) * (t - .5));
}
return y;
}
}


Most of the code of the main() routine of the initial FlightPanel class migrates to static
methods in the SwingFacade class:


package com.oozinoz.ui;
import javax.swing.;
import javax.swing.border.
;
import java.awt.;
import java.awt.event.
;
public class SwingFacade
{


public static TitledBorder createTitledBorder(
String title)
{
TitledBorder tb =
BorderFactory.createTitledBorder(
BorderFactory.createBevelBorder(
BevelBorder.RAISED),
title,
TitledBorder.LEFT,
TitledBorder.TOP);
tb.setTitleColor(Color.black);
tb.setTitleFont(getStandardFont());
return tb;
}


public static JPanel createTitledPanel(
String title,
JPanel in)
{
JPanel out = new JPanel();
out.add(in);
out.setBorder(createTitledBorder(title));
return out;
}
public static Font getStandardFont()
{
return new Font("Dialog", Font.PLAIN, 18);
}


public static JFrame launch(
Component c,
String title)
{
JFrame frame = new JFrame(title);
frame.getContentPane().add(c);
listen(frame);
frame.pack();
frame.setVisible(true);
return frame;
}

Free download pdf