package javaapplication1;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setTitle("Frame");
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
device.setFullScreenWindow(frame);
device.setDisplayMode(new DisplayMode(800, 600, 32, 60));
frame.setVisible(true);
JButton btn = new JButton();
btn.setText("Button");
JPanel panel = new JPanel();
panel.add(btn);
frame.add(panel);
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent …Run Code Online (Sandbox Code Playgroud) JavaApplication1.java
这是我打电话给我单独的小组的地方.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import javax.swing.JFrame;
/**
*
* @author Aires
*/
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JFrame f = new JFrame();
NewJPanel n1 = new NewJPanel();
f.add(n1);
f.pack();
f.show();
}
}
Run Code Online (Sandbox Code Playgroud)
newJPanel.java即时创建新的JLabel以添加到我当前的面板中,但是当我运行该程序时,它没有显示出来.
/*
* To change this template, choose Tools | Templates
* and …Run Code Online (Sandbox Code Playgroud)