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


Java JFrame.add方法代码示例

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


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

示例1: resetLoginUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private void resetLoginUI(int x, int y, JFrame f, JPanel loginPanel, JLabel logoLabel,
		JTextField usernameTextField, JTextField passwordTextField,
		JButton signInButton, JButton logInButton, JButton settingsButton,
		JLabel bgLabel) {

	int i = y - 520;

	f.remove(loginPanel);
	f.setSize(x, y);
	f.revalidate();

	loginPanel.setBounds(0, 0, x, y);
	logoLabel.setBounds(x / 2 - 200, i / 2, 400, 190);
	usernameTextField.setBounds(x / 2 - 200, i / 2 + 200, 400, 100);
	passwordTextField.setBounds(x / 2 - 200, i / 2 + 310, 400, 100);
	signInButton.setBounds(x / 2 - 200, i / 2 + 420, 195, 100);
	logInButton.setBounds(x / 2 + 5, i / 2 + 420, 195, 100);
	settingsButton.setBounds(x - 70, 10, 60, 60);
	bgLabel.setBounds(0, 0, x, y);

	f.add(loginPanel);
	f.revalidate();
	f.repaint();

}
 
开发者ID:berkunal,项目名称:SWEngProject,代码行数:26,代码来源:Menu.java

示例2: initAndShowUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:MissingDragExitEventTest.java

示例3: run

import javax.swing.JFrame; //导入方法依赖的package包/类
public void run() {
    if (this.bar == null) {
        this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
        this.bar.setPreferredSize(new Dimension(400, 20));

        JFrame frame = new JFrame();
        frame.add(this.bar);
        frame.pack();
        frame.setVisible(true);
    }
    else if (40 != this.bar.getValue()) {
        System.out.println("name = " + UIManager.getLookAndFeel().getName());
        System.out.println("value = " + this.bar.getValue());
    }
    else {
        SwingUtilities.getWindowAncestor(this.bar).dispose();
        this.bar = null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Test7163696.java

示例4: createGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void createGUI() {
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton button = new JButton("Default button");
    button.setDefaultCapable(true);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ButtonClickCount++;
        }
    });

    frame.add(button);
    button.setVisible(false);

    frame.getRootPane().setDefaultButton(button);

    frame.setSize(200, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:HiddenDefaultButtonTest.java

示例5: createAndShowGUI

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

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new BorderLayout());

        desktopPane = new JDesktopPane();
        desktopPane.setBackground(BACKGROUND_COLOR);

        frame.add(desktopPane, BorderLayout.CENTER);
        frame.setSize(FRAME_SIZE, FRAME_SIZE);
        frame.setVisible(true);

        internalFrame = new JInternalFrame("Test");
        internalFrame.setSize(FRAME_SIZE / 2, FRAME_SIZE / 2);
        desktopPane.add(internalFrame);
        internalFrame.setVisible(true);
        internalFrame.setResizable(true);

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

示例6: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) 
{
	JPanel header = new ColorPanel( Color.decode("#C6C6C6"), new Dimension(900, 64) ); 
	JPanel navbar = new ColorPanel( Color.decode("#444444"), new Dimension(200, 550) );
	JPanel contentPanel = new ColorPanel( Color.decode("#EEEEEE"), new Dimension(700, 550) );

	JFrame frame = new JFrame("Example App Layout");
	frame.setLayout( new SlickLayout() ); 
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

	//first row
	frame.add( header, new SlickConstraint(0, SlickConstraint.HorizontalFill, SlickConstraint.VerticalPack) );

	//second row
	frame.add( navbar, new SlickConstraint(1, SlickConstraint.HorizontalPack, SlickConstraint.VerticalFill) );
	frame.add( contentPanel, new SlickConstraint(1, SlickConstraint.HorizontalFill, SlickConstraint.VerticalFill) );

	frame.pack();
	frame.setVisible(true);
}
 
开发者ID:jpxor,项目名称:slick,代码行数:21,代码来源:Example_AppLayout.java

示例7: prepareControls

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

    cb = new JComboBox(petStrings);
    cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20));
    cb.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == cb) {
                lwClicked = true;
            }
        }
    });

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

示例8: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		NaiveRayTracer world = createWorld();
		RayTracerPanel panel = new RayTracerPanel(world, 600,600);
		
		frame.add(panel);
		frame.pack();
		
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
		
//		while(true) {
//			Thread.sleep(16);
//			panel.doRenderToBuffer();
//		}
	}
 
开发者ID:jpxor,项目名称:POC-Ray-Tracer,代码行数:19,代码来源:RTracerDemo.java

示例9: createAndShowGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void createAndShowGUI() {
    f = new JFrame();

    final Component component = new JTextField();
    component.addKeyListener(new MyKeyListener());

    f.add(component);
    f.setSize(300, 300);
    f.setLocationRelativeTo(null);
    f.setAlwaysOnTop(true);
    f.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:MouseModifiersInKeyEvent.java

示例10: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args) {
  JFrame f = new JFrame();
  StringEnumConfigurer c = new StringEnumConfigurer(null, "Pick one: ", new String[]{"one", "two", "three"}); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  c.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {
      System.err.println(evt.getPropertyName() + " = " + evt.getNewValue()); //$NON-NLS-1$
    }
  });
  f.add(c.getControls());
  f.pack();
  f.setVisible(true);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:13,代码来源:StringEnumConfigurer.java

示例11: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args)
{
   // Create a label with plain text
   JLabel northLabel = new JLabel("North");
   
   // create an icon from an image so we can put it on a JLabel
   ImageIcon labelIcon = new ImageIcon("GUItip.gif");
   
   // create a label with an Icon instead of text
   JLabel centerLabel = new JLabel(labelIcon);
   
   // create another label with an Icon
   JLabel southLabel = new JLabel(labelIcon);
   
   // set the label to display text (as well as an icon)
   southLabel.setText("South");
   
    // create a frame to hold the labels
   JFrame application = new JFrame();
   
   application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   // add the labels to the frame; the second argument specifies
   // where on the frame to add the label 
   application.add(northLabel, BorderLayout.NORTH);
   application.add(centerLabel, BorderLayout.CENTER);      
   application.add(southLabel, BorderLayout.SOUTH);      

   application.setSize(300, 300); // set the size of the frame
   application.setVisible(true); // show the frame
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:32,代码来源:LabelDemo.java

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

示例13: main

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void main(String[] args)
{
   DrawPanel panel = new DrawPanel();      
   JFrame app = new JFrame();
   
   app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   app.add(panel);
   app.setSize(300, 300);
   app.setVisible(true);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:11,代码来源:TestDraw.java

示例14: createAndShowGUI

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

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JDesktopPane desktopPane = new JDesktopPane();
        desktopPane.setBackground(DESKTOPPANE_COLOR);

        internalFrame = new JInternalFrame("Test") {

            @Override
            public void paint(Graphics g) {
                super.paint(g);
                g.setColor(FRAME_COLOR);
                g.fillRect(0, 0, getWidth(), getHeight());
            }
        };
        internalFrame.setSize(WIN_WIDTH / 3, WIN_HEIGHT / 3);
        internalFrame.setVisible(true);
        desktopPane.add(internalFrame);

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.add(desktopPane, BorderLayout.CENTER);
        frame.add(panel);
        frame.setSize(WIN_WIDTH, WIN_HEIGHT);
        frame.setVisible(true);
        frame.requestFocus();
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:bug8069348.java

示例15: showMetamodel

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


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