当前位置: 首页>>代码示例>>Java>>正文


Java JFrame.setLocation方法代码示例

本文整理汇总了Java中javax.swing.JFrame.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java JFrame.setLocation方法的具体用法?Java JFrame.setLocation怎么用?Java JFrame.setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFrame的用法示例。


在下文中一共展示了JFrame.setLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showWarning

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Warning with instructions for failed library loading
 */
public static void showWarning() {
	// try to set LaF
	try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	} catch (Exception e2) {
		// do nothing
	} //end System
	JFrame x = new JFrame();
	x.setLayout(new BorderLayout());
	x.setTitle("Libraries missing");
	x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	x.add(new JLabel(
			String.join("",
					new String[] {
							"<html>",
							"<div style=\"padding: 13px; font-size: 10px;\">",
							"Your /lib directory not contain all necessary libraries to run JInput.",
							"<br /><br />",
							"To remedy this, download the latest release of MenuSimulator from",
							"<br />",
							"https://github.com/fatmanspanda/ALTTPMenuPractice/releases",
							"<br /><br />",
							"The application will halt when you close this window.",
							"</div>",
							"</html>"
			})),
			BorderLayout.NORTH);
	x.setMinimumSize(new Dimension(500,300));
	x.setLocation(200, 200);
	x.setVisible(true);
}
 
开发者ID:fatmanspanda,项目名称:ALTTPMenuPractice,代码行数:35,代码来源:MenuPractice.java

示例2: setUp

import javax.swing.JFrame; //导入方法依赖的package包/类
protected void setUp() throws Exception {
    if (setup) return;
    PropUtils.forceRadioButtons=false;
    
    try {
        
        tp = new TProperty("oh", true);
        tp1 = new TProperty2("the", true);
        tp2 = new TProperty2("pretty", true);
        tp3 = new TProperty2("pictures",true);
        tp4 = new TProperty3("I can create",true);
        postSetAction = new PostSetAction();
        
        tn = new TNode();
        
        final PropertySheet ps = new PropertySheet();
        
        //ensure no stored value in preferences:
        ps.setCurrentNode(tn);
        sleep();
        ps.setSortingMode(PropertySheet.UNSORTED);
        
        jf = new JFrame();
        jf.getContentPane().add(ps);
        jf.setLocation(20,20);
        jf.setSize(300, 400);
        new WaitWindow(jf);
        tb = ps.table;
        
        ps.setSortingMode(ps.SORTED_BY_NAMES);
        jf.repaint();
        
        
    } catch (Exception e) {
        e.printStackTrace();
        fail("FAILED - Exception thrown "+e.getClass().toString());
    } finally {
        setup = true;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:PropertyMarkingTest.java

示例3: showSplash

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:20,代码来源:App.java

示例4: CompositionArea

import javax.swing.JFrame; //导入方法依赖的package包/类
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:CompositionArea.java

示例5: onGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void onGUI(){
	frame = new JFrame("Encrypter");
	en = new JButton("Encrypt");
	de = new JButton("Decrypt");
	panel = new JPanel();
	panel2 = new JPanel();
	panel3 = new JPanel();
	input = new JTextField("input file this is");
	output = new JTextField(10);
	code  = new JTextField(5);
	codeIn = new JTextField("Enter the Registration ID Raw");
	trans = new JButton("Get the Real Registration ID");
	frame.getContentPane().add(panel, BorderLayout.NORTH);
	frame.getContentPane().add(panel2, BorderLayout.CENTER);
	frame.getContentPane().add(panel3, BorderLayout.SOUTH);
	panel.add(input);
	panel.add(output);
	panel.add(code);
	panel2.add(en);
	panel2.add(de);
	panel3.setLayout(new GridLayout(2,1));
	panel3.add(codeIn);
	panel3.add(trans);
	trans.addActionListener(event -> getRealID(codeIn.getText()));
	en.addActionListener(event -> encrypt(input.getText(),output.getText(),Integer.parseInt(code.getText())));
	de.addActionListener(event -> decrypt(input.getText(),output.getText(),Integer.parseInt(code.getText())));
	frame.setLocation(1366/3, 768/3);
	frame.setDefaultCloseOperation(3);
	frame.setSize(500, 300);
	frame.setVisible(true);
}
 
开发者ID:sxysun,项目名称:Community_Tieba-Data-Analyzer,代码行数:32,代码来源:Test.java

示例6: Progressbar

import javax.swing.JFrame; //导入方法依赖的package包/类
public Progressbar(String title, int max) {
	pbar = new JProgressBar();
	pbar.setMinimum(0);
	pbar.setMaximum(max);
	pbar.setPreferredSize(new Dimension(500, 20));
	add(pbar);
	JFrame frame = new JFrame(title);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setContentPane(this);
	frame.setSize(new Dimension(500, 65));
	frame.setVisible(true);
	Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
	frame.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);
}
 
开发者ID:Moudoux,项目名称:EMC-Installer,代码行数:15,代码来源:Progressbar.java

示例7: errMessage

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void errMessage(String s){
	JFrame frame = new JFrame("Error Message");
	JLabel label = new JLabel(s);
	JPanel panel = new JPanel();
	frame.getContentPane().add(panel);
	panel.add(label);
	frame.setVisible(true);
	frame.setSize(s.length() * 7, 100);
	frame.setLocation(Config.getIns().getWindowXLocation(), Config.getIns().getWindowYLocation());
	frame.setResizable(true);
	frame.setDefaultCloseOperation(3);
}
 
开发者ID:sxysun,项目名称:Community_Tieba-Data-Analyzer,代码行数:13,代码来源:Util.java

示例8: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args)
{ 
   JFrame frame = new JFrame("GBA Fire Emblem Conversation Maker");
   frame.setResizable(false);
   frame.setSize(width, height);
   frame.setLocation(0, 0);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setContentPane(new MainPanel());
   frame.setVisible(true);
}
 
开发者ID:rasambowl,项目名称:FE8CM,代码行数:11,代码来源:FE8CM.java

示例9: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {  
	  
    CollapsablePanel cp = new CollapsablePanel("test", buildPanel());  
  
    JFrame f = new JFrame();  
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
    f.getContentPane().add(new JScrollPane(cp));  
    f.setSize(360, 500);  
    f.setLocation(200, 100);  
    f.setVisible(true);  
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:12,代码来源:CollapsablePanel.java

示例10: setLocation

import javax.swing.JFrame; //导入方法依赖的package包/类
private static Rectangle setLocation(JFrame frame, GraphicsDevice device) {
    GraphicsConfiguration conf = device.getDefaultConfiguration();
    Rectangle bounds = conf.getBounds();

    // put just below half screen
    int x = bounds.x + bounds.width/2;
    int y = bounds.y + bounds.height/2;
    frame.setLocation(x, y);

    return bounds;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:bug8071705.java

示例11: JTextFieldDemo1

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void JTextFieldDemo1() {

		jf = new JFrame("TextField����");

		final Container contentPane = jf.getContentPane();
		contentPane.setLayout(new BorderLayout());

		jp = new JPanel();

		jtf1 = new JTextField();
		jtf2 = new JTextField(10);
		jtf3 = new JTextField("ָ���ı�����");
		jtf4 = new JTextField("ָ������+ָ������(ֻ��״̬)", 30);

		jtf3.setEnabled(false); // true���Ա༭
		jtf4.setFont(new Font("����", Font.BOLD | Font.ITALIC, 16)); // ���壬�Ƿ�Ӵ֡�б�壬�ֺ�
		// �����ı���ˮƽ���뷽ʽ
		jtf4.setHorizontalAlignment(SwingConstants.CENTER);

		jp.add(jtf1);
		jp.add(jtf2);
		jp.add(jtf3);
		jp.add(jtf4);

		contentPane.add(jp);

		jf.pack();
		jf.setLocation(400, 200);
		jf.setVisible(true);
		jf.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:37,代码来源:TextField.java

示例12: setUp

import javax.swing.JFrame; //导入方法依赖的package包/类
protected void setUp() throws Exception {
    // Create new TEditor
    te = new TEditor();
    // Create new TNode
    tn = new TNode();
    
    //Replacing NodeOp w/ JFrame to eliminate depending on full IDE init
    //and long delay while waiting for property sheet thus requested to
    //initialize
    final JFrame jf = new JFrame();
    ps = new PropertySheet();
    jf.getContentPane().setLayout(new BorderLayout());
    jf.getContentPane().add(ps, BorderLayout.CENTER);
    jf.setLocation(30,30);
    jf.setSize(500,500);
    
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            ps.setNodes(new Node[] {tn});
            //ps.setCurrentNode(tn);
            jf.show();
        }
    });
    
    jf.show();
    new ExtTestCase.WaitWindow(jf);
    
    try {
        // Wait for the initialization
        for (int i = 0; i < 10; i++) {
            final String asText = te.getAsText();
            if (asText == null || asText.equals("null")) {
                //System.out.println("null");
                Thread.sleep(1000);
            } else break;
        }
        ensurePainted(ps);
        
    } catch (Exception e) {
        fail("FAILED - Exception thrown "+e.getClass().toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:IndexedPropertyTest.java

示例13: setUp

import javax.swing.JFrame; //导入方法依赖的package包/类
protected void setUp() throws Exception {
    // Create new TEditor
    te = new TEditor();
    // Create new TNode
    tn = new TNode();
    
    //Replacing NodeOp w/ JFrame to eliminate depending on full IDE init
    //and long delay while waiting for property sheet thus requested to
    //initialize
    final JFrame jf = new JFrame();
    ps = new PropertySheet();
    jf.getContentPane().setLayout(new BorderLayout());
    jf.getContentPane().add(ps, BorderLayout.CENTER);
    jf.setLocation(30,30);
    jf.setSize(500,500);
    final Node[] nodes = new Node[]{tn};
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            ps.setNodes(nodes);
            //ps.setCurrentNode(tn);
            jf.show();
        }
    });
    
    jf.show();
    new ExtTestCase.WaitWindow(jf);
    
    try {
        // Wait for the initialization
        for (int i = 0; i < 10; i++) {
            final String asText = te.getAsText();
            if (asText == null || asText.equals("null")) {
                //System.out.println("null");
                Thread.sleep(1000);
            } else break;
        }
        ensurePainted(ps);
        
    } catch (Exception e) {
        fail("FAILED - Exception thrown "+e.getClass().toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:NodeDeletionTest.java

示例14: setUp

import javax.swing.JFrame; //导入方法依赖的package包/类
protected void setUp() throws Exception {
    
    //            UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
    //            UIManager.setLookAndFeel(new com.sun.java.swing.plaf.gtk.GTKLookAndFeel());
    PropUtils.forceRadioButtons=false;
    try {
        //            if (setup) return;
        basicProp= new BasicProperty("basicProp", true);
        System.err.println("Created basicProp at " + System.currentTimeMillis() + " - " + basicProp);
        
        tags1 = new TagsProperty("tags1", true, new String[] {"What","is","the","meaning","of","life"});
        tags2 = new TagsProperty("tags2", true, new String[] {"Austrolopithecines","automatically","engender","every","one"});
        tags3 = new TagsProperty("tags3", true, new String[] {"Behold","the","power","of","cheese"});
        booleanProp = new BooleanProperty("booleanProp", true);
        customProp = new CustomProperty("CustomProp", true);
        customProp2 = new CustomProperty("CustomProp2", true);
        ExceptionProperty exProp = new ExceptionProperty("Exception prop", true);
        NumProperty numProp = new NumProperty("Int prop", true);
        EditableNumProperty edProp = new EditableNumProperty("Editable", true);
        stringProp = new StringProperty("stringProp",true);
        
        // Create new BasicEditor
        te = new BasicEditor();
        // Create new TNode
        tn = new TNode();
        
        System.err.println("Crating frame");
        jf = new JFrame();
        jf.getContentPane().setLayout(new BorderLayout());
        jp = new JPanel();
        jp.setLayout(new FlowLayout());
        jf.getContentPane().add(jp, BorderLayout.CENTER);
        jf.setLocation(20,20);
        jf.setSize(600, 200);
        
        synchronized (jp.getTreeLock()) {
            System.err.println("BasicProp = " + basicProp);
            
            basicRen = new EditablePropertyDisplayer(basicProp);
            tagsRen1 = new EditablePropertyDisplayer(tags1);
            tagsRen2 = new EditablePropertyDisplayer(tags2);
            tagsRen3 = new EditablePropertyDisplayer(tags3);
            boolRen = new EditablePropertyDisplayer(booleanProp);
            custRen = new EditablePropertyDisplayer(customProp);
            custRen2 = new EditablePropertyDisplayer(customProp2);
            exRen = new EditablePropertyDisplayer(exProp);
            numRen = new EditablePropertyDisplayer(numProp);
            edRen = new EditablePropertyDisplayer(edProp);
            stringRen = new EditablePropertyDisplayer(stringProp);
            
            tagsRen2.setRadioButtonMax(10);
            
            jp.add(basicRen);
            jp.add(tagsRen1);
            jp.add(tagsRen2);
            jp.add(tagsRen3);
            jp.add(boolRen);
            jp.add(custRen);
            jp.add(custRen2);
            jp.add(numRen);
            jp.add(edRen);
            jp.add(stringRen);
        }
        
        System.err.println("Waiting for window");
        new WaitWindow(jf);  //block until window open
        System.err.println("Window shown");
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        setup = true;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:74,代码来源:EditableDisplayerTest.java

示例15: SimpleGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
/** The constructor; this method will be called by the AWT event thread, using the "invokeLater" method. */
private SimpleGUI (final String[] args) {

    // Register an exception handler for uncaught exceptions
    MailBug.setup();

    // Enable better look-and-feel
    if (Util.onMac() || Util.onWindows()) {
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Alloy Analyzer "+Version.version());
        System.setProperty("com.apple.mrj.application.growbox.intrudes","true");
        System.setProperty("com.apple.mrj.application.live-resize","true");
        System.setProperty("com.apple.macos.useScreenMenuBar","true");
        System.setProperty("apple.laf.useScreenMenuBar","true");
        try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable e) { }
    }

    // Figure out the desired x, y, width, and height
    int screenWidth=OurUtil.getScreenWidth(), screenHeight=OurUtil.getScreenHeight();
    int width=AnalyzerWidth.get();
    if (width<=0) width=screenWidth/10*8; else if (width<100) width=100;
    if (width>screenWidth) width=screenWidth;
    int height=AnalyzerHeight.get();
    if (height<=0) height=screenHeight/10*8; else if (height<100) height=100;
    if (height>screenHeight) height=screenHeight;
    int x=AnalyzerX.get(); if (x<0) x=screenWidth/10; if (x>screenWidth-100) x=screenWidth-100;
    int y=AnalyzerY.get(); if (y<0) y=screenHeight/10; if (y>screenHeight-100) y=screenHeight-100;

    // Put up a slash screen
    final JFrame frame = new JFrame("Alloy Analyzer");
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.pack();
    if (!Util.onMac() && !Util.onWindows()) {
       String gravity = System.getenv("_JAVA_AWT_WM_STATIC_GRAVITY");
       if (gravity==null || gravity.length()==0) {
          // many Window managers do not respect ICCCM2; this should help avoid the Title Bar being shifted "off screen"
          if (x<30) { if (x<0) x=0; width=width-(30-x);   x=30; }
          if (y<30) { if (y<0) y=0; height=height-(30-y); y=30; }
       }
       if (width<100) width=100;
       if (height<100) height=100;
    }
    frame.setSize(width,height);
    frame.setLocation(x,y);
    frame.setVisible(true);
    frame.setTitle("Alloy Analyzer "+Version.version()+" loading... please wait...");
    final int windowWidth = width;
    // We intentionally call setVisible(true) first before settings the "please wait" title,
    // since we want the minimized window title on Linux/FreeBSD to just say Alloy Analyzer

    // Test the allowed memory sizes
    final WorkerEngine.WorkerCallback c = new WorkerEngine.WorkerCallback() {
        private final List<Integer> allowed = new ArrayList<Integer>();
        private final List<Integer> toTry = new ArrayList<Integer>(Arrays.asList(256,512,768,1024,1536,2048,2560,3072,3584,4096));
        private int mem;
        public synchronized void callback(Object msg) {
            if (toTry.size()==0) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() { SimpleGUI.this.frame=frame; SimpleGUI.this.finishInit(args, allowed, windowWidth); }
                });
                return;
            }
            try { mem=toTry.remove(0); WorkerEngine.stop(); WorkerEngine.run(dummyTask, mem, 128, "", "", this); return; } catch(IOException ex) { fail(); }
        }
        public synchronized void done() {
            //System.out.println("Alloy4 can use "+mem+"M"); System.out.flush();
            allowed.add(mem);
            callback(null);
        }
        public synchronized void fail() {
            //System.out.println("Alloy4 cannot use "+mem+"M"); System.out.flush();
            callback(null);
        }
    };
    c.callback(null);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:76,代码来源:SimpleGUI.java


注:本文中的javax.swing.JFrame.setLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。