Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
39 lines (37 loc) · 1.47 KB

File metadata and controls

39 lines (37 loc) · 1.47 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//for example
import javax.swing.*;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
public class SimpleCalculator3 {
public static void main(String[] args) {
// set GridBagLayout for window panel
GridBagLayout gb = new GridBagLayout();
this.setLayout(gb);
// create an instanse of the class GridBagConstraints
// these lines of code need to be repeated for each component that is added to
// the cell
GridBagConstraints constr = new GridBagConstraints();
// set restrictions for the input iine of the calculator coordinate x in the
// table
constr.x = 0;
// coordinate y in the table
constr.y = 0;
// the cell has the same height as a standard cell
constr.gridheight = 1;
// the cell has a width equal to the width of 6 standard cells
constr.gridwidth = 6;
// fill the entire cell space
constr.fill = constr.BOTH;
// the horizontal proportion that the component will occupy
constr.weightx = 1.0;
// the vertical proportion that the component will occupy
constr.weighty = 1.0;
// position of the component within the cell
constr.anchor = constr.CENTER;
displayField = new JTextField();
// set restrictions for the input field
gb.setConstraints(displayField, constr);
// add the input field to the window
windowContent.add(displayField);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.