public void run() { // set the icon image and layout manager of the rootPane f.setIconImage(Program.windowIcon); f.setLayout(new BorderLayout()); // set component borders mainBox.setBorder(new EmptyBorder(new Insets(5, 10, 10, 5))); // set component alignment rawEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT); gapEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT); huffEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT); vbEncLabel.setAlignmentX(Component.LEFT_ALIGNMENT); mainBox.add(rawEncLabel); mainBox.add(gapEncLabel); mainBox.add(vbEncLabel); mainBox.add(huffEncLabel); f.add(mainBox, BorderLayout.CENTER); // final setup and show of the window f.pack(); f.setSize(250, f.getSize().height); f.setLocationByPlatform(true); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setVisible(true); }
/** * Creates a window ('jframe') and performs the necessary voodoo to display the window and a menu * too. */ private static void openImage(BufferedImage img, String title) { JFrame frame = new JFrame(); frame.setLocationByPlatform(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle(title); addMenus(frame); setImageForFrame(frame, img); frame.pack(); // calculate its size frame.setVisible(true); // display it }
/** * Constructs a PlatformWindowContextImpl. It starts out by showing a progress window. Later a new * browser window is obtained given the windowId, or created. * * @param openerFrame the opener frame * @param windowId the window id * @param properties the properties */ public NavigatorWindowImpl(NavigatorFrame openerFrame, String windowId, Properties properties) { this.requestedProperties = properties; this.windowId = windowId; WindowFactory wf = windowFactory; if (wf == null) { throw new IllegalStateException("Global WindowFactory is null."); } AbstractBrowserWindow window = wf.getExistingWindow(windowId); FramePanel framePanel = null; if (window != null) { framePanel = window.getTopFramePanel(); if (framePanel == null) { throw new IllegalStateException( "Window with ID " + windowId + " exists but its top frame is null."); } } else { framePanel = FramePanelFactorySource.getInstance().getActiveFactory().createFramePanel(windowId); framePanel.setOpenerFrame(openerFrame); } this.framePanel = framePanel; // Starts out as progress window. // We allow documents to override window properties, but // it can also be the case that such methods as alert() are // invoked while the document loads. if (window != null) { this.browserWindow = window; this.progressWindow = null; this.launched = true; } else { AbstractBrowserWindow newWindow = wf.createWindow(this.windowId, properties, this); this.browserWindow = newWindow; JFrame progressWindow = new ProgressWindow(); this.progressWindow = progressWindow; // Pack to use preferred sizes progressWindow.pack(); // Then resize progressWindow.setSize(new Dimension(400, progressWindow.getHeight())); progressWindow.setLocationByPlatform(true); progressWindow.setVisible(true); progressWindow.addWindowListener( new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { if (!launched) { if (logger.isLoggable(Level.INFO)) { logger.info( "NavigatorWindowImpl(): Disposing browserWindow due to progress window getting closed."); } browserWindow.dispose(); } } }); } }
/** This method sets up the window and displays it. */ private void setupFrame() { JFrame window = new JFrame("Dungeon of Dooom"); window.setIconImage(Toolkit.getDefaultToolkit().getImage("graphics/icon.png")); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); populateFrame(window.getContentPane()); window.pack(); window.setLocationByPlatform(true); window.setVisible(true); Dimension windowSize = new Dimension(608, 606); window.setSize(windowSize); window.setResizable(false); }
private static void show() { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); try { } catch (Exception e) { // TODO: handle exception System.out.println(e.getMessage()); } }
public void itemPressed(VisualItem item, java.awt.event.MouseEvent e) { if (e.getClickCount() == 2) { Node v = null; String pindex = "/"; String parent = "/"; int ind; String itemname = item.getString(LABEL); for (int i = 0; ; i++) { v = (getNode(i)); String current = getName(v); if (current.compareTo(itemname) == 0) { ind = (int) v.get(Index); if (ind <= 9) itemname = itemname.substring(0, itemname.length() - 1); else itemname = itemname.substring(0, itemname.length() - 2); while (pindex != "Start") { Node h = v.getParent(); pindex = getName(h); ind = (int) h.get(Index); if (pindex == "Start") break; if (ind <= 9) parent = "/" + pindex.substring(0, pindex.length() - 1) + parent; else parent = "/" + pindex.substring(0, pindex.length() - 2) + parent; v = h; } break; } } System.out.println(parent.substring(1) + itemname); // trial2 hello2 = new // trial2(item.getInt(Index),(item.getString(LABEL)),parent.substring(1)+itemname,100); urllink mainPanel = new urllink( item.getInt(Index), (item.getString(LABEL)), parent.substring(1) + itemname, 100); JFrame frame = new JFrame("Click any option"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); } }
private static void createAndShowGui() { List<Integer> scores = new ArrayList<Integer>(); Random random = new Random(); int maxDataPoints = 16; int maxScore = 20; for (int i = 0; i < maxDataPoints; i++) { scores.add(random.nextInt(maxScore)); } DrawGraph mainPanel = new DrawGraph(scores); JFrame frame = new JFrame("DrawGraph"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); }
public ContentDialog(Content content) { frame = new JFrame("Content"); int margin = 15; JPanel main = new JPanel(); frame.setContentPane(main); main.setLayout(new BorderLayout()); ContentConfig config = new ContentConfig(); ContentPanel contentPanel = new ContentPanel(content, config, margin); Settings settings = new Settings(contentPanel); ScrollableView<ContentPanel> scrollableView = new ScrollableView<>(contentPanel); main.add(settings, BorderLayout.NORTH); main.add(scrollableView, BorderLayout.CENTER); /* * Menu */ Rectangle scene = content.getScene(); ContentPainter painter = new ContentPainter(scene, content, config, null); JMenuBar menu = new JMenuBar(); JMenu menuFile = new JMenu("File"); menu.add(menuFile); ExportUtil.addExportItems(menuFile, frame, painter, contentPanel); frame.setJMenuBar(menu); /* * Show dialog */ frame.setLocationByPlatform(true); frame.setSize(800, 500); frame.setVisible(true); }
private static void show() { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); }
/** * Constructor. * * @throws Exception */ public Gui( String thisPlayer, String[] playerNames, AckManager ackmanager, InetAddress hostAddress, int hostPort) { super("Texas Hold'em - " + thisPlayer); this.ackmanager = ackmanager; this.hostAddress = hostAddress; this.hostPort = hostPort; this.thisPlayer = thisPlayer; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().setBackground(UIConstants.TABLE_COLOR); setLayout(new GridBagLayout()); gc = new GridBagConstraints(); controlPanel = new ControlPanel(); boardPanel = new BoardPanel(controlPanel); addComponent(boardPanel, 1, 1, 1, 1); playerPanels = new HashMap<String, PlayerPanel>(); int i = 0; for (String player : playerNames) { PlayerPanel panel = new PlayerPanel(); playerPanels.put(player, panel); switch (i++) { case 0: // North position. addComponent(panel, 1, 0, 1, 1); break; case 1: // East position. addComponent(panel, 2, 1, 1, 1); break; case 2: // South position. addComponent(panel, 1, 2, 1, 1); break; case 3: // West position. addComponent(panel, 0, 1, 1, 1); break; default: // Do nothing. } } JFrame chatFrame = new JFrame(); chatFrame.setResizable(false); chat = new ChatPanel(this); chatFrame.add(chat); // Set to ignore the button chatFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); chatFrame.setAlwaysOnTop(true); chatFrame.setLocationByPlatform(true); chatFrame.setSize(400, 160); chatFrame.setVisible(true); // Show the main frame. pack(); setResizable(false); setLocationRelativeTo(null); setVisible(true); }
public void setup(boolean exitOnClose, Content content) { frame.setSize(800, 600); if (exitOnClose) { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } frame.setTitle("Live CG"); GeometryEditor geometryEditor = new GeometryEditor(); Menu menu = new Menu(this, geometryEditor.getEditPane(), geometryEditor.getEditPane()); Toolbar toolbar = new Toolbar(geometryEditor.getEditPane(), geometryEditor.getEditPane()); toolbar.setFloatable(false); StatusBar statusBar = new StatusBar(); StatusBarMouseListener statusBarMouseListener = new StatusBarMouseListener(geometryEditor.getEditPane(), statusBar); geometryEditor.getEditPane().addMouseListener(statusBarMouseListener); geometryEditor.getEditPane().addMouseMotionListener(statusBarMouseListener); GridBagConstraints c = new GridBagConstraints(); JPanel mainPanel = new JPanel(new GridBagLayout()); frame.setJMenuBar(menu); frame.setContentPane(mainPanel); c.weightx = 1.0; c.fill = GridBagConstraints.BOTH; c.gridy = 0; c.weighty = 0.0; mainPanel.add(toolbar, c); c.gridy = 1; c.weighty = 1.0; mainPanel.add(geometryEditor, c); c.gridy = 2; c.weighty = 0.0; mainPanel.add(statusBar, c); frame.setLocationByPlatform(true); frame.setVisible(true); objectDialog = new ObjectDialog(frame, geometryEditor.getEditPane()); objectDialog.setSize(300, 300); contentDialog = new ContentDialog(frame, geometryEditor.getEditPane()); contentDialog.setSize(300, 300); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { if (showObjectDialog) { showObjectDialog(); } if (showContentDialog) { showContentDialog(); } } }); if (content != null) { geometryEditor.getEditPane().setContent(content); } }