use of java.awt.Container in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method printTexture.
private static void printTexture() {
f = new JFrame("Texture Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
use of java.awt.Container in project jdk8u_jdk by JetBrains.
the class LinearGradientPrintingTest method createUI.
public static void createUI() {
f = new JFrame("LinearGradient Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final LinearGradientPrintingTest gpt = new LinearGradientPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
use of java.awt.Container in project pcgen by PCGen.
the class PrintPreviewDialog method initLayout.
private void initLayout() {
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
{
//layout top bar
JPanel bar = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.BASELINE;
gbc.insets = new Insets(8, 6, 8, 2);
bar.add(new JLabel("Select Template:"), gbc);
gbc.insets = new Insets(8, 2, 8, 6);
gbc.weightx = 1;
bar.add(sheetBox, gbc);
pane.add(bar, BorderLayout.NORTH);
}
{
Box vbox = Box.createVerticalBox();
previewPanelParent.setPreferredSize(new Dimension(600, 800));
vbox.add(previewPanelParent);
vbox.add(progressBar);
pane.add(vbox, BorderLayout.CENTER);
}
{
Box hbox = Box.createHorizontalBox();
hbox.add(new JLabel("Page:"));
hbox.add(Box.createHorizontalStrut(4));
hbox.add(pageBox);
hbox.add(Box.createHorizontalStrut(10));
hbox.add(new JLabel("Zoom:"));
hbox.add(Box.createHorizontalStrut(4));
hbox.add(zoomBox);
hbox.add(Box.createHorizontalStrut(5));
hbox.add(zoomInButton);
hbox.add(Box.createHorizontalStrut(5));
hbox.add(zoomOutButton);
hbox.add(Box.createHorizontalGlue());
hbox.add(printButton);
hbox.add(Box.createHorizontalStrut(5));
hbox.add(cancelButton);
hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
pane.add(hbox, BorderLayout.SOUTH);
}
}
use of java.awt.Container in project pcgen by PCGen.
the class CharacterHPDialog method initComponents.
private void initComponents() {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
JTable table = new JTable(tableModel) {
@Override
public TableCellEditor getCellEditor(int row, int column) {
if (column == 5) {
//TODO: the max roll should be calculated in a different manner
String hd = levels.getClassTaken(levels.getElementAt(row)).getHD();
int max = NumberUtils.toInt(hd);
return new IntegerEditor(1, max);
} else {
return super.getCellEditor(row, column);
}
}
};
table.setDefaultRenderer(JButton.class, new Renderer());
table.setDefaultEditor(JButton.class, new Editor());
table.setCellSelectionEnabled(false);
table.setRowHeight(new IntegerEditor(1, 10).getPreferredSize().height);
JTableHeader header = table.getTableHeader();
header.setReorderingAllowed(false);
JScrollPane scrollPane = new JScrollPane(table);
pane.add(scrollPane, BorderLayout.CENTER);
Box box = Box.createHorizontalBox();
box.add(new JLabel("Total Hp:"));
box.add(Box.createHorizontalStrut(3));
final ReferenceListener<Integer> hpListener = new ReferenceListener<Integer>() {
@Override
public void referenceChanged(ReferenceEvent<Integer> e) {
totalHp.setText(e.getNewReference().toString());
}
};
ReferenceFacade<Integer> hpRef = character.getTotalHPRef();
totalHp.setText(hpRef.get().toString());
hpRef.addReferenceListener(hpListener);
box.add(totalHp);
box.add(Box.createHorizontalStrut(5));
JButton button = new JButton("Reroll All");
button.setActionCommand("Reroll");
button.addActionListener(this);
box.add(button);
box.add(Box.createHorizontalGlue());
button = new JButton("Close");
button.setActionCommand("Close");
button.addActionListener(this);
box.add(button);
pane.add(box, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
//Make sure to remove the listeners so that the garbage collector can
//dispose of this dialog and prevent a memory leak
levels.removeHitPointListener(tableModel);
character.getTotalHPRef().removeReferenceListener(hpListener);
}
});
Utility.installEscapeCloseOperation(this);
}
use of java.awt.Container in project pcgen by PCGen.
the class ChooserDialog method initComponents.
private void initComponents() {
setTitle(chooser.getName());
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
//detach listeners from the chooser
treeViewModel.setDelegate(null);
listModel.setListFacade(null);
chooser.getRemainingSelections().removeReferenceListener(ChooserDialog.this);
}
});
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
JSplitPane split = new JSplitPane();
JPanel leftPane = new JPanel(new BorderLayout());
if (availTable != null) {
availTable.setAutoCreateRowSorter(true);
availTable.setTreeViewModel(treeViewModel);
availTable.getRowSorter().toggleSortOrder(0);
availTable.addActionListener(this);
leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER);
} else {
availInput.addActionListener(this);
Dimension maxDim = new Dimension(Integer.MAX_VALUE, availInput.getPreferredSize().height);
availInput.setMaximumSize(maxDim);
JPanel availPanel = new JPanel();
availPanel.setLayout(new BoxLayout(availPanel, BoxLayout.PAGE_AXIS));
availPanel.add(Box.createRigidArea(new Dimension(10, 30)));
availPanel.add(Box.createVerticalGlue());
availPanel.add(new JLabel(LanguageBundle.getString("in_uichooser_value")));
availPanel.add(availInput);
availPanel.add(Box.createVerticalGlue());
leftPane.add(availPanel, BorderLayout.WEST);
}
JPanel buttonPane1 = new JPanel(new FlowLayout());
JButton addButton = new JButton(chooser.getAddButtonName());
addButton.setActionCommand("ADD");
addButton.addActionListener(this);
buttonPane1.add(addButton);
buttonPane1.add(new JLabel(Icons.Forward16.getImageIcon()));
leftPane.add(buttonPane1, BorderLayout.SOUTH);
split.setLeftComponent(leftPane);
JPanel rightPane = new JPanel(new BorderLayout());
JPanel labelPane = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
labelPane.add(new JLabel(chooser.getSelectionCountName()), new GridBagConstraints());
remainingLabel.setText(chooser.getRemainingSelections().get().toString());
labelPane.add(remainingLabel, gbc);
labelPane.add(new JLabel(chooser.getSelectedTableTitle()), gbc);
rightPane.add(labelPane, BorderLayout.NORTH);
list.setModel(listModel);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addActionListener(this);
rightPane.add(new JScrollPane(list), BorderLayout.CENTER);
JPanel buttonPane2 = new JPanel(new FlowLayout());
buttonPane2.add(new JLabel(Icons.Back16.getImageIcon()));
JButton removeButton = new JButton(chooser.getRemoveButtonName());
removeButton.setActionCommand("REMOVE");
removeButton.addActionListener(this);
buttonPane2.add(removeButton);
rightPane.add(buttonPane2, BorderLayout.SOUTH);
split.setRightComponent(rightPane);
if (chooser.isInfoAvailable()) {
JSplitPane infoSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
infoSplit.setTopComponent(split);
infoSplit.setBottomComponent(infoPane);
infoSplit.setResizeWeight(0.8);
pane.add(infoSplit, BorderLayout.CENTER);
if (availTable != null) {
availTable.getSelectionModel().addListSelectionListener(this);
}
} else {
pane.add(split, BorderLayout.CENTER);
}
JPanel bottomPane = new JPanel(new FlowLayout());
//$NON-NLS-1$
JButton button = new JButton(LanguageBundle.getString("in_ok"));
//$NON-NLS-1$
button.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok"));
button.setActionCommand("OK");
button.addActionListener(this);
bottomPane.add(button);
//$NON-NLS-1$
button = new JButton(LanguageBundle.getString("in_cancel"));
//$NON-NLS-1$
button.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel"));
button.setActionCommand("CANCEL");
button.addActionListener(this);
bottomPane.add(button);
pane.add(bottomPane, BorderLayout.SOUTH);
}
Aggregations