public void xtestTiming() { final JDialog dialog = new JDialog((JFrame) null, "TestTiming"); JDesktopPane pane = new JDesktopPane(); dialog.setContentPane(pane); final Object[] f = {null}; for (int i = 99; i >= 0; i--) { JInternalFrame frame = new JInternalFrame("Internal Frame - " + i, true, true, true, true); JButton s = new JButton("button" + i); s.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { final long start = System.currentTimeMillis(); System.err.println("TestMarathonNamingStrategy.testTiming(): " + start); namingStrategy.setTopLevelComponent(dialog, true); String name = namingStrategy.getName((Component) e.getSource()); System.err.println( "TestMarathonNamingStrategy.testTiming(): name = " + name + "::" + (System.currentTimeMillis() - start)); } }); f[0] = s; frame.getContentPane().add(s); frame.pack(); frame.setLocation(i, i); frame.setVisible(true); pane.add(frame); } dialog.setSize(500, 500); dialog.setModal(true); dialog.setVisible(true); System.err.println( "TestMarathonNamingStrategy.testTiming(): " + ((Component) f[0]).isVisible()); }
public Object showWindow(final MkWindow macWindow, String title, boolean isModal) { listMkWindow.add(macWindow); if (isModal) { JDialog modalFrame = new JDialog(this, title, true); // macWindow.setJanela(modalFrame); final MkRun onCloseWindow = macWindow.onCloseWindow; modalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); modalFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { if (onCloseWindow != null) { onCloseWindow.execute(); } disposeWindow(macWindow); } }); modalFrame.setLayout(new BorderLayout()); modalFrame.add(macWindow, BorderLayout.CENTER); modalFrame.pack(); Dimension desktopSize = desktopPane.getSize(); int x = (desktopSize.width - modalFrame.getWidth()) / 2; int y = (desktopSize.height - modalFrame.getHeight()) / 2; modalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y)); if (macWindow.panelButton != null) { modalFrame.getRootPane().setDefaultButton((JButton) macWindow.panelButton.getComponent(0)); } modalFrame.setVisible(true); return modalFrame; } else { JInternalFrame internalFrame = new JInternalFrame(title, true, true, true, true); internalFrame.setContentPane(macWindow); internalFrame.pack(); // internalFrame.setBounds(internalFrame.getBounds()); //pq? desktopPane.add(internalFrame); internalFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); final MkRun onCloseWindow = macWindow.onCloseWindow; if (onCloseWindow != null) { internalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); internalFrame.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { onCloseWindow.execute(); } }); } Dimension desktopSize = desktopPane.getSize(); int x = (desktopSize.width - internalFrame.getWidth()) / 2; int y = (desktopSize.height - internalFrame.getHeight()) / 2; internalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y)); internalFrame.setVisible(true); return internalFrame; } }
private void displayNewWindow() { try { frame = new DefaultQuarantineWindow(getGuiContext(), guiData, userId, new ListDataSource()); frame.addInternalFrameListener(cleanUpListener); getDesktopPane().add(frame); frame.pack(); frame.setVisible(true); frame.setSelected(true); } catch (Exception ex) { ErrorDialog.show(getDesktopPane(), "Impossible d'afficher la liste", ex); } }
protected void showDeployAgentDialog() { // TODO Auto-generated method stub JInternalFrame fr = new JInternalFrame("Deploy Agent"); fr.getContentPane().add(new NewAgentPanel()); fr.pack(); fr.setClosable(true); fr.setIconifiable(true); fr.setResizable(true); fr.setMaximizable(true); fr.setVisible(true); jDesktopPane1.add(fr); }
private void initAboutFrames() { System.out.println("Initializing the about frames..."); authorFrame = new JInternalFrame("Authors", true, true, true, true); problemFrame = new JInternalFrame("Problem Description", true, true, true, true); final String AUTHOR_TEXT = "Authors:\n Ethan Wells and San Yeung\n"; JTextArea authorFrameTextArea = new JTextArea(AUTHOR_TEXT); authorFrameTextArea.setEditable(false); authorFrameTextArea.setLineWrap(true); authorFrameTextArea.setColumns(60); authorFrame.add(authorFrameTextArea); authorFrame.pack(); final String PROBLEM_TEXT = "Two towns A and B are connected with a bridge. Suppose there are four\n" + "people and their moving directions are indicated by the arrows. The bridge is narrow, and at any\n" + "time, multiple people cannot pass in the opposite directions.\n" + "1. Based on the Ricart & Agrawalas mutual exclusion algorithm, design a decentralized protocol\n" + "so that at most one person can be on the bridge at any given time, and no person is indefinitely\n" + "prevented from crossing the bridge. Treat each person to be a process, and assume that their\n" + "clocks are synchronized.\n" + "2. Design another protocol so that multiple people can be on the bridge as long as they are\n" + "moving in the same direction, but no person is indefinitely prevented from crossing the bridge.\n" + "Design a graphical user interface to display the movement of the people, so that the instructor can\n" + "control the walking speed of the people and verify the protocol. Note that to receive full credits,\n" + "you should provide instructions on how to compile and run your program, and your program should\n" + "be well-documented."; JTextArea problemFrameTextArea = new JTextArea(PROBLEM_TEXT); problemFrameTextArea.setEditable(false); problemFrameTextArea.setLineWrap(true); problemFrameTextArea.setColumns(70); problemFrame.add(problemFrameTextArea); problemFrame.pack(); authorFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); problemFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); virtualDesktop.add(authorFrame); virtualDesktop.add(problemFrame); }
public LogViewInternalFrame( String name, JDesktopPane desktopPane, StatusObserver statusObserver) { this.name = name; this.desktopPane = desktopPane; this.statusObserver = statusObserver; dataTableModel = new LogDataTableModel(); logViewPanel = new LogViewPanel(dataTableModel, statusObserver); cardLayout = new CardLayout(); JPanel panelLoading = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(10, 10, 10, 10); c.anchor = GridBagConstraints.PAGE_START; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.ipadx = 12; c.ipady = 12; JLabel label = new JLabel("Loading file " + name); panelLoading.add(label, c); c.gridy = 1; c.weighty = 5; c.weightx = 3; loadingProgressBar = new JProgressBar(); loadingProgressBar.setIndeterminate(false); loadingProgressBar.setStringPainted(true); loadingProgressBar.setString("Connecting..."); panelLoading.add(loadingProgressBar, c); iframe = new JInternalFrame(name, true, true, true, true); iframe.getContentPane().setLayout(cardLayout); iframe.getContentPane().add(panelLoading, CARD_LAYOUT_LOADING); iframe.getContentPane().add(logViewPanel, CARD_LAYOUT_CONTENT); cardLayout.show(iframe.getContentPane(), CARD_LAYOUT_LOADING); iframe.setBounds(50, 50, 200, 100); desktopPane.add(iframe); iframe.setVisible(true); iframe.pack(); try { iframe.setMaximum(true); } catch (PropertyVetoException ignore) { } }
private void showDomainDialog( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_showDomainDialog // TODO add your handling code here: JInternalFrame fr = new JInternalFrame("Add new Domain"); fr.getContentPane().add(new NewDomainPanel()); fr.pack(); fr.setClosable(true); fr.setIconifiable(true); fr.setResizable(true); fr.setMaximizable(true); fr.setVisible(true); jDesktopPane1.add(fr); GridBagConstraints gc = new GridBagConstraints(); gc.gridx = 0; gc.gridy = GridBagConstraints.RELATIVE; gc.insets = new Insets(6, 12, 0, 12); gc.fill = GridBagConstraints.HORIZONTAL; domainsPanel.add(new JButton("Dynamic"), gc); } // GEN-LAST:event_showDomainDialog
public DialogDecoration() { setLayout(new BorderLayout()); clipboardPanel = new JClipboardPanel(); clipboardPanel.addPropertyChangeListener(DialogDecoration.this); frame = new JInternalFrame("Clipboard"); frame.setContentPane(clipboardPanel); frame.setResizable(true); frame.setClosable(true); frame.setIconifiable(false); frame.pack(); frame.setVisible(true); desktop = new JLayeredPane(); desktop.setOpaque(false); desktop.add(frame); add(BorderLayout.CENTER, desktop); }
private void initializeContainer(Container c) { System.out.println("Initializing the Container..."); c.setPreferredSize(MASTER_WINDOW_SIZE); virtualDesktop = new JDesktopPane(); virtualDesktop.setPreferredSize(MASTER_WINDOW_SIZE); algorithmFrame = new JInternalFrame("Algorithm Visualization", true, true, true, true); algorithmFrame.setResizable(false); algorithmFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); vizPanel = new VisualizationPanel(); algorithmFrame.setContentPane(vizPanel); vizPanel.setDisplayedThreads(); algorithmFrame.pack(); virtualDesktop.add(algorithmFrame); initAboutFrames(); c.add(virtualDesktop); algorithmFrame.setVisible(true); }
public void pack() { if (w != null) { // circumvention for bug 1924630 : this throws a NullPointerException // with the combination Metal-lnf / java 1.5 / screen menu bar / laf window deco // / floating palettes. We have to make sure the window is focusable // during pack(): final boolean wasFocusable = w.getFocusableWindowState(); if (!wasFocusable) { w.setFocusableWindowState(true); } w.pack(); if (!wasFocusable) { w.setFocusableWindowState(false); } } else if (jif != null) { // bug in swing?? // when using undecorated windows plus metal-lnf plus lnf-window-deco // try { jif.pack(); } catch( NullPointerException e ) {} jif.pack(); } else { throw new IllegalStateException(); } }
/** Contains a CyNetworkView. */ protected void createContainer(final CyNetworkView view) { if (networkViewMap.containsKey(view.getNetwork().getIdentifier())) return; // create a new InternalFrame and put the CyNetworkViews Component into // it final JInternalFrame iframe = new JInternalFrame(view.getTitle(), true, true, true, true); iframe.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { Cytoscape.destroyNetworkView(view); } }); desktopPane.add(iframe); // code added to support layered canvas for each CyNetworkView if (view instanceof DGraphView) { final InternalFrameComponent internalFrameComp = new InternalFrameComponent(iframe.getLayeredPane(), (DGraphView) view); iframe.getContentPane().add(internalFrameComp); internalFrameComponentMap.put(view.getNetwork().getIdentifier(), internalFrameComp); } else { logger.info("NetworkViewManager.createContainer() - DGraphView not found!"); iframe.getContentPane().add(view.getComponent()); } iframe.pack(); int x = 0; int y = 0; JInternalFrame refFrame = null; JInternalFrame[] allFrames = desktopPane.getAllFrames(); if (allFrames.length > 1) { refFrame = allFrames[0]; } if (refFrame != null) { x = refFrame.getLocation().x + 20; y = refFrame.getLocation().y + 20; } if (x > (desktopPane.getWidth() - MINIMUM_WIN_WIDTH)) { x = desktopPane.getWidth() - MINIMUM_WIN_WIDTH; } if (y > (desktopPane.getHeight() - MINIMUM_WIN_HEIGHT)) { y = desktopPane.getHeight() - MINIMUM_WIN_HEIGHT; } if (x < 0) { x = 0; } if (y < 0) { y = 0; } iframe.setBounds(x, y, 400, 400); // maximize the frame if the specified property is set try { String max = CytoscapeInit.getProperties().getProperty("maximizeViewOnCreate"); if ((max != null) && Boolean.parseBoolean(max)) iframe.setMaximum(true); } catch (PropertyVetoException pve) { logger.warn("Unable to maximize internal frame: " + pve.getMessage()); } iframe.setVisible(true); iframe.addInternalFrameListener(this); iframe.setResizable(true); networkViewMap.put(view.getNetwork().getIdentifier(), iframe); componentMap.put(iframe, view.getNetwork().getIdentifier()); firePropertyChange( CytoscapeDesktop.NETWORK_VIEW_FOCUSED, null, view.getNetwork().getIdentifier()); }
public JunctionLinkDataFrame(final JunctionLink jl) { super( jl.getCurrName() + " properties", false, // resizable false, // closable false, // maximizable true); // iconifiable // PSRender.onHold(); super.setBackground(back_color); super.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameActivated(InternalFrameEvent e) { reload(); SelectedObject.setSelectedObject(jl); } }); PSRender.moveToTop(jl.getBound(), 0.5); ml = jl; setLocation(50, 50); dataModelMain = new HeadTable(jl); tableMain = new JTable(dataModelMain); tableMain.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); tableMain.setPreferredScrollableViewportSize(new Dimension(500, 20)); // tableMain.setBackground(back_color); // code TableColumn column_code = tableMain.getColumn("Code"); DefaultTableCellRenderer rendererCode = new DefaultTableCellRenderer(); rendererCode.setToolTipText("Enter new code for this path"); column_code.setCellRenderer(rendererCode); column_code.setCellEditor(new TextFieldEditor()); // name TableColumn column_name = tableMain.getColumn("Name"); LanguageButtonRender render_name = new LanguageButtonRender(); render_name.setToolTipText("Path name. Press for change name"); column_name.setCellRenderer(render_name); LanguageButtonEditor editor_name = new LanguageButtonEditor(new JCheckBox()); column_name.setCellEditor(editor_name); // junction 1 TableColumn column_junc_1 = tableMain.getColumn("Junction 1"); MLButtonRenderer rendererJunc_1 = new MLButtonRenderer(); rendererJunc_1.setToolTipText("Code of first Junction, click for open properties"); column_junc_1.setCellRenderer(rendererJunc_1); MLButtonEditor editorJunc = new MLButtonEditor(new JCheckBox()); column_junc_1.setCellEditor(editorJunc); // junction 2 TableColumn column_junc_2 = tableMain.getColumn("Junction 2"); MLButtonRenderer rendererJunc_2 = new MLButtonRenderer(); rendererJunc_2.setToolTipText("Code of second Junction, click for open properties"); column_junc_2.setCellRenderer(rendererJunc_2); column_junc_2.setCellEditor(editorJunc); // type JComboBox comboBoxType = new JComboBox(); String roadNames[] = jl.getTypeNames(); for (int i = 0, len = roadNames.length; i < len; i++) { comboBoxType.addItem(roadNames[i]); } TableColumn column_type = tableMain.getColumn("Type"); DefaultTableCellRenderer rendererType = new DefaultTableCellRenderer(); rendererType.setToolTipText("To change road type click for combo box"); column_type.setCellRenderer(rendererType); column_type.setCellEditor(new DefaultCellEditor(comboBoxType)); // legth TableColumn column_length = tableMain.getColumn("Length"); DefaultTableCellRenderer rendererLen = new DefaultTableCellRenderer(); rendererLen.setToolTipText("The path length in meters"); column_length.setCellRenderer(rendererLen); scrollpaneMain = new JScrollPane(tableMain); scrollpaneMain.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollpaneMain.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); scrollpaneMain.setPreferredSize(new Dimension(500, 50)); Container contentPane = super.getContentPane(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); contentPane.setLayout(gridbag); c.ipady = 0; // make this component tall c.weightx = 0.5; c.gridwidth = 4; c.gridx = 0; c.gridy = 0; gridbag.setConstraints(scrollpaneMain, c); // scrollpaneMain.setBackground(back_color); // scrollpaneMain.setForeground(back_color); contentPane.add(scrollpaneMain); TableModel dataModelPoints = new PointTableModel(jl); tablePoints = new JTable(dataModelPoints); tablePoints.setPreferredScrollableViewportSize( new Dimension(200, dataModelPoints.getRowCount() * tablePoints.getRowHeight())); ListModel lm = new AbstractListModel() { public int getSize() { return 1000; } public Object getElementAt(int index) { return "" + index; } }; JList rowHeader = new JList(lm); rowHeader.setFixedCellWidth(20); rowHeader.setFixedCellHeight(tablePoints.getRowHeight()); // + tablePoints.getRowMargin()); rowHeader.setCellRenderer(new RowHeaderRenderer(tablePoints)); scrollPanePoints = new JScrollPane(tablePoints); scrollPanePoints.setWheelScrollingEnabled(true); scrollPanePoints.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPanePoints.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); int mh; if (dataModelPoints.getRowCount() * tablePoints.getRowHeight() > 100) { mh = 100; } else { mh = dataModelPoints.getRowCount() * tablePoints.getRowHeight(); } scrollPanePoints.setPreferredSize(new Dimension(200, mh)); scrollPanePoints.setRowHeaderView(rowHeader); c.ipadx = 200; c.weightx = 0.5; c.gridwidth = 3; c.gridx = 1; c.gridy = 1; gridbag.setConstraints(scrollPanePoints, c); // scrollPanePoints.setBackground(back_color); contentPane.add(scrollPanePoints); button_ok = new JButton("Ok"); button_ok.addActionListener(this); JPanel buttonPane = new JPanel(null); buttonPane.setPreferredSize(new Dimension(500, 100)); button_ok.setBounds(205, 40, 90, 40); buttonPane.add(button_ok); c.ipady = 10; // make this component tall c.ipadx = 10; c.weightx = 0.5; c.gridwidth = 4; c.gridx = 2; c.gridy = 2; gridbag.setConstraints(buttonPane, c); buttonPane.setBackground(back_color); contentPane.add(buttonPane); super.pack(); super.setVisible(true); // MapApplication.getDesktop().setSelectedFrame(this); }