本文整理汇总了Java中java.awt.HeadlessException类的典型用法代码示例。如果您正苦于以下问题:Java HeadlessException类的具体用法?Java HeadlessException怎么用?Java HeadlessException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HeadlessException类属于java.awt包,在下文中一共展示了HeadlessException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInputMethodWindow
import java.awt.HeadlessException; //导入依赖的package包/类
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");
}
示例2: main
import java.awt.HeadlessException; //导入依赖的package包/类
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();
}
示例3: createDialog
import java.awt.HeadlessException; //导入依赖的package包/类
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;
}
示例4: TestFrame
import java.awt.HeadlessException; //导入依赖的package包/类
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);
}
示例5: getEncryptAction
import java.awt.HeadlessException; //导入依赖的package包/类
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);
}
}
};
}
示例6: btn_deleteActionPerformed
import java.awt.HeadlessException; //导入依赖的package包/类
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();
}
示例7: AppScannerInterface
import java.awt.HeadlessException; //导入依赖的package包/类
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());
}
}
示例8: btn_saveActionPerformed
import java.awt.HeadlessException; //导入依赖的package包/类
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");
}
}
示例9: setSavingImage
import java.awt.HeadlessException; //导入依赖的package包/类
/**
* @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;
}
示例10: getDesktop
import java.awt.HeadlessException; //导入依赖的package包/类
/**
* 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;
}
示例11: showOpenDialog
import java.awt.HeadlessException; //导入依赖的package包/类
@Override
public int showOpenDialog(Component parent) throws HeadlessException {
int ret = super.showOpenDialog(parent);
if (ret == APPROVE_OPTION)
update();
return ret;
}
示例12: showSaveDialog
import java.awt.HeadlessException; //导入依赖的package包/类
@Override
public int showSaveDialog(Component parent) throws HeadlessException {
int ret = super.showSaveDialog(parent);
if (ret == APPROVE_OPTION)
update();
return ret;
}
示例13: getScreenBounds
import java.awt.HeadlessException; //导入依赖的package包/类
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;
}
示例14: colorModel
import java.awt.HeadlessException; //导入依赖的package包/类
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;
}
示例15: colorModel
import java.awt.HeadlessException; //导入依赖的package包/类
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;
}