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


Java JFrame.setLayout方法代码示例

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


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

示例1: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {
	JTextFieldDemo1();
	final JFrame f = new JFrame("Welcome To Earth!");
	final JTextField name = new JTextField(30);
	final JTextField noed = new JTextField("HJW", 10);
	final JLabel nameLab = new JLabel("�����û�����:");
	final JLabel noedLab = new JLabel("���ɱ༭�ı� ");
	noed.setEnabled(false);
	name.setColumns(30);
	noed.setColumns(30);
	f.setLayout(new GridLayout(3, 2));// ���ò��ֹ�����
	f.add(nameLab);
	f.add(name);
	f.add(noedLab);
	f.add(noed);
	f.setSize(300, 100);
	f.setLocation(300, 200);
	f.setVisible(true);

}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:21,代码来源:TextField.java

示例2: 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

示例3: setup

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void setup(final Point tmp) {
    comboBox = new JComboBox<>();
    for (int i = 1; i < 7; i++) {
        comboBox.addItem("Long-long-long-long-long text in the item-" + i);
    }
    String property = System.getProperty(PROPERTY_NAME);
    comboBox.putClientProperty(PROPERTY_NAME, Boolean.valueOf(property));
    frame = new JFrame();
    frame.setAlwaysOnTop(true);
    frame.setLayout(new FlowLayout());
    frame.add(comboBox);
    frame.pack();
    frame.setSize(frame.getWidth(), SIZE);
    frame.setVisible(true);
    frame.setLocation(tmp.x, tmp.y);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:JComboBoxPopupLocation.java

示例4: dispatch

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Description: dispatches the console from its current place properly.
 */
public static void  dispatch(JScrollPane scrollPane, JTextPane cons,
                             JTabbedPane outputTabs, Component tabComp, JFrame frame,
                             Boolean consoleOut, Attachable mainFrame) {
    frame.setSize(600, 400);
    frame.setLocationRelativeTo( (Component) mainFrame);
    frame.setLayout(new BorderLayout());
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    
    scrollPane.setViewportView(cons);
    frame.add(scrollPane);
    
    if (frame.getWindowListeners().length > 0)
        frame.removeWindowListener(frame.getWindowListeners()[0]);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            mainFrame.attachConsole();
        }
    });
    frame.setVisible(true);
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:25,代码来源:ConsoleCore.java

示例5: prepareControls

import javax.swing.JFrame; //导入方法依赖的package包/类
protected void prepareControls() {
    frame = new JFrame("Mixing : Dropdown Overlapping test");
    frame.setLayout(new GridLayout(0,1));
    frame.setSize(200, 200);
    frame.setVisible(true);

    menuBar = new JMenuBar();
    JMenu menu = new JMenu("Test Menu");
    ActionListener menuListener = new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            lwClicked = true;
        }
    };

    JMenuItem item;
    menu.add(item = new JMenuItem("first"));
    item.addActionListener(menuListener);
    separator = new JSeparator();
    separator.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            spClicked = true;
        }
    });
    menu.add(separator);

    for (int i = 0; i < petStrings.length; i++) {
        menu.add(item = new JMenuItem(petStrings[i]));
        item.addActionListener(menuListener);
    }
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);

    propagateAWTControls(frame);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:JMenuBarOverlapping.java

示例6: setup

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void setup() {
    /**
     * Note the input type is not restricted to "submit". Types "image",
     * "checkbox", "radio" have the same problem.
     */
    html = new JEditorPane("text/html",
            "<html><body><form action=\"http://localhost.cgi\">"
                    + "<input type=submit name=submit value=\"submit\"/>"
                    + "</form></body></html>");
    frame = new JFrame();
    frame.setLayout(new BorderLayout());
    frame.add(html, BorderLayout.CENTER);
    frame.setSize(200, 100);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:bug7189299.java

示例7: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {

        JFrame frame = new JFrame();
        frame.setLayout(new FlowLayout());
        frame.setVisible(true);
		
        JButton button1 = new JButton("点我!");
        JButton button2 = new JButton("也点我!");
		
        frame.getContentPane().add(button1);
        frame.getContentPane().add(button2);
        //这里addActionListener方法的参数是ActionListener,是一个函数式接口
        //使用lambda表达式方式
        button1.addActionListener(e -> { System.out.println("这里是Lambda实现方式"); });
        //使用方法引用方式
        button2.addActionListener(TestMethodReference::doSomething);
        
    }
 
开发者ID:juebanlin,项目名称:util4j,代码行数:19,代码来源:TestMethodReference.java

示例8: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main( String[] args ) {

        JFrame frame = new JFrame( "" );
        frame.setLayout( new FlowLayout() );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.getContentPane().add( new CorpsePanel( "", new MockPlugin() ) );
        frame.setSize( 1200, 800 );
//    	frame.pack();
        frame.setVisible( true );

    }
 
开发者ID:lauriholmas,项目名称:batmapper,代码行数:12,代码来源:CorpseTest1.java

示例9: test

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void test() {
    JFrame frame = new JFrame();
    frame.setPreferredSize(new Dimension(400, 400));
    frame.setLayout(new BorderLayout());
    JExpandableTextArea eta = new JExpandableTextArea(10, 20);
    JScrollPane sp = new JScrollPane(eta);
    JPanel panel = new JPanel();
    panel.add(sp);
    frame.add(panel, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:14,代码来源:JExpandableTextArea.java

示例10: LogWindow

import javax.swing.JFrame; //导入方法依赖的package包/类
public LogWindow() {
	frame = new JFrame();
	frame.setTitle("Latest Log");
	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	frame.setSize(600, 480);
	frame.setLocationRelativeTo(null);
	frame.setResizable(false);
	frame.setLayout(null);
	
	panel = new JPanel();
	frame.add(panel);
	
	init();
}
 
开发者ID:JudgeGlass,项目名称:Install_Builder_Universal,代码行数:15,代码来源:LogWindow.java

示例11: displayImage

import javax.swing.JFrame; //导入方法依赖的package包/类
public void displayImage(Image img2) {
    //BufferedImage img=ImageIO.read(new File("/HelloOpenCV/lena.png"));
    ImageIcon icon = new ImageIcon(img2);
    JFrame frame = new JFrame();
    frame.setLayout(new FlowLayout());
    frame.setSize(img2.getWidth(null) + 50, img2.getHeight(null) + 50);
    JLabel lbl = new JLabel();
    lbl.setIcon(icon);
    frame.add(lbl);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:14,代码来源:OpenCVFlow.java

示例12: createPanel

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Creates an instance of JFrame {@link #panel} and adds the graph view {@link #view} to the {@link #panel}.
 * @author Shashank B S
 */
private void createPanel() {
	JFrame temp = new JFrame();
	temp.setLayout(new BorderLayout());
	panel = temp.getContentPane();
	panel.add(headerBar,BorderLayout.PAGE_START);
	panel.add(view);
	panel.add(settingsBar, BorderLayout.PAGE_END);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:13,代码来源:GraphManager.java

示例13: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main( String[] args ) {

        JFrame frame = new JFrame( "Simple Graph View" );
        frame.setLayout( new FlowLayout() );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.getContentPane().add( new ManualPanel() );

        frame.pack();
        frame.setVisible( true );

    }
 
开发者ID:lauriholmas,项目名称:batmapper,代码行数:12,代码来源:ManualTest1.java

示例14: showModel

import javax.swing.JFrame; //导入方法依赖的package包/类
public void showModel() {
  xmlCreator.setMetamodel(false);
  frame = new JFrame("Visualization");
  frame.setLayout(new BorderLayout());
  frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  frame.add(getGraph(), BorderLayout.CENTER);
  frame.setVisible(true);
  frame.setSize(500, 500);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:Visualization.java

示例15: AboutWindow

import javax.swing.JFrame; //导入方法依赖的package包/类
public AboutWindow() {
	frame = new JFrame();
	frame.setTitle("About");
	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	frame.setSize(325, 280);
	frame.setLocationRelativeTo(null);
	frame.setResizable(false);
	frame.setLayout(null);
	
	panel = new JPanel();
	frame.add(panel);
	
	initialize();
	frame.setVisible(true);
}
 
开发者ID:JudgeGlass,项目名称:Install_Builder_Universal,代码行数:16,代码来源:AboutWindow.java


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