类java.awt.HeadlessException源码实例Demo

下面列出了怎么用java.awt.HeadlessException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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();
}
 
源代码2 项目: netcdf-java   文件: TestImprovedFileChooser.java
@Test
public void testStuff()
    throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException {
  try {
    if (ImprovedFileChooser.isMacOs) {
      System.setProperty("apple.laf.useScreenMenuBar", "true");
    } else {
      for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    }
    ImprovedFileChooser fileChooser = new ImprovedFileChooser();
    fileChooser.setPreferredSize(new Dimension(1000, 750));
    fileChooser.showDialog(null, "Choose");
  } catch (HeadlessException e) {
    // ok to fail if there is no display
  }
}
 
源代码3 项目: pcgen   文件: PlayerCharacterTest.java
/**
 * Test the processing of modFeat. Checks that when in select single and
 * close mode, only one instance of a feat with a sub-choice is added.
 */
@Test
public void testModFeat()
{
	readyToRun();
	final PlayerCharacter character = new PlayerCharacter();
	character.setRace(human);
	character.incrementClassLevel(1, pcClass, true);

	UIPropertyContext.setSingleChoiceAction(Constants.CHOOSER_SINGLE_CHOICE_METHOD_SELECT_EXIT);
	ChooserFactory.useRandomChooser();

	assertEquals(
			2, (int)character.getRemainingFeatPoints(true),
			"Start with 2 feats"
	);
	try
	{
		AbstractCharacterTestCase.applyAbility(character, BuildUtilities.getFeatCat(), toughness, "");
	}
	catch (HeadlessException e)
	{
		Logging.debugPrint("Ignoring Headless exception.");
	}
	assertEquals(1, (int)character.getRemainingFeatPoints(true), "Only 1 feat used");
}
 
源代码4 项目: 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();
}
 
源代码5 项目: Spark   文件: SparkTrustManager.java
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
    try {
        doTheChecks(chain, authType);
    } catch (CertPathValidatorException e) {
        try {
            SwingUtilities.invokeLater(new Runnable() {
                
                @Override
                public void run() {
                certControll.addChain(chain);
                }
            });

        } catch (HeadlessException e1) {
            Log.error("Couldn't add certificate from presented chain");
        }
        throw new CertificateException(e);
    }
}
 
源代码6 项目: Spark   文件: MutualAuthenticationSettingsPanel.java
private void createSelfSignedCertificate() {
idControll.setUpData(commonNameField.getText(), organizationUnitField.getText(), organizationField.getText(), countryField.getText(),
	cityField.getText());
try {
    KeyPair keyPair = idControll.createKeyPair();

    X509Certificate cert = idControll.createSelfSignedCertificate(keyPair);
           if (saveCertToFile.isSelected()) {
               PemBuilder pemBuilder = new PemHelper().new PemBuilder();
               pemBuilder.add(keyPair.getPrivate());
               pemBuilder.add(cert);
               pemBuilder.saveToPemFile(IdentityController.CERT_FILE);
               JOptionPane.showMessageDialog(null,
                       Res.getString("dialog.self.signed.certificate.has.been.created") + IdentityController.SECURITY_DIRECTORY.toString());
           } else {
               try {
                   idControll.addEntryToKeyStore(cert, keyPair.getPrivate());
               } catch (HeadlessException | InvalidNameException | KeyStoreException e) {
                       Log.error("Couldn't save entry to IdentityStore", e);
               }
           }
} catch (NoSuchAlgorithmException | NoSuchProviderException | IOException | OperatorCreationException | CertificateException e1) {
    Log.error("Couldn't create Self Signed Certificate", e1);
}
   }
 
源代码7 项目: netcdf-java   文件: TestPanel.java
@Test
public void testPanel() {
  try {
    PrefPanel pp = new PrefPanel("title", (PreferencesExt) store.node("test"));
    pp.addTextField("name", "name", "defValue");
    Field.Text longF = pp.addTextField("Longname", "Longname",
        "defValue really long name for to be with starting value gotta adjust the thing");
    Field.Int iu = pp.addIntField("testIU", "number of times to barf", 2);
    pp.finish();
  } catch (HeadlessException e) {
    // ok to fail if there is no display
  }
}
 
源代码8 项目: openjdk-jdk8u   文件: 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();
    }
}
 
源代码9 项目: jdk1.8-source-analysis   文件: 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();
    }
}
 
源代码10 项目: openjdk-jdk8u   文件: 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");
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: 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");
}
 
源代码12 项目: hottub   文件: 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");
}
 
源代码13 项目: gama   文件: StyleAttribute.java
static public float convertUnitsToPixels(final int unitType, final float value) {
	if (unitType == NumberWithUnits.UT_UNITLESS || unitType == NumberWithUnits.UT_PERCENT) { return value; }

	float pixPerInch;
	try {
		pixPerInch = Toolkit.getDefaultToolkit().getScreenResolution();
	} catch (final HeadlessException ex) {
		// default to 72 dpi
		pixPerInch = 72;
	}
	final float inchesPerCm = .3936f;

	switch (unitType) {
		case NumberWithUnits.UT_IN:
			return value * pixPerInch;
		case NumberWithUnits.UT_CM:
			return value * inchesPerCm * pixPerInch;
		case NumberWithUnits.UT_MM:
			return value * .1f * inchesPerCm * pixPerInch;
		case NumberWithUnits.UT_PT:
			return value * (1f / 72f) * pixPerInch;
		case NumberWithUnits.UT_PC:
			return value * (1f / 6f) * pixPerInch;
	}

	return value;
}
 
源代码14 项目: dsworkbench   文件: SupportRefillSourcePanel.java
private void pasteFromClipboard() {
    try {
        String data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
        List<Village> villages = PluginManager.getSingleton().executeVillageParser(data);
        if (!villages.isEmpty()) {
            addVillages(villages.toArray(new Village[villages.size()]));
        }
    } catch (HeadlessException | IOException | UnsupportedFlavorException ignored) {
    }
}
 
源代码15 项目: 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");
}
 
源代码16 项目: stendhal   文件: SpriteStore.java
protected SpriteStore() {
	try {
		gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
	} catch (HeadlessException e) {
		logger.warn("Cannot initialize graphic user interface: " + e);
	}
}
 
源代码17 项目: openjdk-8-source   文件: 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();
    }
}
 
源代码18 项目: Bytecoder   文件: 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");
}
 
源代码19 项目: JDKSourceCode1.8   文件: 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();
    }
}
 
源代码20 项目: tutorials   文件: HeadlessModeUnitTest.java
@Test
public void whenHeadlessmode_thenFrameThrowsHeadlessException() {
    assertThatExceptionOfType(HeadlessException.class).isThrownBy(() -> {
        Frame frame = new Frame();
        frame.setVisible(true);
        frame.setSize(120, 120);
    });
}
 
源代码21 项目: dsworkbench   文件: DefenseSourcePanel.java
private void pasteFromClipboard() {
    String data = "";
    try {
        data = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor);
        List<Village> villages = PluginManager.getSingleton().executeVillageParser(data);
        if (!villages.isEmpty()) {
            addVillages(villages.toArray(new Village[villages.size()]));
        }
    } catch (HeadlessException | IOException | UnsupportedFlavorException ignored) {
    }
}
 
源代码22 项目: netbeans   文件: UtilitiesTest.java
public int getScreenResolution() throws HeadlessException {
    return Toolkit.getDefaultToolkit().getScreenResolution();
}
 
源代码23 项目: netbeans   文件: UtilitiesTest.java
public Clipboard getSystemClipboard() throws HeadlessException {
    return Toolkit.getDefaultToolkit().getSystemClipboard();
}
 
源代码24 项目: jdk8u-jdk   文件: HeadlessGraphicsEnvironment.java
public GraphicsDevice[] getScreenDevices()
    throws HeadlessException {
    throw new HeadlessException();
}
 
源代码25 项目: netbeans   文件: UtilitiesTest.java
protected ListPeer createList(java.awt.List target) throws HeadlessException {
    throw new IllegalStateException("Method not implemented");
}
 
源代码26 项目: CodenameOne   文件: PropertySheetDialog.java
public PropertySheetDialog(Frame owner, boolean modal)
  throws HeadlessException {
  super(owner, modal);
}
 
源代码27 项目: orbit-image-analysis   文件: BaseDialog.java
public BaseDialog(Frame owner) throws HeadlessException {
  super(owner);
  buildUI();
}
 
源代码28 项目: Bytecoder   文件: JFileChooser.java
private static void checkDragEnabled(boolean b) {
    if (b && GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }
}
 
源代码29 项目: openjdk-8   文件: HeadlessGraphicsEnvironment.java
public Rectangle getMaximumWindowBounds() throws HeadlessException {
    throw new HeadlessException();
}
 
源代码30 项目: Spark   文件: CertificateController.java
public void addCertificateAsExempted(CertificateModel certModel) throws HeadlessException, InvalidNameException, KeyStoreException {
    addEntryToKeyStoreImpl(certModel, true);
}
 
 类所在包
 类方法
 同包方法