Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Penggalan Source code Keluaran / Output

package latihanframe;

import javax.swing.JOptionPane;

/*
* To change this license header, choose License
Headers in Project Properties.
* To change this template file, choose Tools |
Templates
* and open the template in the editor.
*/

/**
*
* @author johan.budiman@upj.ac.id
*/
public class latihanframe2 extends
javax.swing.JFrame {
private latihanframe_aplikasi1_jinternalframe
ifraplikasi2;
/**
* Creates new form latihanframe2
*/
public latihanframe2() {
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() {
DpUtama = new javax.swing.JDesktopPane();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
menubuka = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();

setDefaultCloseOperation(javax.swing.WindowCo
nstants.EXIT_ON_CLOSE);
addComponentListener(new
java.awt.event.ComponentAdapter() {
public void
componentShown(java.awt.event.ComponentEve
nt evt) {
formComponentShown(evt);
}
});

DpUtama.addComponentListener(new
java.awt.event.ComponentAdapter() {
public void
componentShown(java.awt.event.ComponentEve
nt evt) {
DpUtamaComponentShown(evt);
}
});

javax.swing.GroupLayout DpUtamaLayout =
new javax.swing.GroupLayout(DpUtama);
DpUtama.setLayout(DpUtamaLayout);
DpUtamaLayout.setHorizontalGroup(

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

DpUtamaLayout.createParallelGroup(javax.swing.
GroupLayout.Alignment.LEADING)
.addGap(0, 498, Short.MAX_VALUE)
);

jMenu1.setText("File");

menubuka.setText("Buka Aplikasi");
menubuka.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt)
{
menubukaActionPerformed(evt);
}
});
jMenu1.add(menubuka);

jMenuBar1.add(jMenu1);

jMenu2.setText("Edit");
jMenuBar1.add(jMenu2);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new


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

layout.createParallelGroup(javax.swing.GroupLay
out.Alignment.LEADING)
.addComponent(DpUtama)
);
layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLay
out.Alignment.LEADING)
.addComponent(DpUtama,
javax.swing.GroupLayout.Alignment.TRAILING)
);

pack();
setLocationRelativeTo(null);
}// </editor-fold>

private void
formComponentShown(java.awt.event.Compone
ntEvent evt) {
ifraplikasi2 = new
latihanframe_aplikasi1_jinternalframe();
}

private void
DpUtamaComponentShown(java.awt.event.Com
ponentEvent evt) {
// TODO add your handling code here:
}

private void
menubukaActionPerformed(java.awt.event.Actio
nEvent evt) {
//membuat object ifraplikasi1 dari class
eksternal yang sudah kita buat
// latihanframe_aplikasi1_jinternalframe
if(!(ifraplikasi2.isVisible())) { // Memeriksa
apakah ifraplikasi1 sedang tidak tampil
this.DpUtama.add(ifraplikasi2); //
memasukkan ifraplikasi2 ke desktoppane
ifraplikasi2.setVisible(true); //
Menampilkan ifraplikasi2
}
else
{JOptionPane.showMessageDialog(this,"Aplikasi
2 sudah dibuka");
}
}

/**
* @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/uisw
ing/lookandfeel/plaf.html
*/
try {
for
(javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels
()) {
if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getC
lassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(latihanframe2.
class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(latihanframe2.
class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(latihanframe2.
class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException
ex) {

java.util.logging.Logger.getLogger(latihanframe2.
class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
}
//</editor-fold>

/* Create and display the form */


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

// Variables declaration - do not modify


private javax.swing.JDesktopPane DpUtama;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem menubuka;
// End of variables declaration
}

You might also like