patternjavaMinor
jInternalFrames code
Viewed 0 times
codejinternalframesstackoverflow
Problem
I'm new to this page I want to ask you to critique my code on jInternalFrame. Basically the problem is that there is no complete example on using this, so I wrote this "template" but I don't know if it lacks of something.
So here is the code(It does 'nothing' just calling, positioning and basic stuff):
Main.java
mTmp.java
```
package forms;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
public class mTmp extends JInternalFrame {
//referencia a singleton
private static mTmp ref;
//desktop, panel, pos. relativa
JDesktopPane desktop;
JPanel panel;
Dimension idx;
//componentes swing
private JButton jButton1;
private JButton jButton2;
private JButton jButton3;
private JPanel jPanel1;
So here is the code(It does 'nothing' just calling, positioning and basic stuff):
Main.java
package forms;
import java.awt.*;
import javax.swing.*;
public class Main {
static JFrame frame;
static panel pan;
static menu men;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
public static void createAndShowGUI() {
UIManager.LookAndFeelInfo look[];
look = UIManager.getInstalledLookAndFeels();
try {
UIManager.setLookAndFeel(look[3].getClassName());
} catch (Exception ex) {
}
frame = new JFrame();
pan = new panel();
men = new menu(pan);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().add(pan);
frame.setJMenuBar(men.getMenuBar());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}mTmp.java
```
package forms;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
public class mTmp extends JInternalFrame {
//referencia a singleton
private static mTmp ref;
//desktop, panel, pos. relativa
JDesktopPane desktop;
JPanel panel;
Dimension idx;
//componentes swing
private JButton jButton1;
private JButton jButton2;
private JButton jButton3;
private JPanel jPanel1;
Solution
Your class names don't follow the normal standard of starting with a capital letter. Also they are not very specific so it is hard to understand what their purpose might be. Your variable names suffer from similar problems of not being
Context
StackExchange Code Review Q#2700, answer score: 5
Revisions (0)
No revisions yet.