Ejemplo 1: java create jframe
import javax.swing.JFrame;
public class example {
public static void main(String[] args){
JFrame frame = new JFrame();
frame.setSize(100,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOES);
frame.setTitle("Example Frame");
frame.setVisible(true);
}
}
Ejemplo 2: cómo crear un JFrame en java
import javax.swing.JFrame;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.Color;
public class ChrismasTree {
public static void main(String[] args) {
JFrame window = new JFrame();
window.setTitle("Christmas Tree");
window.setSize(800, 1000);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
DrawingComponent DC = new DrawingComponent();
window.add(DC);
}
}
class DrawingComponent extends JComponent{
public void paint(Graphics graph0){
Graphics2D graph = (Graphics2D) graph0;
graph.setColor(Color.LIGHT_GRAY);
graph.draw(new Rectangle(0, 710, 70, 60));
graph.setColor(Color.BLUE);
graph.draw(new Rectangle(70, 600, 50, 100));
graph.setColor(Color.BLACK);
}
}
Ejemplo 3: ventana de creación de java
//THIS IS A FIX OF THE ONE BY FRANCY FROG
//THEY FIXED THEIRS
import javax.swing.JFrame;
public class example {
public static void main(String[] args){
JFrame frame = new JFrame();
frame.setSize(100,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Example Frame");
frame.setVisible(true);
}
}
Ejemplo 4: ejemplo de jframe simple de java
import javax.swing.*;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.*;
public class JFrameExample{
public static void main(String[] args){
// Create frame with title Registration Demo
JFrame frame= new JFrame();
frame.setTitle("JFrame Demo");
frame.pack();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Ejemplo 5: como importar jframe en java
import javax.swing.JFrame;
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)