Java 类java.awt.HeadlessException 实例源码
项目:OpenJSharp
文件:InputMethodContext.java
static Window createInputMethodWindow(String title, InputContext context, boolean isSwing) {
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
if (isSwing) {
return new InputMethodJFrame(title, context);
} else {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof InputMethodSupport) {
return ((InputMethodSupport)toolkit).createInputMethodWindow(
title, context);
}
}
throw new InternalError("Input methods must be supported");
}
项目:openjdk-jdk10
文件:R2303044ListSelection.java
public static void main(final String[] args) throws HeadlessException {
final Frame frame = new Frame("Test Frame");
final List list = new List();
frame.setSize(300, 200);
list.add(ITEM_NAME);
list.select(0);
frame.add(list);
frame.validate();
frame.setVisible(true);
sleep();
if (!ITEM_NAME.equals(list.getSelectedItem())) {
throw new RuntimeException("List item not selected item.");
}
list.removeAll();
frame.dispose();
}
项目:jdk8u-jdk
文件:JOptionPane.java
private JDialog createDialog(Component parentComponent, String title,
int style)
throws HeadlessException {
final JDialog dialog;
Window window = JOptionPane.getWindowForComponent(parentComponent);
if (window instanceof Frame) {
dialog = new JDialog((Frame)window, title, true);
} else {
dialog = new JDialog((Dialog)window, title, true);
}
if (window instanceof SwingUtilities.SharedOwnerFrame) {
WindowListener ownerShutdownListener =
SwingUtilities.getSharedOwnerFrameShutdownListener();
dialog.addWindowListener(ownerShutdownListener);
}
initDialog(dialog, style, parentComponent);
return dialog;
}
项目:openjdk-jdk10
文件:WindowResizingOnDPIChangingTest.java
public TestFrame(int width, int height, boolean undecorated) throws HeadlessException {
super("Test Frame. Undecorated: " + undecorated);
setSize(width, height);
mrImage = new TestMultiResolutionImage(width, height);
setUndecorated(undecorated);
Panel panel = new Panel(new FlowLayout()) {
@Override
public void paint(Graphics g) {
super.paint(g);
AffineTransform tx = ((Graphics2D) g).getTransform();
mrImage.scaleX = tx.getScaleX();
mrImage.scaleY = tx.getScaleY();
Insets insets = getInsets();
g.drawImage(mrImage, insets.left, insets.bottom, null);
}
};
add(panel);
}
项目:Cognizant-Intelligent-Test-Scripter
文件:TMSettingsControl.java
private static AbstractAction getEncryptAction(final JTable table) {
return new AbstractAction() {
@Override
public void actionPerformed(ActionEvent me) {
try {
int col = table.getSelectedColumn();
int row = table.getSelectedRow();
if (col > -1 && row > -1) {
String data = table.getValueAt(row, col).toString();
table.setValueAt(TMIntegration.encrypt(data), row, col);
}
} catch (HeadlessException ex) {
Logger.getLogger(TMSettingsControl.class.getName())
.log(Level.SEVERE, ex.getMessage(), ex);
}
}
};
}
项目:steller
文件:TokoEditorForm1.java
private void btn_deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_deleteActionPerformed
// untuk table delete.
try {
String sql = "DELETE FROM Product WHERE Prod_id ='" + txt_idProduct.getText() + "'";
java.sql.Connection conn = (java.sql.Connection) apsari.Koneksi.koneksiDB();
java.sql.PreparedStatement pst = conn.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(null, "Data akan dihapus?");
databaru = true;
//kosongkan editor kiri
txt_idProduct.setText("");
txt_namaProduct.setText("");
txt_hargaProduct.setText("");
} catch (SQLException | HeadlessException e) {
}
GetData();
}
项目:twainBDirect
文件:AppScannerInterface.java
public AppScannerInterface() {
super();
initialize();
try {
scanner = Scanner.getDevice();
//--
if (BoshScan.verifyAndInitComponets(scanner)) {
boshScanListener = new BoshScanListener();
//--
scanner.addListener(boshScanListener);
} else {
JOptionPane.showMessageDialog(null, "No cumple con los requerimientos necesarios para \nusar twain4J", "Error", JOptionPane.ERROR_MESSAGE);
}
//--
} catch (HeadlessException e) {
System.out.println(e.getMessage());
}
}
项目:openjdk-jdk10
文件:JOptionPane.java
private JDialog createDialog(Component parentComponent, String title,
int style)
throws HeadlessException {
final JDialog dialog;
Window window = JOptionPane.getWindowForComponent(parentComponent);
if (window instanceof Frame) {
dialog = new JDialog((Frame)window, title, true);
} else {
dialog = new JDialog((Dialog)window, title, true);
}
if (window instanceof SwingUtilities.SharedOwnerFrame) {
WindowListener ownerShutdownListener =
SwingUtilities.getSharedOwnerFrameShutdownListener();
dialog.addWindowListener(ownerShutdownListener);
}
initDialog(dialog, style, parentComponent);
return dialog;
}
项目:RA-Reader
文件:RegisterAuszugGUI.java
private void btn_saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_saveActionPerformed
try {
JFileChooser jfc = new JFileChooser();
jfc.setDialogTitle("Registerauszug speichern");
jfc.setFileFilter(new FileNameExtensionFilter("TEXT FILES", "txt", "text"));
if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
File f = jfc.getSelectedFile();
FileWriter fw = new FileWriter(f);
BufferedWriter bw = new BufferedWriter(fw);
DataSetter ds = new DataSetter();
ds.writeToFile(bw, it);
}
} catch (HeadlessException | IOException e) {
JOptionPane.showMessageDialog(this, "Error: IO");
}
}
项目:jaer
文件:ImageCreatorSlave.java
/**
* @param savingImage the savingImage to set
*/
public void setSavingImage(boolean savingImage) {
if (savingImage == true) {
try {
// Repeat the SavingImageTask without delay and with 5000ms between executions
JFileChooser f = new JFileChooser();
f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int state = f.showSaveDialog(null);
if (state == JFileChooser.APPROVE_OPTION) {
savingImageTimer = new java.util.Timer();
savingImageTimer.scheduleAtFixedRate(new SaveImageTask(f.getSelectedFile()), 0, 5000);
}
} catch (HeadlessException e) {//Catch exception if any
log.warning("Error: " + e.getMessage());
}
} else {
savingImageTimer.cancel();
savingImageTimer = null;
}
this.savingImage = savingImage;
}
项目:jdk8u-jdk
文件:R2303044ListSelection.java
public static void main(final String[] args) throws HeadlessException {
final Frame frame = new Frame("Test Frame");
final List list = new List();
frame.setSize(300, 200);
list.add(ITEM_NAME);
list.select(0);
frame.add(list);
frame.validate();
frame.setVisible(true);
sleep();
if (!ITEM_NAME.equals(list.getSelectedItem())) {
throw new RuntimeException("List item not selected item.");
}
list.removeAll();
frame.dispose();
}
项目:OpenJSharp
文件:Desktop.java
/**
* Returns the <code>Desktop</code> instance of the current
* browser context. On some platforms the Desktop API may not be
* supported; use the {@link #isDesktopSupported} method to
* determine if the current desktop is supported.
* @return the Desktop instance of the current browser context
* @throws HeadlessException if {@link
* GraphicsEnvironment#isHeadless()} returns {@code true}
* @throws UnsupportedOperationException if this class is not
* supported on the current platform
* @see #isDesktopSupported()
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public static synchronized Desktop getDesktop(){
if (GraphicsEnvironment.isHeadless()) throw new HeadlessException();
if (!Desktop.isDesktopSupported()) {
throw new UnsupportedOperationException("Desktop API is not " +
"supported on the current platform");
}
sun.awt.AppContext context = sun.awt.AppContext.getAppContext();
Desktop desktop = (Desktop)context.get(Desktop.class);
if (desktop == null) {
desktop = new Desktop();
context.put(Desktop.class, desktop);
}
return desktop;
}
项目:alevin-svn2
文件:LocatableFileChooser.java
@Override
public int showOpenDialog(Component parent) throws HeadlessException {
int ret = super.showOpenDialog(parent);
if (ret == APPROVE_OPTION)
update();
return ret;
}
项目:alevin-svn2
文件:LocatableFileChooser.java
@Override
public int showSaveDialog(Component parent) throws HeadlessException {
int ret = super.showSaveDialog(parent);
if (ret == APPROVE_OPTION)
update();
return ret;
}
项目:incubator-netbeans
文件:HintsUI.java
private Rectangle getScreenBounds() throws HeadlessException {
Rectangle virtualBounds = new Rectangle();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
if (gs.length == 0 || gs.length == 1) {
return new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
}
for (GraphicsDevice gd : gs) {
virtualBounds = virtualBounds.union(gd.getDefaultConfiguration().getBounds());
}
return virtualBounds;
}
项目:incubator-netbeans
文件:DecorableTest.java
static private ColorModel colorModel(int transparency) {
ColorModel model;
try {
model = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration()
.getColorModel(transparency);
}
catch(HeadlessException he) {
model = ColorModel.getRGBdefault();
}
return model;
}
项目:incubator-netbeans
文件:ImageUtilities.java
static private ColorModel colorModel(int transparency) {
ColorModel model;
try {
model = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration()
.getColorModel(transparency);
}
catch(ArrayIndexOutOfBoundsException aioobE) {
//#226279
model = ColorModel.getRGBdefault();
} catch(HeadlessException he) {
model = ColorModel.getRGBdefault();
}
return model;
}
项目:incubator-netbeans
文件:UtilitiesTest.java
protected CheckboxPeer createCheckbox(Checkbox target) throws HeadlessException {
throw new IllegalStateException("Method not implemented");
}
项目:etomica
文件:GraphMap.java
@Override
public int showSaveDialog(Component component) throws HeadlessException {
int result = super.showSaveDialog(component);
if (result == JFileChooser.APPROVE_OPTION) {
File sf = getSelectedFile();
String ext = SVGFileFilter.getExtension(sf);
String fext = ((SVGFileFilter) getFileFilter()).getExtension();
if ((ext == null) || (!ext.equals(fext))) {
File nsf = new File(sf.getAbsolutePath() + "." + fext);
setSelectedFile(nsf);
}
}
return result;
}
项目:incubator-netbeans
文件:FileChooserBuilder.java
@Override
public int showDialog(Component parent, String approveButtonText) throws HeadlessException {
int result = super.showDialog(parent, approveButtonText);
if (result == APPROVE_OPTION) {
saveCurrentDir();
}
return result;
}
项目:openjdk-jdk10
文件:HeadlessJApplet.java
public static void main(String args[]) {
boolean exceptions = false;
try {
new JApplet();
} catch (HeadlessException e) {
exceptions = true;
}
if (!exceptions)
throw new RuntimeException("HeadlessException did not occur when expected");
}
项目:incubator-netbeans
文件:UndoRedoAction.java
static void cannotUndoRedo(RuntimeException ex) throws MissingResourceException, HeadlessException {
if (ex.getMessage() != null) {
JOptionPane.showMessageDialog(
WindowManager.getDefault().getMainWindow(),
ex.getMessage(),
NbBundle.getMessage(UndoRedoAction.class, ex instanceof CannotUndoException ? "LBL_CannotUndo" : "LBL_CannotRedo"),
JOptionPane.ERROR_MESSAGE);
}
}
项目:NativeJFileChooser
文件:NativeJFileChooser.java
@Override
public int showSaveDialog(Component parent) throws HeadlessException {
if (!FX_AVAILABLE) {
return super.showSaveDialog(parent);
}
final CountDownLatch latch = new CountDownLatch(1);
Platform.runLater(new Runnable() {
@Override
public void run() {
// parent.setEnabled(false);
if (isDirectorySelectionEnabled()) {
currentFile = directoryChooser.showDialog(null);
} else {
currentFile = fileChooser.showSaveDialog(null);
}
latch.countDown();
// parent.setEnabled(true);
}
});
try {
latch.await();
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
if (currentFile != null) {
return JFileChooser.APPROVE_OPTION;
} else {
return JFileChooser.CANCEL_OPTION;
}
}
项目:Cognizant-Intelligent-Test-Scripter
文件:Utils.java
private static JFileChooser createFileChooser() {
JFileChooser jf = new JFileChooser() {
@Override
protected JDialog createDialog(Component parent) throws HeadlessException {
JDialog dialog = super.createDialog(parent);
dialog.setIconImage(getFavIcon());
return dialog;
}
};
return jf;
}
项目:java_mooc_fi
文件:HangmanUserInterface.java
public HangmanUserInterface(HangmanLogic logiikka) throws HeadlessException {
super();
setTitle("Hangman");
this.figure = new HangmanFigure(logiikka, this);
add(this.figure);
addKeyListener(new HirsipuuKeyAdapter(logiikka));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 400);
}
项目:openjdk-jdk10
文件:WindowResizingOnSetLocationTest.java
public TestFrame(GraphicsConfiguration gc, Rectangle rect) throws HeadlessException {
super(gc);
setBounds(rect);
mrImage = new TestMultiResolutionImage(rect.width, rect.height);
JPanel panel = new JPanel(new FlowLayout()) {
@Override
public void paint(Graphics g) {
super.paint(g);
AffineTransform tx = ((Graphics2D) g).getTransform();
mrImage.scaleX = tx.getScaleX();
mrImage.scaleY = tx.getScaleY();
Insets insets = getInsets();
g.drawImage(mrImage, insets.left, insets.bottom, null);
}
};
JButton button = new JButton("Move to another display");
button.addActionListener((e) -> {
GraphicsConfiguration config = getGraphicsConfiguration();
GraphicsDevice[] devices = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getScreenDevices();
int index = devices[screen1].getDefaultConfiguration().equals(config)
? screen2 : screen1;
Rectangle r = getCenterRect(screenBounds[index]);
frame.setBounds(r);
});
panel.add(button);
add(panel);
}
项目:JDigitalSimulator
文件:Guitilities.java
public static Dimension getActualSize(Frame frame) {
try {
int extendedState = frame.getExtendedState();
java.awt.Rectangle bounds = frame.getMaximizedBounds(), systemBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
return new Dimension((extendedState&Frame.MAXIMIZED_HORIZ)==Frame.MAXIMIZED_HORIZ?(bounds!=null&&bounds.width !=Integer.MAX_VALUE?bounds.width :systemBounds.width ):frame.getWidth(),
(extendedState&Frame.MAXIMIZED_VERT) ==Frame.MAXIMIZED_VERT ?(bounds!=null&&bounds.height!=Integer.MAX_VALUE?bounds.height:systemBounds.height):frame.getHeight());
} catch(HeadlessException e) { return frame.getSize(); }
}
项目:HR-Management-System-in-Java-using-swing-framework
文件:AddNewLogin.java
private void SaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveActionPerformed
try {
LoginHandling.save(getData());
JOptionPane.showMessageDialog(null,"Record Saved.");
}catch (HeadlessException e) {
JOptionPane.showMessageDialog(null, "Not Saved something went wrong.");
}
}
项目:steller
文件:FrmDataDiri.java
public void insertCustomer() {
try { // for adding new data
String sql = " UPDATE Customer SET First_name = ' " + text_namaAwal.getText() + " ' , Last_name = ' " + text_namaAkhir.getText() + " ' , Email_address = ' " + text_email.getText() + " ' WHERE Cust_id = "+strCust_id+" ;";
java.sql.Connection conn = (java.sql.Connection) apsari.Koneksi.koneksiDB();
java.sql.PreparedStatement pst = conn.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(null, "Data diri anda berhasil disimpan");
} catch (SQLException | HeadlessException e) {
JOptionPane.showMessageDialog(null, e);
}
}
项目:openjdk-jdk10
文件:InputMethodContext.java
static Window createInputMethodWindow(String title, InputContext context, boolean isSwing) {
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
if (isSwing) {
return new InputMethodJFrame(title, context);
} else {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof InputMethodSupport) {
return ((InputMethodSupport)toolkit).createInputMethodWindow(
title, context);
}
}
throw new InternalError("Input methods must be supported");
}
项目:jdk8u-jdk
文件:DropTarget.java
/**
* Creates a new DropTarget given the <code>Component</code>
* to associate itself with, an <code>int</code> representing
* the default acceptable action(s) to
* support, a <code>DropTargetListener</code>
* to handle event processing, a <code>boolean</code> indicating
* if the <code>DropTarget</code> is currently accepting drops, and
* a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
* <P>
* The Component will receive drops only if it is enabled.
* @param c The <code>Component</code> with which this <code>DropTarget</code> is associated
* @param ops The default acceptable actions for this <code>DropTarget</code>
* @param dtl The <code>DropTargetListener</code> for this <code>DropTarget</code>
* @param act Is the <code>DropTarget</code> accepting drops.
* @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public DropTarget(Component c, int ops, DropTargetListener dtl,
boolean act, FlavorMap fm)
throws HeadlessException
{
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
component = c;
setDefaultActions(ops);
if (dtl != null) try {
addDropTargetListener(dtl);
} catch (TooManyListenersException tmle) {
// do nothing!
}
if (c != null) {
c.setDropTarget(this);
setActive(act);
}
if (fm != null) {
flavorMap = fm;
} else {
flavorMap = SystemFlavorMap.getDefaultFlavorMap();
}
}
项目:LogiGSK
文件:LogiGSKService.java
private static boolean isReallyHeadless() {
if (GraphicsEnvironment.isHeadless()) {
//return true;
}
try {
GraphicsDevice[] screenDevices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
return screenDevices == null || screenDevices.length == 0;
} catch (HeadlessException e) {
System.err.print(e);
return true;
}
}
项目:genetic-algorithm
文件:DisplayWindow.java
public DisplayWindow(int width, int height) throws HeadlessException{
super("Zombie Shooter");
this.width = width;
this.height = height;
setSize(600,600);
drawArea = new DrawArea(600,600);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setContentPane(drawArea);
setVisible(true);
}
项目:jdk8u-jdk
文件:InputMethodContext.java
static Window createInputMethodWindow(String title, InputContext context, boolean isSwing) {
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
if (isSwing) {
return new InputMethodJFrame(title, context);
} else {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit instanceof InputMethodSupport) {
return ((InputMethodSupport)toolkit).createInputMethodWindow(
title, context);
}
}
throw new InternalError("Input methods must be supported");
}
项目:incubator-netbeans
文件:UtilitiesTest.java
protected TextFieldPeer createTextField(TextField target) throws HeadlessException {
throw new IllegalStateException("Method not implemented");
}
项目:incubator-netbeans
文件:UtilitiesTest.java
protected ListPeer createList(java.awt.List target) throws HeadlessException {
throw new IllegalStateException("Method not implemented");
}
项目:incubator-netbeans
文件:UtilitiesTest.java
protected MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException {
throw new IllegalStateException("Method not implemented");
}
项目:incubator-netbeans
文件:UtilitiesTest.java
protected PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException {
throw new IllegalStateException("Method not implemented");
}
项目:incubator-netbeans
文件:UtilitiesTest.java
protected MenuItemPeer createMenuItem(MenuItem target) throws HeadlessException {
throw new IllegalStateException("Method not implemented");
}
项目:incubator-netbeans
文件:UtilitiesTest.java
public Map mapInputMethodHighlight(InputMethodHighlight highlight) throws HeadlessException {
return Toolkit.getDefaultToolkit().mapInputMethodHighlight( highlight );
}