use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class Font2DTest method main.
/// Main function
public static void main(String[] argv) {
if (argv.length > 0) {
if (argv[0].equalsIgnoreCase("-disablecandisplaycheck") || argv[0].equalsIgnoreCase("-dcdc")) {
canDisplayCheck = false;
} else {
printUsage();
}
}
UIManager.put("swing.boldMetal", Boolean.FALSE);
final JFrame f = new JFrame("Font2DTest");
final Font2DTest f2dt = new Font2DTest(f, false);
f.addWindowListener(new WindowAdapter() {
public void windowOpening(WindowEvent e) {
f2dt.repaint();
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.getContentPane().add(f2dt);
f.pack();
f.show();
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class WChoicePeer method initialize.
@Override
@SuppressWarnings("deprecation")
void initialize() {
Choice opt = (Choice) target;
int itemCount = opt.getItemCount();
if (itemCount > 0) {
String[] items = new String[itemCount];
for (int i = 0; i < itemCount; i++) {
items[i] = opt.getItem(i);
}
addItems(items, 0);
if (opt.getSelectedIndex() >= 0) {
select(opt.getSelectedIndex());
}
}
Window parentWindow = SunToolkit.getContainingWindow((Component) target);
if (parentWindow != null) {
WWindowPeer wpeer = (WWindowPeer) parentWindow.getPeer();
if (wpeer != null) {
windowListener = new WindowAdapter() {
@Override
public void windowIconified(WindowEvent e) {
closeList();
}
@Override
public void windowClosing(WindowEvent e) {
closeList();
}
};
wpeer.addWindowListener(windowListener);
}
}
super.initialize();
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class ServiceDialog method initPageDialog.
/**
* Initialize "page setup" dialog
*/
void initPageDialog(int x, int y, PrintService ps, DocFlavor flavor, PrintRequestAttributeSet attributes) {
this.psCurrent = ps;
this.docFlavor = flavor;
this.asOriginal = attributes;
this.asCurrent = new HashPrintRequestAttributeSet(attributes);
if (attributes.get(DialogOnTop.class) != null) {
setAlwaysOnTop(true);
}
Container c = getContentPane();
c.setLayout(new BorderLayout());
pnlPageSetup = new PageSetupPanel();
c.add(pnlPageSetup, BorderLayout.CENTER);
pnlPageSetup.updateInfo();
JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
btnApprove = createExitButton("button.ok", this);
pnlSouth.add(btnApprove);
getRootPane().setDefaultButton(btnApprove);
btnCancel = createExitButton("button.cancel", this);
handleEscKey(btnCancel);
pnlSouth.add(btnCancel);
c.add(pnlSouth, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
dispose(CANCEL);
}
});
getAccessibleContext().setAccessibleDescription(getMsg("dialog.pstitle"));
setResizable(false);
setLocation(x, y);
pack();
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class ServiceDialog method initPrintDialog.
/**
* Initialize print dialog.
*/
void initPrintDialog(int x, int y, PrintService[] services, int defaultServiceIndex, DocFlavor flavor, PrintRequestAttributeSet attributes) {
this.services = services;
this.defaultServiceIndex = defaultServiceIndex;
this.asOriginal = attributes;
this.asCurrent = new HashPrintRequestAttributeSet(attributes);
this.psCurrent = services[defaultServiceIndex];
this.docFlavor = flavor;
SunPageSelection pages = (SunPageSelection) attributes.get(SunPageSelection.class);
if (pages != null) {
isAWT = true;
}
if (attributes.get(DialogOnTop.class) != null) {
setAlwaysOnTop(true);
}
Container c = getContentPane();
c.setLayout(new BorderLayout());
tpTabs = new JTabbedPane();
tpTabs.setBorder(new EmptyBorder(5, 5, 5, 5));
String gkey = getMsg("tab.general");
int gmnemonic = getVKMnemonic("tab.general");
pnlGeneral = new GeneralPanel();
tpTabs.add(gkey, pnlGeneral);
tpTabs.setMnemonicAt(0, gmnemonic);
String pkey = getMsg("tab.pagesetup");
int pmnemonic = getVKMnemonic("tab.pagesetup");
pnlPageSetup = new PageSetupPanel();
tpTabs.add(pkey, pnlPageSetup);
tpTabs.setMnemonicAt(1, pmnemonic);
String akey = getMsg("tab.appearance");
int amnemonic = getVKMnemonic("tab.appearance");
pnlAppearance = new AppearancePanel();
tpTabs.add(akey, pnlAppearance);
tpTabs.setMnemonicAt(2, amnemonic);
c.add(tpTabs, BorderLayout.CENTER);
updatePanels();
JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
btnApprove = createExitButton("button.print", this);
pnlSouth.add(btnApprove);
getRootPane().setDefaultButton(btnApprove);
btnCancel = createExitButton("button.cancel", this);
handleEscKey(btnCancel);
pnlSouth.add(btnCancel);
c.add(pnlSouth, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
dispose(CANCEL);
}
});
getAccessibleContext().setAccessibleDescription(getMsg("dialog.printtitle"));
setResizable(false);
setLocation(x, y);
pack();
}
use of java.awt.event.WindowAdapter in project jabref by JabRef.
the class DuplicateResolverDialog method init.
private void init(BibEntry one, BibEntry two, DuplicateResolverType type) {
JButton both;
JButton second;
JButton first;
JButton removeExact = null;
switch(type) {
case DUPLICATE_SEARCH:
first = new JButton(Localization.lang("Keep left"));
second = new JButton(Localization.lang("Keep right"));
both = new JButton(Localization.lang("Keep both"));
me = new MergeEntries(one, two, frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
break;
case INSPECTION:
first = new JButton(Localization.lang("Remove old entry"));
second = new JButton(Localization.lang("Remove entry from import"));
both = new JButton(Localization.lang("Keep both"));
me = new MergeEntries(one, two, Localization.lang("Old entry"), Localization.lang("From import"), frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
break;
case DUPLICATE_SEARCH_WITH_EXACT:
first = new JButton(Localization.lang("Keep left"));
second = new JButton(Localization.lang("Keep right"));
both = new JButton(Localization.lang("Keep both"));
removeExact = new JButton(Localization.lang("Automatically remove exact duplicates"));
me = new MergeEntries(one, two, frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
break;
default:
first = new JButton(Localization.lang("Import and remove old entry"));
second = new JButton(Localization.lang("Do not import entry"));
both = new JButton(Localization.lang("Import and keep old entry"));
me = new MergeEntries(one, two, Localization.lang("Old entry"), Localization.lang("From import"), frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
break;
}
if (removeExact != null) {
options.add(removeExact);
}
options.add(first);
options.add(second);
options.add(both);
options.add(merge);
options.add(Box.createHorizontalStrut(5));
options.add(cancel);
options.add(helpButton);
first.addActionListener(e -> buttonPressed(DuplicateResolverResult.KEEP_LEFT));
second.addActionListener(e -> buttonPressed(DuplicateResolverResult.KEEP_RIGHT));
both.addActionListener(e -> buttonPressed(DuplicateResolverResult.KEEP_BOTH));
merge.addActionListener(e -> buttonPressed(DuplicateResolverResult.KEEP_MERGE));
if (removeExact != null) {
removeExact.addActionListener(e -> buttonPressed(DuplicateResolverResult.AUTOREMOVE_EXACT));
}
cancel.addActionListener(e -> buttonPressed(DuplicateResolverResult.BREAK));
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
buttonPressed(DuplicateResolverResult.BREAK);
}
});
getContentPane().add(me.getMergeEntryPanel());
getContentPane().add(options, BorderLayout.SOUTH);
pack();
WindowLocation pw = new WindowLocation(this, JabRefPreferences.DUPLICATES_POS_X, JabRefPreferences.DUPLICATES_POS_Y, JabRefPreferences.DUPLICATES_SIZE_X, JabRefPreferences.DUPLICATES_SIZE_Y);
pw.displayWindowAtStoredLocation();
both.requestFocus();
}
Aggregations