Hallo allerseits,
ich hab mal wieder etwas für euch!
GUI:
HIntergrund Draw:
läuft ja ganz gut soweit nur das problem ist, wenn ich das starte dann sehe ich vorerst nur das bild. Wenn ich allerdings es minimiere oder INS rand ziehe kommt alles.
wenn ich paint() mache, geht alles den bach runter ...
bitte um hilfe..
ich hab mal wieder etwas für euch!
GUI:
Java:
package sbotapp;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import oracle.jdeveloper.layout.PaneConstraints;
import oracle.jdeveloper.layout.PaneLayout;
import oracle.jdeveloper.layout.XYConstraints;
import oracle.jdeveloper.layout.XYLayout;
public class UI extends JFrame {
private JMenuBar menuBar = new JMenuBar();
private JMenu menuFile = new JMenu();
private JMenuItem menuFileExit = new JMenuItem();
private JMenu menuHelp = new JMenu();
private JMenuItem menuHelpAbout = new JMenuItem();
private JMenuItem jMenuItem1 = new JMenuItem();
private JFormattedTextField currentloctitle =
new JFormattedTextField();
private JFormattedTextField directoryLoc =
new JFormattedTextField();
private JButton startclientbutt = new JButton();
private JButton KillClientbutt = new JButton();
private JList jList1 = new JList();
private JFormattedTextField charlistTitle = new JFormattedTextField();
private JPanel jPanel1 = new JPanel();
private BackgroundPanel mp = new BackgroundPanel();
public UI() {
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setJMenuBar( menuBar );
this.getContentPane().setLayout( null );
this.setSize(new Dimension(757, 341));
this.setTitle( "SBot Manager" );
this.setResizable(false);
menuFile.setText( "File" );
menuFileExit.setText( "Exit" );
menuFileExit.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ae ) { fileExit_ActionPerformed( ae ); } } );
menuHelp.setText( "Help" );
menuHelpAbout.setText( "About" );
menuHelpAbout.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ae ) { helpAbout_ActionPerformed( ae ); } } );
jMenuItem1.setText("Choose Directory");
currentloctitle.setOpaque(false);
currentloctitle.setText("Current Directory...");
currentloctitle.setFont(new Font("Lucida Bright", 1, 14));
currentloctitle.setBorder(BorderFactory.createLineBorder(Color.black, 0));
currentloctitle.setForeground(Color.white);
currentloctitle.setEditable(false);
currentloctitle.setBorder(BorderFactory.createLineBorder(Color.black, 1));currentloctitle.setBounds(new Rectangle(0, 0, 225, 25));
currentloctitle.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
currentloctitle_actionPerformed(e);
}
});
directoryLoc.setEditable(false);
directoryLoc.setOpaque(false);
directoryLoc.setForeground(Color.white);
directoryLoc.setBounds(new Rectangle(0, 25, 755, 35));
startclientbutt.setText("Start Client");
startclientbutt.setFont(new Font("Lucida Sans Unicode", 1, 16));
startclientbutt.setBounds(new Rectangle(400, 95, 145, 60));
KillClientbutt.setText("Kill Client");
KillClientbutt.setFont(new Font("Lucida Sans Unicode", 1, 16));
KillClientbutt.setBounds(new Rectangle(400, 185, 145, 60));
jList1.setBounds(new Rectangle(30, 75, 205, 210));
charlistTitle.setOpaque(false);
charlistTitle.setText("Characters:");
charlistTitle.setFont(new Font("Lucida Bright", 1, 14));
charlistTitle.setEditable(false);
charlistTitle.setBorder(BorderFactory.createLineBorder(Color.black, 1));
charlistTitle.setForeground(Color.white);
charlistTitle.setBounds(new Rectangle(0, 50, 120, 35));
charlistTitle.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
currentloctitle1_actionPerformed(e);
}
});
mp.setBounds(new Rectangle(0, 0, 755, 290));
mp.setLayout(null);
menuFile.add(jMenuItem1);
menuFile.add(menuFileExit);
menuBar.add(menuFile);
menuHelp.add(menuHelpAbout);
menuBar.add(menuHelp);
this.getContentPane().add(charlistTitle, null);
this.getContentPane().add(jList1, null);
this.getContentPane().add(KillClientbutt, null);
this.getContentPane().add(startclientbutt, null);
this.getContentPane().add(directoryLoc, null);
this.getContentPane().add(currentloctitle, null);
this.getContentPane().add(mp, null);
/* mp.add(currentloctitle, new XYConstraints(0, 0, 225, 25));
mp.add(jList1, new XYConstraints(30, 75, 205, 210));
mp.add(directoryLoc, new XYConstraints(0, 25, 755, 35));
mp.add(KillClientbutt, new XYConstraints(400, 185, 145, 60));
mp.add(startclientbutt, new XYConstraints(400, 95, 145, 60));
mp.add(charlistTitle, new XYConstraints(0, 50, 120, 35)); */
}
void fileExit_ActionPerformed(ActionEvent e) {
System.exit(0);
}
void helpAbout_ActionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(this, new UI_AboutBoxPanel1(), "About", JOptionPane.PLAIN_MESSAGE);
}
private void currentloctitle1_actionPerformed(ActionEvent e) {
}
private void currentloctitle_actionPerformed(ActionEvent e) {
}
}
HIntergrund Draw:
Java:
public class BackgroundPanel extends JPanel{
private Image img;
public BackgroundPanel()
{
URL url = getClass().getResource("background.jpg");
img = getToolkit().getImage(url);
}
protected void paintComponent(Graphics g)
{
// Draws the img to the BackgroundPanel.
super.paintComponent(g);
g.drawImage(img, 0, 0, this);
}
}
läuft ja ganz gut soweit nur das problem ist, wenn ich das starte dann sehe ich vorerst nur das bild. Wenn ich allerdings es minimiere oder INS rand ziehe kommt alles.
wenn ich paint() mache, geht alles den bach runter ...
bitte um hilfe..