T
toef82
Gast
Hallo ich habe folgendes Problem, Ich habe hier ein Panel welches in einem cardlayout eingebettet ist,
wenn das programm startet ist allerdings mein "durchsuchen Button " unsichtbar, erst wenn ich mit der maus über die stelle fahre wo er sein sollte wird er sichtbar..und seltsamer weise, wenn ich ein normales Button nehme, dann ist es von anfang an sichtbar..hätte da einer eine Idee?
wenn das programm startet ist allerdings mein "durchsuchen Button " unsichtbar, erst wenn ich mit der maus über die stelle fahre wo er sein sollte wird er sichtbar..und seltsamer weise, wenn ich ein normales Button nehme, dann ist es von anfang an sichtbar..hätte da einer eine Idee?
Code:
import java.awt.Button;
import java.awt.Choice;
import java.awt.Color;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
//import JavaComPorts.commapi.samples.SerialDemo.SerialParameters;
public class EinstellungsPanel extends JPanel implements ActionListener,ItemListener{
//private SerialParameters parameters;
private JButton durchsuchen;
TextField powerpfad;
ControlerMain mainframe;
private Label portNameLabel;
private Choice portChoice;
private Label baudLabel;
private Choice baudChoice;
private Label flowControlInLabel;
private Choice flowChoiceIn;
private Label flowControlOutLabel;
private Choice flowChoiceOut;
private Label databitsLabel;
private Choice databitsChoice;
private Label stopbitsLabel;
private Choice stopbitsChoice;
private Label parityLabel;
private Choice parityChoice;
private Label rs232;
private Label powerpoint;
EinstellungsPanel(ControlerMain c){
mainframe =c;
this.durchsuchen= new JButton("Durchsuchen..");
this.powerpfad= new TextField("");
powerpoint= new Label("Einstellungen...",Label.LEFT);
portNameLabel = new Label("Port Name:", Label.LEFT);
portChoice = new Choice();
baudLabel = new Label("Baud Rate:", Label.LEFT);
baudChoice = new Choice();
flowControlInLabel = new Label("Flow Control In:", Label.LEFT);
flowChoiceIn = new Choice();
flowControlOutLabel = new Label("Flow Control Out:", Label.LEFT);
rs232= new Label("RS-232 Einstellungen...",Label.LEFT);
flowChoiceOut = new Choice();
parityLabel = new Label("Parity:", Label.LEFT);
parityChoice = new Choice();
databitsChoice = new Choice();
databitsLabel = new Label("Data Bits:", Label.LEFT);
stopbitsLabel = new Label("Stop Bits:", Label.LEFT);
stopbitsChoice = new Choice();
rs232.setFont(new Font("SansSerif", Font.BOLD, 15));
powerpoint.setFont(new Font("SansSerif", Font.BOLD, 20));
powerpoint.setBackground(new Color(253,227,143));
portNameLabel.setBackground(new Color(253,227,143));
baudLabel.setBackground(new Color(253,227,143));
flowControlInLabel.setBackground(new Color(253,227,143));
flowControlOutLabel.setBackground(new Color(253,227,143));
rs232.setBackground(new Color(253,227,143));
databitsLabel.setBackground(new Color(253,227,143));
stopbitsLabel.setBackground(new Color(253,227,143));
parityLabel.setBackground(new Color(253,227,143));
setLayout(null);
this.durchsuchen.setBounds(400,95, 150,30);
this.powerpfad.setBounds(50,100,300,20);
powerpoint.setBounds(30,30,250,30);
portNameLabel.setBounds(30,400,100,20);
portChoice.setBounds(130,400,80,20);
baudLabel.setBounds(30,430,100,20);
baudChoice.setBounds(130,430,80,20);
flowControlInLabel.setBounds(30,460,100,20);
flowChoiceIn.setBounds(130,460,80,20);
flowControlOutLabel.setBounds(230,460,100,20);
rs232.setBounds(30,350,250,50);
flowChoiceOut.setBounds(330,460,80,20);
parityChoice.setBounds(130,490,80,20);
databitsLabel.setBounds(230,430,100,20);
stopbitsLabel.setBounds(230,400,100,20);
databitsChoice.setBounds(330,430,80,20);
stopbitsChoice.setBounds(330,400,80,20);
parityLabel.setBounds(30,490,100,20);
durchsuchen.addActionListener(this);
portChoice.addItemListener(this);
baudChoice.addItemListener(this);
flowChoiceIn.addItemListener(this);
flowChoiceOut.addItemListener(this);
parityChoice.addItemListener(this);
databitsChoice.addItemListener(this);
stopbitsChoice.addItemListener(this);
databitsChoice.addItem("5");
databitsChoice.addItem("6");
databitsChoice.addItem("7");
databitsChoice.addItem("8");
// databitsChoice.select(parameters.getDatabitsString());
baudChoice.addItem("300");
baudChoice.addItem("2400");
baudChoice.addItem("9600");
baudChoice.addItem("14400");
baudChoice.addItem("28800");
baudChoice.addItem("38400");
baudChoice.addItem("57600");
baudChoice.addItem("152000");
flowChoiceIn.addItem("None");
flowChoiceIn.addItem("Xon/Xoff In");
flowChoiceIn.addItem("RTS/CTS In");
flowChoiceOut.addItem("None");
flowChoiceOut.addItem("Xon/Xoff Out");
flowChoiceOut.addItem("RTS/CTS Out");
stopbitsChoice.addItem("1");
stopbitsChoice.addItem("1.5");
stopbitsChoice.addItem("2");
// stopbitsChoice.select(parameters.getStopbitsString());
parityChoice.addItem("None");
parityChoice.addItem("Even");
parityChoice.addItem("Odd");
parityChoice.select("None");
// parityChoice.select(parameters.getParityString());
add(powerpoint);
add(powerpfad);
add(portNameLabel);
add(portChoice);
add(baudLabel);
add(baudChoice);
add(flowControlInLabel);
add(flowChoiceIn);
add(flowControlOutLabel);
add(flowChoiceOut);
add(databitsLabel);
add(databitsChoice);
add(stopbitsLabel);
add(stopbitsChoice);
add(parityLabel);
add(parityChoice);
add(rs232);
this.add(durchsuchen);
//baudChoice.select(Integer.toString(parameters.getBaudRate()));
}
///////////////////////////////////////////////////////////////
public void actionPerformed(ActionEvent ev){
String com=ev.getActionCommand();
if(com.equals("Durchsuchen...")){
FileDialog file=new FileDialog(mainframe,"Powerpoint...??");
/*try{ file.setDirectory("C:");
}catch(Exception e){}
*/file.setVisible(true);
this.powerpfad.setText(new String(file.getDirectory()+file.getFile()));
//mainframe.setPowerPfad(file.getDirectory()+file.getFile());
//System.out.println(this.mainframe.getPowerPfad());
}
}
public void paint(Graphics g){
g.fillRect(30,65,820,5);
}
@Override
public void itemStateChanged(ItemEvent arg0) {
// TODO Auto-generated method stub
}
}