0% found this document useful (0 votes)
7 views13 pages

Package Com

The document is a Java Swing application that defines a main window class, JFrmVentana_Principal, which includes a JTextArea and a JButton. It sets up a menu bar with options for 'File' and 'Edit', including items for opening, creating new files, and exiting the application. The main method initializes and displays the window using the Nimbus look and feel if available.

Uploaded by

camila.rrguez03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views13 pages

Package Com

The document is a Java Swing application that defines a main window class, JFrmVentana_Principal, which includes a JTextArea and a JButton. It sets up a menu bar with options for 'File' and 'Edit', including items for opening, creating new files, and exiting the application. The main method initializes and displays the window using the Nimbus look and feel if available.

Uploaded by

camila.rrguez03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

package com.mycompany.

workbenchprovis;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
*
* @author Camil
*/
public class JFrmVentana_Principal extends javax.swing.JFrame {

private JPanel mainPanel;


private JTextArea textArea;
private JButton button;

/**
* Creates new form JFrmVentana_Principal
*/
public JFrmVentana_Principal() {
initComponents();
initCustomComponents();
}

private void initCustomComponents() {


// Crear un JPanel principal donde se cambiará el fondo
mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
// Crear JTextArea y JButton para la ventana principal
textArea = new JTextArea("Este es el JTextArea principal.");
button = new JButton("Botón Principal");

// Agregar los componentes al panel


mainPanel.add(new JScrollPane(textArea), BorderLayout.CENTER);
mainPanel.add(button, BorderLayout.SOUTH);

setContentPane(mainPanel); // Establecer el panel principal como


contenido
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();


jTextPane1 = new javax.swing.JTextPane();
Abrir = new javax.swing.JMenuBar();
jMenu_Archivo = new javax.swing.JMenu();
jMenuItem_Salir = new javax.swing.JMenuItem();
jMenu_Editar = new javax.swing.JMenu();
jMenu_Nuevo = new javax.swing.JMenu();
jMenuItem2 = new javax.swing.JMenuItem();
jScrollPane1.setViewportView(jTextPane1);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jMenu_Archivo.setLabel("Archivo");

jMenuItem_Salir.setText("Salir");
jMenu_Archivo.add(jMenuItem_Salir);

Abrir.add(jMenu_Archivo);

jMenu_Editar.setText("Editar");

jMenu_Nuevo.setText("Nuevo");

jMenuItem2.setText("Nueva Imagen");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu_Nuevo.add(jMenuItem2);

jMenu_Editar.add(jMenu_Nuevo);

Abrir.add(jMenu_Editar);

setJMenuBar(Abrir);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 506, Short.MAX_VALUE)
);
layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 443, Short.MAX_VALUE)
);

pack();
}// </editor-fold>
private void initComponents(){
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
Abrir = new javax.swing.JMenuBar();
jMenu_Archivo = new javax.swing.JMenu();
jMenuItem_Salir = new javax.swing.JMenuItem();
jMenu_Editar = new javax.swing.JMenu();
jMenu_Nuevo = new javax.swing.JMenu();
jMenuItem2 = new javax.swing.JMenuItem();

jScrollPane1.setViewportView(jTextPane1);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jMenu_Archivo.setLabel("Archivo");
jMenuItem_Salir.setText("Salir");
jMenuItem_Salir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem_SalirActionPerformed(evt);
}
});
jMenu_Archivo.add(jMenuItem_Salir);

Abrir.add(jMenu_Archivo);

jMenu_Editar.setText("Editar");

jMenu_Nuevo.setText("Nuevo");

jMenuItem2.setText("Nueva Imagen");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu_Nuevo.add(jMenuItem2);

jMenu_Editar.add(jMenu_Nuevo);

Abrir.add(jMenu_Editar);

setJMenuBar(Abrir);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 506, Short.MAX_VALUE)
);
layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 421, Short.MAX_VALUE)
);

pack();
}// </editor-fold>
}
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(JFrmVentana_Principal.class.getName()).log(j
ava.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(JFrmVentana_Principal.class.getName()).log(j
ava.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(JFrmVentana_Principal.class.getName()).log(j
ava.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(JFrmVentana_Principal.class.getName()).log(j
ava.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrmVentana_Principal().setVisible(true);
}
});
package com.mycompany.workbenchprovis;

/**
*
* @author Camil
*/
public class JFrmVentana_Principal extends javax.swing.JFrame {

/**
* Creates new form JFrmVentana_Principal
*/
public JFrmVentana_Principal() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();


jTextPane1 = new javax.swing.JTextPane();
Abrir = new javax.swing.JMenuBar();
jMenu_Archivo = new javax.swing.JMenu();
jMenuItem_Abrir = new javax.swing.JMenuItem();
jMenuItem_Nuevo = new javax.swing.JMenuItem();
jMenuItem_Salir = new javax.swing.JMenuItem();
jMenu_Editar = new javax.swing.JMenu();
jMenu_Vista = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();

jScrollPane1.setViewportView(jTextPane1);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jMenu_Archivo.setText("Archivo");

jMenuItem_Abrir.setText("Abrir");
jMenuItem_Abrir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem_AbrirActionPerformed(evt);
}
});
jMenu_Archivo.add(jMenuItem_Abrir);

jMenuItem_Nuevo.setText("Nuevo");
jMenu_Archivo.add(jMenuItem_Nuevo);

jMenuItem_Salir.setText("Salir");
jMenu_Archivo.add(jMenuItem_Salir);

Abrir.add(jMenu_Archivo);

jMenu_Editar.setText("Editar");
Abrir.add(jMenu_Editar);
jMenu_Vista.setText("Vista");

jMenuItem1.setText("jMenuItem1");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu_Vista.add(jMenuItem1);

Abrir.add(jMenu_Vista);

setJMenuBar(Abrir);

javax.swing.GroupLayout layout = new


javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 506, Short.MAX_VALUE)
);
layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 421, Short.MAX_VALUE)
);

pack();
}// </editor-fold>
private void jMenuItem_AbrirActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
}

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
}
private void jMenuItem_NuevoActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(JFrmVentana_Principal.class.getName()).log(j
ava.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(JFrmVentana_Principal.class.getName()).log(j
ava.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(JFrmVentana_Principal.class.getName()).log(j
ava.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(JFrmVentana_Principal.class.getName()).log(j
ava.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrmVentana_Principal().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JMenuBar Abrir;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem_Abrir;
private javax.swing.JMenuItem jMenuItem_Nuevo;
private javax.swing.JMenuItem jMenuItem_Salir;
private javax.swing.JMenu jMenu_Archivo;
private javax.swing.JMenu jMenu_Editar;
private javax.swing.JMenu jMenu_Vista;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration
}

You might also like