in Education by
My current problem is that I have a JFrame with a 2x2 GridLayout. And inside one of the squares, I have a JPanel that is to display a grid. I am having a field day with the java swing library... take a look Image Java is automatically expanding each JLabel to fit the screen. I want it to just be those blue squares (water) and the black border and not that gray space. Is there a way I can just set the size of that JPanel permanently so that I don't have to go through changing the size of the JFrame a million times before I get the exact dimension so that the gray space disappears? I also would like to set the size of those buttons so they are not so huge (BorderLayout is being used for the buttons and TextField) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
GridBagLayout is what you really want to use. The GridLayout will force the same size for each component in the layout no matter what size constraints you put on them. GridBagLayout is a lot more powerful and a lot more complicated. Study up on the API page for it. Using GridBagLayout, the components won't fill the whole grid space if you don't want them to and can even stay the size that you ask it to be. To keep a component's size from changing, I would set all three available size constraints: water.setPreferredSize(new Dimension(20, 20)); water.setMinimumSize(new Dimension(20, 20)); water.setMaximumSize(new Dimension(20, 20)); For your buttons, I would definitely use an inner panel as Bryan mentions. You could use either a GridLayout like he suggests or a FlowLayout if you don't want all the buttons to be the same size. Add all your buttons to that inner panel instead of the main one.

Related questions

0 votes
    How can you select a classifier on the basis of training set size?...
asked Mar 11, 2021 in Technology by JackTerrance
0 votes
    I want to load an image from my computer into 2D Graphics so that I can edit it afterwards and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I have 2 buckets prod and dev. Inside .env I have S3_PROD and S3_DEV. I want my system to point ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I have 2 buckets prod and dev. Inside .env I have S3_PROD and S3_DEV. I want my system to point ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    ______ will be called inside par() to set margins. (a) Mai (b) Smai (c) May (d) Jay I have been ... & Neural Networks of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    scale command is used to set a new size for a Deployment, ReplicaSet, Replication Controller. (1)False (2)True...
asked Sep 19, 2021 in Education by JackTerrance
0 votes
    The VM size determines the number of ________ that you can create for a VM. A. Ips B. VIPs C. NICs D. MACs...
asked Nov 20, 2022 in Education by JackTerrance
0 votes
0 votes
0 votes
    EJ Write T for true and F for false. 71. Input devices are used to store the data. 2. Calculations are done ... is a system software. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    I have a grid it has to display some 100 rows from a table. I do not want to set any paging ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    Write html code to set the BGCOLOR as NAVY, header 1 text Text Example with size, colour and font face'' as ... font face ARIAL . Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    I have an EAR file that contains two WARs, war1.war and war2.war. My application.xml file looks ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
0 votes
    if you need to verify what exactly is present inside a repository, how you will do this?...
asked Feb 18, 2021 in Technology by JackTerrance
...