Example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

List of usage examples for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

Introduction

In this page you can find the example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment.

Prototype

public static GraphicsEnvironment getLocalGraphicsEnvironment() 

Source Link

Document

Returns the local GraphicsEnvironment .

Usage

From source file:JOptionPaneDemonstrationLocalized.java

public static void main(String[] argv) {

        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        Font unicodeFont = new Font("LucidaSans", Font.PLAIN, 12);

        ResourceBundle bundle = ResourceBundle.getBundle("JOptionPaneResources", Locale.getDefault());

        String[] textMessages = new String[3];
        textMessages[0] = bundle.getString("Yes");
        textMessages[1] = bundle.getString("No");
        textMessages[2] = bundle.getString("Cancel");

        JOptionPane jop = new JOptionPane(bundle.getString("MessageText"), JOptionPane.ERROR_MESSAGE,
                JOptionPane.YES_NO_CANCEL_OPTION, null, textMessages);
        JDialog jopDialog = jop.createDialog(null, bundle.getString("TitleText"));
        jop.setFont(unicodeFont);//from  w w w. ja  v a 2s.  com
        jopDialog.setVisible(true);
        Object userSelection = jop.getValue();
    }

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Map<String, List<String>> fontFaceNames = new HashMap<String, List<String>>();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = ge.getAllFonts();

    for (int i = 0; i < fonts.length; i++) {
        String familyName = fonts[i].getFamily();
        String faceName = fonts[i].getName();

        List<String> list = fontFaceNames.get(familyName);
        if (list == null) {
            list = new ArrayList<String>();
            fontFaceNames.put(familyName, list);
        }/*w  w  w . j  a  va  2s.co  m*/
        list.add(faceName);
    }
    System.out.println(fontFaceNames);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    Button btn = new Button("OK");
    btn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            gs.setFullScreenWindow(null);
        }//w w w  .  jav  a2  s  .com
    });
    Frame frame = new Frame(gs.getDefaultConfiguration());
    Window win = new Window(frame);
    win.add(btn, BorderLayout.CENTER);
    try {
        gs.setFullScreenWindow(win);
        win.validate();
    } finally {
        gs.setFullScreenWindow(null);
    }
}

From source file:Main.java

public static void main(String[] args) {
    final StringBuilder sb = new StringBuilder();
    sb.append("<html>");
    sb.append("<body><ol>");
    Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
    for (Font font : fonts) {
        String name = font.getName();
        sb.append("<li style='font-family: " + name + "; font-size: 20px;'>");
        sb.append(name);//ww w .j av a2s .  co m
    }

    JScrollPane sp = new JScrollPane(new JLabel(sb.toString()));
    Dimension d = sp.getPreferredSize();
    sp.setPreferredSize(new Dimension(d.width, 150));
    JOptionPane.showMessageDialog(null, sp);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String html = "<h1>Hello, world.</h1>";
    int width = 200, height = 100;

    BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
            .getDefaultConfiguration().createCompatibleImage(width, height);

    Graphics graphics = image.createGraphics();

    JEditorPane jep = new JEditorPane("text/html", html);
    jep.setSize(width, height);// w  w w. j a v a  2 s .c om
    jep.print(graphics);

    ImageIO.write(image, "png", new File("Image.png"));
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment graphicsEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();

    GraphicsDevice graphicsDevice = graphicsEnv.getDefaultScreenDevice();

    boolean isSupported = graphicsDevice.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);
    System.out.println("PERPIXEL_TRANSPARENT  supported: " + isSupported);

    isSupported = graphicsDevice.isWindowTranslucencySupported(TRANSLUCENT);
    System.out.println("TRANSLUCENT  supported: " + isSupported);

    isSupported = graphicsDevice.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
    System.out.println("PERPIXEL_TRANSLUCENT  supported: " + isSupported);
}

From source file:Test.java

public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);

    GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();

    if (!graphicsDevice.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
        System.err.println("Translucency is not supported on this platform");
        System.exit(0);//from   w ww  .  jav  a 2s .c o  m
    }
    ApplicationWindow window = new ApplicationWindow();
    window.setOpacity(0.75f);
    window.setVisible(true);
}

From source file:Test.java

License:asdf

public static void main(String[] args) {
    GraphicsEnvironment envmt = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = envmt.getDefaultScreenDevice();

    if (!device.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        System.out.println("Shaped windows are not supported on" + "your system.");
        System.exit(0);//from w  w  w  .ja va 2s.com
    }

    ApplicationWindow window = new ApplicationWindow();
    window.setVisible(true);
}

From source file:Test.java

public static void main(String[] args) {
    GraphicsEnvironment envmt = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = envmt.getDefaultScreenDevice();

    if (!device.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
        System.out.println("Translucent windows are not supported on your system.");
        System.exit(0);/*from  ww w .j a  va  2s.c  o m*/
    }
    JFrame.setDefaultLookAndFeelDecorated(true);
    ApplicationWindow window = new ApplicationWindow();
    window.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(800, 600);//from www  . j  ava2s .c o  m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    device.setFullScreenWindow(frame);
    device.setDisplayMode(new DisplayMode(800, 600, 32, 60));
    frame.setVisible(true);

    JButton btn = new JButton();
    btn.setText("Button");
    JPanel panel = new JPanel();

    panel.add(btn);
    frame.add(panel);

    btn.addActionListener(e -> {
        JOptionPane.showMessageDialog(frame.getContentPane(), "JOptionPane");
    });
}