我的FlowLayout畫的圖片非常小,所以我幾乎看不到它們。Java FlowLayout不會畫我的照片很小
我的錯誤是什麼?
我的計劃就是後來的,它看起來就像這樣:
的內流式佈局,顯示colorSeperations或直方圖中的一行所以現在IAM的工作。
public Window(String pfad, Image bild) {
this.pfad = pfad;
this.bild = bild;
int[] actualScalation1 = new int[2];
Scaler scalerImg1 = new Scaler(bild);
actualScalation1 = scalerImg1.getActualScalation();
// int RGB-int Array
int [][] rgbColorsForPicture;
// Gib mir das Bild als BufferedImage
BufferedImage pictureForColorSeperation = null;
try {
pictureForColorSeperation = BufferImage.drawthePicture(pfad);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Gib mir das Bild als RGB-int Array
rgbColorsForPicture = ImageToolK.readRGBvalues(pictureForColorSeperation);
// Erstelle den roten Farbauszug
ColorSeperation farbauszugRot = new ColorSeperation(rgbColorsForPicture, 0, 0, 0, actualScalation1[0], actualScalation1[1], 0.5);
farbauszugRot.createColorSeperation();
ColorSeperation farbauszugGruen = new ColorSeperation(rgbColorsForPicture, 0, 0, 1, actualScalation1[0], actualScalation1[1], 0.5);
farbauszugGruen.createColorSeperation();
ColorSeperation farbauszugBlau = new ColorSeperation(rgbColorsForPicture, 0, 0, 2, actualScalation1[0], actualScalation1[1], 0.5);
farbauszugBlau.createColorSeperation();
Histogram histogramRot = new Histogram(rgbColorsForPicture, 0, 0, 0, bild.getHeight(null), bild.getWidth(null), 1, 1);
histogramRot.createHistogram(bild.getHeight(null), bild.getWidth(null));
PicturePanel panelbild1 = new PicturePanel(bild, actualScalation1[0], actualScalation1[1]);
PicturePanel panelbild2 = new PicturePanel(bild, actualScalation1[0], actualScalation1[1]);
PicturePanel panelbild3 = new PicturePanel(bild, actualScalation1[0], actualScalation1[1]);
/**
*
* LAYOUTEN
*/
Panel panel1 = new Panel();
Panel glDiagramsAndSeperations = new Panel();
panel1.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
// ((FlowLayout) panel1.getLayout()).setAlignment(FlowLayout.LEFT);
// GridBagLayout gbl = new GridBagLayout();
GridLayout mainWindow = new GridLayout(1, 0, 0, 0);
glDiagramsAndSeperations.setLayout(new GridLayout(0, 1, 0, 0));
//
// GridBagConstraints gbc = new GridBagConstraints();
setLayout(mainWindow); // GridBagLayout setzen
// glDiagramsAndSeperations.add(panel1);
//
panel1.add(farbauszugRot);
panel1.add(farbauszugGruen);
panel1.add(farbauszugBlau);
//
// panel1.add(panelbild1);
// panel1.add(panelbild2);
add(panel1);
this.setBackground(new Color(232, 232, 232));
pack();
setVisible(true);
}
嘗試打印出每個'ColorSeperation'和'panel1'的'getPreferredSize()'。也許他們只是想變小。 – 2012-01-07 01:31:20
爲了儘快提供更好的幫助,請發佈[SSCCE](http://sscce.org/)。 – 2012-01-07 01:32:21
根據羅素的建議進行擴展,是否覆蓋了自定義面板的getPreferredSize()方法以返回圖像的大小? – camickr 2012-01-07 02:16:23