本文整理汇总了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();
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
// }
}
示例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);
}
示例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);
}
示例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
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}