Java FlowLayout 确实把我的图片画得很小

发布于 2024-12-25 12:23:22 字数 3085 浏览 4 评论 0原文

我的 FlowLayout 确实将图片画得很小,所以我几乎看不到它们。

我的错是什么?

我稍后的计划是,它看起来像这样:

在此处输入图像描述

所以现在我正在研究内部流布局显示一行颜色分离或直方图。

    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);
    }

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);
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

养猫人 2025-01-01 12:23:22

Image 作为 Icon 放置到JLabel 那么 Image 应该是可调整大小的达到最大值图标的 getWidhtgetHeight

因为您的主题是关于 FlowLayout,所以您在此处发布的代码片段显示了 的用法>GridLayout,如果您接受 Grid 中的所有 Object 将具有相同的 Bounds,那么 LayoutManager 可能是正确的 在屏幕上

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文