當前位置: 首頁>>代碼示例>>Java>>正文


Java JDialog.setModal方法代碼示例

本文整理匯總了Java中javax.swing.JDialog.setModal方法的典型用法代碼示例。如果您正苦於以下問題:Java JDialog.setModal方法的具體用法?Java JDialog.setModal怎麽用?Java JDialog.setModal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JDialog的用法示例。


在下文中一共展示了JDialog.setModal方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import javax.swing.JDialog; //導入方法依賴的package包/類
public static void run(String className, String testName, String fileName) throws Exception {
    final File golden = new File("/space/nm/java/editor/test/unit/data/goldenfiles/org/netbeans/modules/java/editor/semantic/" + className + "/" + testName + ".pass");
    final File test   = new File("/tmp/tests/org.netbeans.modules.java.editor.semantic." + className + "/" + testName + "/" + testName + ".out");
    final File source = new File("/tmp/tests/org.netbeans.modules.java.editor.semantic." + className + "/" + testName + "/test/" + fileName + ".java");
    
    final StyledDocument doc = loadDocument(source);
    final List<HighlightImpl> goldenHighlights = parse(doc, golden);
    final List<HighlightImpl> testHighlights = parse(doc, test);

    Runnable show = new Runnable() {
        public void run() {
            JDialog d = new JDialog();
            
            d.setModal(true);
            
            ShowGoldenFilesPanel panel = new ShowGoldenFilesPanel(d);
            
            panel.setDocument(doc, goldenHighlights, testHighlights, golden, test);
            
            d.getContentPane().add(panel);
            
            d.show();
        }
    };

    if (SwingUtilities.isEventDispatchThread()) {
        show.run();
    } else {
        SwingUtilities.invokeAndWait(show);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:ShowGoldenFiles.java

示例2: main

import javax.swing.JDialog; //導入方法依賴的package包/類
public static void main(String[] args) {
  final String loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";

  final JDialog d = new JDialog();
  d.setTitle("Flow Label Test");
  d.setModal(true);
  d.setResizable(true);
  d.setLocationRelativeTo(null);
  d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
  d.add(new FlowLabel(loremIpsum + "\n\n" + loremIpsum));
  d.pack();
  d.setVisible(true);
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:14,代碼來源:FlowLabel.java

示例3: show

import javax.swing.JDialog; //導入方法依賴的package包/類
/** Shows a given graph in an optionally modal dialog. */
private void show(final Graph graph, GrammarModel grammar, boolean modal) {
    GraphPreviewPanel panel = GraphPreviewDialog.createPanel(grammar, graph);
    panel.add(new NodeIdsButton(panel), BorderLayout.NORTH);
    JOptionPane optionPane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE);
    JDialog dialog = optionPane.createDialog(graph.getName());
    dialog.setModal(modal);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:11,代碼來源:Viewer.java

示例4: showHelp

import javax.swing.JDialog; //導入方法依賴的package包/類
private void showHelp()
{
	JDialog dialog = ComponentHelper.createJDialog(comp);
	dialog.getContentPane().add(new HelpPanel(dialog, help));
	dialog.setTitle(CurrentLocale.get("com.tle.admin.plugin.helplistener.title", title)); //$NON-NLS-1$

	dialog.setSize(new Dimension(600, 400));
	ComponentHelper.centreOnScreen(dialog);

	dialog.setModal(true);
	dialog.setVisible(true);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:13,代碼來源:HelpListener.java

示例5: main

import javax.swing.JDialog; //導入方法依賴的package包/類
public static void main(String args[])
{
	JDialog d = new JDialog();
	d.setSize(300, 300);
	d.setModal(true);

	JLinkButton a = new JLinkButton("Hello", new ImageIcon("c:\\image.gif"));
	JLinkButton b = new JLinkButton("Disabled");
	b.setEnabled(false);

	d.getContentPane().add(a);

	d.setVisible(true);
	System.exit(0);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:16,代碼來源:JLinkButton.java

示例6: testDiffView

import javax.swing.JDialog; //導入方法依賴的package包/類
public void testDiffView () throws Throwable {
    // create a file and initial commit
    File file = new File(wc, "file.txt");
    file.createNewFile();

    // chain of change & commit
    StringBuilder content = new StringBuilder();
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 20; ++j) {
            content.append("File change number ").append(i).append("_").append(j).append("\n");
        }
        TestKit.write(file, content.toString());
        System.out.println("Commit nbr. " + i);
        TestKit.commit(wc);
    }

    // local changes
    // changes every few lines
    int pos = content.indexOf("\n");
    while (pos != -1) {
        int nextPos = content.indexOf("\n", pos + 30);
        if (nextPos == -1) {
            pos = -1;
        } else {
            String replaceString = "Local change \nLocal change \nLocal change \n";
            content.replace(pos + 1, nextPos, replaceString);
            pos = nextPos + nextPos - pos + replaceString.length();
            // every 5 next lines
            for (int i = 0; i < 5 && pos != -1; ++i) {
                pos = content.indexOf("\n", pos + 1);
            }
        }
    }
    TestKit.write(file, content.toString());

    boolean showing = SvnSearchHistorySupport.getInstance(file).searchHistory(100);
    assertTrue(showing);

    JDialog d = new JDialog((JFrame)null, "Close dialog");
    d.setModal(false);
    d.setVisible(true);
    while (d.isVisible()) {
        Thread.sleep(1000);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:46,代碼來源:SearchHistoryTest.java

示例7: testDiffView

import javax.swing.JDialog; //導入方法依賴的package包/類
public void testDiffView () throws Throwable {
    // create a file and initial commit
    File file = new File(getWorkTreeDir(), "file.txt");
    file.createNewFile();

    // chain of change & commit
    StringBuilder content = new StringBuilder();
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 20; ++j) {
            content.append("File change number ").append(i).append("_").append(j).append("\n");
        }
        write(file, content.toString());
        System.out.println("Commit nbr. " + i);
        commit(wc);
    }

    // local changes
    // changes every few lines
    int pos = content.indexOf("\n");
    while (pos != -1) {
        int nextPos = content.indexOf("\n", pos + 30);
        if (nextPos == -1) {
            pos = -1;
        } else {
            String replaceString = "Local change \nLocal change \nLocal change \n";
            content.replace(pos + 1, nextPos, replaceString);
            pos = nextPos + nextPos - pos + replaceString.length();
            // every 5 next lines
            for (int i = 0; i < 5 && pos != -1; ++i) {
                pos = content.indexOf("\n", pos + 1);
            }
        }
    }
    write(file, content.toString());

    boolean showing = HgSearchHistorySupport.getInstance(file).searchHistory(100);
    assertTrue(showing);

    JDialog d = new JDialog((JFrame)null, "Close dialog");
    d.setModal(false);
    d.setVisible(true);
    while (d.isVisible()) {
        Thread.sleep(1000);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:46,代碼來源:SearchHistoryTestCase.java

示例8: setEnlargedView

import javax.swing.JDialog; //導入方法依賴的package包/類
/**
 * This method shows the enlarged dialog for the current ontology class instances
 * in order to provide an easier access for the end user.
 */
private void setEnlargedView() {
	
	JDialog dialog = new JDialog(OntologyVisualisationConfiguration.getOwnerWindow());
	dialog.setPreferredSize(new Dimension(100, 200));
	dialog.setName("Ontology-Instance-Viewer");
	dialog.setTitle(OntologyVisualisationConfiguration.getApplicationTitle() +  ": Ontology-Instance-Viewer");
	dialog.setModal(true);
	dialog.setResizable(true);
	dialog.setContentPane(getJContentPane());
	
	// --- Size and center the dialog -----------------
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	int diaWidth = (int) (screenSize.width*0.8);
	int diaHeight = (int) (screenSize.height * 0.9);

	int left = (screenSize.width - diaWidth) / 2;
	int top = (screenSize.height - diaHeight) / 2; 

	dialog.setSize(new Dimension(diaWidth, diaHeight));
    dialog.setLocation(left, top);	
	
    // --- Remind and remove THIS from the parent -----
    this.getDynTableJPanel().setOntologyClassVisualsationVisible(null);
    Container parentContainer = this.getParent();
    parentContainer.remove(this);
    parentContainer.validate();
    parentContainer.repaint();
    
    // --- Add THIS to the dialog ---------------------
    this.removeEnlargeTab();
    jPanel4TouchDown.add(this, BorderLayout.CENTER);
    dialog.setVisible(true);
	// - - - - - - - - - - - - - - - - - - - - - - - -  
    // - - User-Interaction  - - - - - - - - - - - - - 
	// - - - - - - - - - - - - - - - - - - - - - - - -
    this.addEnlargeTab();
	
    // --- Add THIS again to the parent ---------------
    this.getDynTableJPanel().setOntologyClassVisualsationVisible(null);
    parentContainer.add(this);
    parentContainer.validate();
    parentContainer.repaint();
    
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:49,代碼來源:OntologyInstanceViewer.java

示例9: initSpyDialog

import javax.swing.JDialog; //導入方法依賴的package包/類
/**
 * Initializes Spy dialog.
 */
protected void initSpyDialog(Component rootComponent, Component component) {
	if (rootComponent instanceof Dialog) {
		spyDialog = new CaddyDialog((Dialog) rootComponent) {
			@Override
			protected JRootPane createRootPane() {
				return createSpyRootPane();
			}
		};
	} else if (rootComponent instanceof Frame) {
		spyDialog = new CaddyDialog((Frame) rootComponent) {
			@Override
			protected JRootPane createRootPane() {
				return createSpyRootPane();
			}
		};
	} else {
		spyDialog = new JDialog() {
			@Override
			protected JRootPane createRootPane() {
				return createSpyRootPane();
			}
		};
	}
	spyDialog.setName("SwingSpy");
	spyDialog.setTitle("SwingSpy");
	spyDialog.setModal(false);
	spyDialog.setAlwaysOnTop(true);
	Container contentPane = spyDialog.getContentPane();
	contentPane.setLayout(new BorderLayout());
	spyPanel = new SwingSpyPanel();
	spyPanel.reload(rootComponent, component);
	contentPane.add(spyPanel);
	spyDialog.pack();

	spyDialog.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			super.windowClosed(e);
			spyGlass.setVisible(false);
			spyDialog = null;
		}
	});
	spyDialog.setLocationRelativeTo(null);
	spyDialog.setVisible(true);
}
 
開發者ID:igr,項目名稱:swingspy,代碼行數:49,代碼來源:SwingSpy.java

示例10: exportToKML

import javax.swing.JDialog; //導入方法依賴的package包/類
public static void exportToKML(UnknownDataSet ds, DataSelector select) {
	KMLExportConfigDialog fc = null;
	HeaderConfig hc = null;

	// Set up the headers and fields
	do {
		if (hc == null)
			hc = new HeaderConfig((JFrame)ds.map.getTopLevelAncestor(),ds);
		else
			hc.setVisible(true);
		if (hc.visibleV == null) {
			hc.dispose();
			return;
		}

		int imgI = guessImage(ds, hc.visibleV, select);
		fc = new KMLExportConfigDialog((JFrame) ds.map.getTopLevelAncestor(), 
				ds.desc.name.replace(":", ""), hc.visibleV, imgI);
	} while (!fc.export);
	hc.dispose();

	// Get the save file
	JFileChooser jfc = new JFileChooser(System.getProperty("user.home"));
	File f = new File(ds.desc.name.split("\\s")[0] + ".kmz");
	jfc.setSelectedFile(f);

	do {
		int c = jfc.showSaveDialog(null);
		if (c==JFileChooser.CANCEL_OPTION||c==JFileChooser.ERROR_OPTION) return;
		f = jfc.getSelectedFile();
		if (f.exists()) {
			c=JOptionPane.showConfirmDialog(null, "File Already Exists\nConfirm Overwrite");
			if (c==JOptionPane.OK_OPTION) break;
			// if (c==JOptionPane.CANCEL_OPTION) return;
		}
	} while (f.exists());

	int n = 1 + fc.getScales().size();
	n *= select.getRowCount();

	JDialog dialog = new JDialog((JFrame) ds.map.getTopLevelAncestor());
	dialog.setTitle("Exporting to KMZ");
	dialog.setModal(true);
	JProgressBar pb = new JProgressBar(0,n);
	JPanel p = new JPanel();
	p.add(new JLabel("Saving " + f.getName()));
	p.add(pb);

	dialog.getContentPane().setLayout(new FlowLayout());
	dialog.getContentPane().add(p);
	dialog.pack();
	dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	dialog.setLocation(dialog.getOwner().getX() + dialog.getOwner().getWidth() / 2 - dialog.getWidth()/2, 
			dialog.getOwner().getY() + dialog.getOwner().getHeight() / 2 - dialog.getHeight()/2);

	new Task(new Object[] {ds,select,f,fc,hc,pb,dialog}) {
		public void run() {
			exportToKML((UnknownDataSet)args[0],
					(DataSelector)args[1],
					(File)args[2],
					(KMLExportConfigDialog)args[3],
					(HeaderConfig)args[4],
					(JProgressBar)args[5]);
			((JDialog) args[6]).dispose();
		}
	}.start();
	dialog.setVisible(true);
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:69,代碼來源:KMLExport.java


注:本文中的javax.swing.JDialog.setModal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。