當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。