Java Code Examples for javax.swing.JFrame#setBackground()
The following examples show how to use
javax.swing.JFrame#setBackground() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RobotUtils.java From karate with MIT License | 6 votes |
public static void highlight(int x, int y, int width, int height, int time) { JFrame f = new JFrame(); f.setUndecorated(true); f.setBackground(new Color(0, 0, 0, 0)); f.setAlwaysOnTop(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setType(JFrame.Type.UTILITY); f.setFocusableWindowState(false); f.setAutoRequestFocus(false); f.setLocation(x, y); f.setSize(width, height); f.getRootPane().setBorder(BorderFactory.createLineBorder(Color.RED, 3)); f.setVisible(true); delay(time); f.dispose(); }
Example 2
Source File: ComponentResizeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void createAndShowGUI() { demoFrame = new JFrame(); demoFrame.setSize(300, 300); demoFrame.setLayout(new FlowLayout()); demoFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); demoFrame.setUndecorated(true); demoFrame.setBackground(new Color(0f, 0, 0, 0.1f)); JCheckBox b = new JCheckBox("Whatever"); demoFrame.paintAll(null); b.setOpaque(true); demoFrame.add(b); demoFrame.add(new JButton()); demoFrame.setVisible(true); }
Example 3
Source File: bug8041561.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void createAndShowGUI() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBackground(Color.BLUE); radioButton = new JRadioButton(); radioButton.setOpaque(false); JPanel panel = new JPanel(); panel.setBackground(Color.BLUE); panel.add(radioButton); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); }
Example 4
Source File: AhkFastTyper.java From training with MIT License | 5 votes |
private static void makeUI() { frame = new JFrame("Keyboard Shortcuts Pane"); frame.setUndecorated(true); frame.setBackground(new Color(1, 1, 1, 0f)); // frame.setFocusableWindowState(false); frame.setSize(100, 30); frame.setAlwaysOnTop(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setFocusableWindowState(false); frame.setFocusable(true); frame.setVisible(false); }
Example 5
Source File: DialogUtils.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public static void createDialogBackPanel(JFrame dialog, Component parent) { dialog.setBackground(new Color(255, 255, 255, 64)); DialogBackPanel newContentPane = new DialogBackPanel(dialog.getContentPane(), dialog.getTitle()); dialog.setContentPane(newContentPane); dialog.setSize(parent.getSize()); dialog.setLocation(parent.getLocationOnScreen()); }
Example 6
Source File: CheckIntersectPolyline2D.java From javaGeom with GNU Lesser General Public License v3.0 | 5 votes |
public final static void main(String[] args){ System.out.println("draw intersection of polylines"); JPanel panel = new CheckIntersectPolyline2D(); panel.setPreferredSize(new Dimension(400, 300)); JFrame frame = new JFrame("Check intersection of polyline"); frame.setBackground(Color.WHITE); frame.setContentPane(panel); frame.pack(); frame.setVisible(true); }
Example 7
Source File: SwingDemo.java From jfxvnc with Apache License 2.0 | 5 votes |
public SwingDemo(boolean singleFrame) { JFrame frame = new JFrame("SwingDemo"); frame.setSize(900, 700); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventDispatcher(new KeyDispatcher()); if (singleFrame) { frame.setContentPane(createVncView()); frame.setBackground(Color.GRAY); frame.setVisible(true); return; } JDesktopPane pane = new JDesktopPane(); frame.setContentPane(pane); iframe = new JInternalFrame("VNC", true, true, true, true); iframe.setSize(850, 650); iframe.setOpaque(false); iframe.addInternalFrameListener(this); iframe.setContentPane(createVncView()); pane.add(iframe); frame.setVisible(true); iframe.setVisible(true); }
Example 8
Source File: IceLeaf.java From snowblossom with Apache License 2.0 | 4 votes |
public void run() { JFrame f=new JFrame(); f.setVisible(true); f.setDefaultCloseOperation( f.EXIT_ON_CLOSE); f.setBackground(getBGColor()); try { InputStream is = IceLeaf.class.getResourceAsStream(getResourceBasePath() +"/iceleaf-ui/resources/flower-with-ink-256.png"); f.setIconImage(ImageIO.read(is)); } catch(Exception e) { e.printStackTrace(); } String title = getTitle(); if (!params.getNetworkName().equals("snowblossom")) { title = title + " - " + params.getNetworkName(); } f.setTitle(title); f.setSize(950, 600); JTabbedPane tab_pane = new JTabbedPane(); f.setContentPane(tab_pane); // should be first to initialize settings to default settings_panel.setup(); node_panel.setup(); node_select_panel.setup(); wallet_panel.setup(); make_wallet_panel.setup(); send_panel.setup(); address_panel.setup(); history_panel.setup(); receive_panel.setup(); tab_pane.add("Wallets", wallet_panel.getPanel()); tab_pane.add("Send", send_panel.getPanel()); tab_pane.add("Receive", receive_panel.getPanel()); tab_pane.add("Addresses", address_panel.getPanel()); tab_pane.add("History", history_panel.getPanel()); tab_pane.add("Make Wallet", make_wallet_panel.getPanel()); tab_pane.add("Node Selection", node_select_panel.getPanel()); tab_pane.add("Node", node_panel.getPanel()); tab_pane.add("Settings", settings_panel.getPanel()); setupMorePanels(tab_pane, f); UIUtil.applyLook(f, ice_leaf); }
Example 9
Source File: SplashWindow.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public SplashWindow() { window = new JFrame() { /** default serial id. */ private static final long serialVersionUID = 1L; @Override public void paint(Graphics g) { // Draw splash image and superimposed text Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.drawImage(splashImage, 0, 0, this); g2d.setColor(Color.WHITE); g2d.setFont(new Font("SansSerif", Font.PLAIN, 36)); g2d.drawString(MSP_STRING, 30, 60); g2d.setFont(versionStringFont); g2d.drawString(VERSION_STRING, splashImage.getWidth(this) - versionStringWidth - 16, 24); } }; splashImage = ImageLoader.getImage(IMAGE_NAME); ImageIcon splashIcon = new ImageIcon(splashImage); width = splashIcon.getIconWidth(); height = splashIcon.getIconHeight(); window.setSize(width, height); // Center the splash window on the screen. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension windowSize = new Dimension(width, height); window.setLocation(((screenSize.width - windowSize.width) / 2), ((screenSize.height - windowSize.height) / 2)); window.setBackground(Color.black); window.setUndecorated(true); // Set icon image for window. setIconImage(); // Set cursor style. window.setCursor(new Cursor(Cursor.WAIT_CURSOR)); // Display the splash window. window.setVisible(true); }
Example 10
Source File: SkinEditorMainGUI.java From megamek with GNU General Public License v2.0 | 4 votes |
/** * Initializes a number of things about this frame. */ private void initializeFrame() { frame = new JFrame(Messages.getString("ClientGUI.title")); //$NON-NLS-1$ frame.setJMenuBar(menuBar); Rectangle virtualBounds = getVirtualBounds(); int x, y, w, h; if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) { x = GUIPreferences.getInstance().getWindowPosX(); y = GUIPreferences.getInstance().getWindowPosY(); w = GUIPreferences.getInstance().getWindowSizeWidth(); h = GUIPreferences.getInstance().getWindowSizeHeight(); if ((x < virtualBounds.getMinX()) || ((x + w) > virtualBounds.getMaxX())) { x = 0; } if ((y < virtualBounds.getMinY()) || ((y + h) > virtualBounds.getMaxY())) { y = 0; } if (w > virtualBounds.getWidth()) { w = (int) virtualBounds.getWidth(); } if (h > virtualBounds.getHeight()) { h = (int) virtualBounds.getHeight(); } frame.setLocation(x, y); frame.setSize(w, h); } else { frame.setSize(800, 600); } frame.setMinimumSize(new Dimension(640, 480)); frame.setBackground(SystemColor.menu); frame.setForeground(SystemColor.menuText); List<Image> iconList = new ArrayList<Image>(); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_16X16) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_32X32) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_48X48) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_256X256) .toString())); frame.setIconImages(iconList); mechW = new JDialog(frame, Messages.getString("ClientGUI.MechDisplay"), false); x = GUIPreferences.getInstance().getDisplayPosX(); y = GUIPreferences.getInstance().getDisplayPosY(); h = GUIPreferences.getInstance().getDisplaySizeHeight(); w = GUIPreferences.getInstance().getDisplaySizeWidth(); if ((x + w) > virtualBounds.getWidth()) { x = 0; w = Math.min(w, (int)virtualBounds.getWidth()); } if ((y + h) > virtualBounds.getHeight()) { y = 0; h = Math.min(h, (int)virtualBounds.getHeight()); } mechW.setLocation(x, y); mechW.setSize(w, h); mechW.setResizable(true); unitDisplay = new UnitDisplay(null); mechW.add(unitDisplay); mechW.setVisible(true); unitDisplay.displayEntity(testEntity); }
Example 11
Source File: ClientGUI.java From megamek with GNU General Public License v2.0 | 4 votes |
/** * Initializes a number of things about this frame. */ private void initializeFrame() { frame = new JFrame(Messages.getString("ClientGUI.title")); //$NON-NLS-1$ menuBar.setGame(client.getGame()); frame.setJMenuBar(menuBar); Rectangle virtualBounds = getVirtualBounds(); if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) { int x = GUIPreferences.getInstance().getWindowPosX(); int y = GUIPreferences.getInstance().getWindowPosY(); int w = GUIPreferences.getInstance().getWindowSizeWidth(); int h = GUIPreferences.getInstance().getWindowSizeHeight(); if ((x < virtualBounds.getMinX()) || ((x + w) > virtualBounds.getMaxX())) { x = 0; } if ((y < virtualBounds.getMinY()) || ((y + h) > virtualBounds.getMaxY())) { y = 0; } if (w > virtualBounds.getWidth()) { w = (int) virtualBounds.getWidth(); } if (h > virtualBounds.getHeight()) { h = (int) virtualBounds.getHeight(); } frame.setLocation(x, y); frame.setSize(w, h); } else { frame.setSize(800, 600); } frame.setMinimumSize(new Dimension(640,480)); frame.setBackground(SystemColor.menu); frame.setForeground(SystemColor.menuText); List<Image> iconList = new ArrayList<>(); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_16X16).toString() )); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_32X32).toString() )); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_48X48).toString() )); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_256X256).toString() )); frame.setIconImages(iconList); }