1

My FlowLayout does paint the pictures very small so i nearly cant see them.

Whats my mistake ?

My plan later is, that it will look like this:

enter image description here

So now iam working on the inner Flow Layout which displays one line of colorSeperations or histograms.

    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);
    }
kleopatra
  • 51,061
  • 28
  • 99
  • 211
Furtano
  • 375
  • 1
  • 3
  • 15

1 Answers1

1

put Image as Icon to the JLabel then Image should be resiziable up to maximum Icon's getWidht and getHeight

since your topic is about FlowLayout, code snipped that you posted here showed usage of GridLayout, that could be correct LayoutManager if you accepting that all Object in the Grid will have the same Bounds on the screen

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • I cant, i have to use only AWT, not SWING. No other chance? – Furtano Jan 07 '12 at 01:34
  • please don't take as attack to your person, why do you use API that came from last milenium, from year 2002 is there Swing, you must have got important reason for use AWT instead of Swing, e.g. implementations for OpenGL – mKorbel Jan 07 '12 at 01:39
  • yes but its the task and i designed the program (paint methods in panels) for that, i dont want/can change to swing now in this project. SO, is there a way to do this with AWT? – Furtano Jan 07 '12 at 01:43
  • there are three areas used 1) paint() method --> replace any number for Widht and Height with getWidht/getHeight then your BufferedImage should be resizible/cropped scallable by rules that came from used LayoutManager 2) this change from paint() to the Icon is question pass BufferedImage to the Icon, then Icon to the JLabel 3) as mentioned post a SSCCE, because your code snipped doesn't showed whatever about paint and sizing .... – mKorbel Jan 07 '12 at 01:58
  • Why can't you change to Swing? Basically all you have to do is add a "J" to all your components. – camickr Jan 07 '12 at 02:14