- 1. Clase Graphics
- 2. JButton y JLabel
- 3. JTextField
- 4. BorderLayout
- 5. JCheckBox
- 6. JRadioButton
- 7. JComboBox
- 8. JSlider
- 9. JSpinner
- 10. JToggleButton
- 11. JSeparator
- 12. JDialog
- 13. JProgressBar
- 14. JFormateddTextField
- 15. JEditorPane
- 16. JSplitPane
- 17. JTabbedPane
- 18. JDesktopPane
- 19. JToolBar
- 20. JMenubar
- 21. JTable
- 22. JTree
- 23. JFileChooser
Ejercicio 1
Crea una aplicación de Java Swing que tenga un JDesktopPane con tres JInternalFrame. Cada JInternalFrame debe tener un título diferente, un tamaño distinto y un color de fondo diferente.
package jdesktoppane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
public class Ejercicio1 {
public static void main(String[] args) {
MarcoEscritorio miMarco=new MarcoEscritorio();
miMarco.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
miMarco.setVisible(true);
}
}
class MarcoEscritorio extends JFrame{
public MarcoEscritorio() {
setBounds(0,0,500,500);
setTitle("Escritorio");
setResizable(false);
setLocationRelativeTo(null);
LaminaEscritorio miLamina=new LaminaEscritorio();
add(miLamina);
}
}
class LaminaEscritorio extends JPanel{
public LaminaEscritorio() {
JDesktopPane escritorio =new JDesktopPane();
JInternalFrame rojo =new JInternalFrame("Rojo",true,true,true,true);
rojo.getContentPane().setBackground(Color.red);
rojo.setBounds(10,10,200,200);
rojo.setVisible(true);
JInternalFrame verde =new JInternalFrame("Verde",true,true,true,true);
verde.getContentPane().setBackground(Color.green);
verde.setBounds(220,10,300,300);
verde.setVisible(true);
JInternalFrame azul =new JInternalFrame("Azul",true,true,true,true);
azul.getContentPane().setBackground(Color.blue);
azul.setBounds(10,220,400,400);
azul.setVisible(true);
escritorio.add(rojo);
escritorio.add(verde);
escritorio.add(azul);
setLayout(new BorderLayout());
add(escritorio,BorderLayout.CENTER);
}
}