Hey allemaal,
Ik heb een probleem... en dat probleem is namelijk dit:
Ik heb hier drie klassen
- 1ste klas die roept een JFrame op en
- de 2e class zorgt voor onderandere buttons enzo. en hier gaat het fout... op één of andere manier blijft ie steken op een bepaalde grootte... als ik em zet naar bijv. 800x600 dan...
blijft ie gewoon bij zijn vorige grootte.
- De derde class is de class voor 't oproepen van een gif voor de splash.
Ik heb em ook geprobeerd de grootte te veranderen in de 1ste class zelf.. maar dat wil ook niet..
hieronder zijn de codes:
Ik heb een probleem... en dat probleem is namelijk dit:
Ik heb hier drie klassen
- 1ste klas die roept een JFrame op en
- de 2e class zorgt voor onderandere buttons enzo. en hier gaat het fout... op één of andere manier blijft ie steken op een bepaalde grootte... als ik em zet naar bijv. 800x600 dan...
- De derde class is de class voor 't oproepen van een gif voor de splash.
Ik heb em ook geprobeerd de grootte te veranderen in de 1ste class zelf.. maar dat wil ook niet..
hieronder zijn de codes:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| import javax.swing.UIManager;
import java.awt.*;
public class SplashApp {
boolean packFrame = false;
public SplashApp() {
FrameMain frame = new FrameMain();\
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int)(screenSize.getWidth() - 500) / 2;
int y = (int)(screenSize.getHeight() - 400) / 2;
frame.setLocation(x, y);
frame.pack();
frame.show();
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
SplashApp slashApp = new SplashApp();
}
} |
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FrameMain extends JFrame {
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
JTextArea jTextArea1 = new JTextArea();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JButton jButton1 = new JButton();
JRadioButton jRadioButton1 = new JRadioButton();
FrameSplash frmSplash;
public FrameMain(){
try{
frmSplash = new FrameSplash(this, 5000, "splash.gif");
frmSplash = null;
jbInit();
pack();
}
catch(Exception ex){
JOptionPane.showMessageDialog(this, ex, "Exception", JOptionPane.ERROR_MESSAGE);
}
}
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
jTextArea1.setText("jTextArea1");
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Main Frame");
jLabel1.setText("jLabel1");
jLabel2.setText("jLabel2");
jButton1.setText("jButton1");
jRadioButton1.setText("jRadioButton1");
contentPane.add(jTextArea1, BorderLayout.CENTER);
contentPane.add(jLabel1, BorderLayout.NORTH);
contentPane.add(jLabel2, BorderLayout.SOUTH);
contentPane.add(jButton1, BorderLayout.WEST);
contentPane.add(jRadioButton1, BorderLayout.EAST);
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
} |
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
| import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FrameSplash extends JWindow implements MouseListener, WindowListener, ActionListener{
private Image splashImage;
private int imgWidth, imgHeight;
private String imgName;
private Toolkit tk;
private boolean windowOpened = false;
private Timer timer;
public FrameSplash(Frame parent, int milliSecs, String imgName){
super(parent);
this.imgName = imgName;
this.addMouseListener(this);
parent.addWindowListener(this);
tk = Toolkit.getDefaultToolkit();
splashImage = loadSplashImage();
showSplashScreen();
timer = new Timer(milliSecs, this);
timer.start();
}
public Image loadSplashImage(){
MediaTracker tracker = new MediaTracker(this);
Image result;
result = tk.getImage(imgName);
tracker.addImage(result, 0);
try { tracker.waitForAll(); }
catch (InterruptedException e) {}
imgWidth = result.getWidth(this);
imgHeight = result.getHeight(this);
return (result);
}
public void showSplashScreen(){
Dimension screenSize = tk.getScreenSize();
setBackground(Color.white);
int w = imgWidth;
int h = imgHeight;
int x = (screenSize.width - w) /2;
int y = (screenSize.height - h) /2;
setBounds(x, y, w, h);
show();
}
public void paint(Graphics g){
g.drawImage(splashImage, 0, 0, imgWidth, imgHeight, Color.white, this);
}
public void actionPerformed(ActionEvent e){
if (windowOpened){
dispose();
}
}
public void mousePressed(MouseEvent e){
dispose();
}
public void mouseReleased(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void windowOpened(WindowEvent e){
if (timer.isRunning()){
windowOpened = true;
}
else{
dispose();
}
}
public void windowClosing(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
} |
[AMD XP 2400@2.0GhZ | Asus A7V8X-X | 512 DDR-RAM | Sapphire Ati Radeon 9800 Pro 128 MB | 80GB Maxtor 5400] && [AMD DURON 800@800 | MSI KT266A Pro2 | 256 DDR-RAM | GeForce2 MX/MX400 64MB | 20GB Maxtor 5400]