Code:
RootPanel footer = RootPanel.get("footer");
footer.addStyleName(StyleNameGen.createName("mainWidgetFooterStyle"));
footer.add(versionLabel);
footer.add(expirationMessage);
and it puts the versionLabel and thenexpirationMessage `below it.
What to do if I want to put the versionLabelbesides the expirationMessage?
You have to add them both to another container first like a HorizontalLayoutContainer or an HBoxLayoutContainer.
HorizontalLayoutContainer labelContainer = new HorizontalLayoutContainer()
labelContainer.add(versionLabel, new HorizontalLayoutData(-1, -1, new Margins(5)));
labelContainer.add(expirationMessage, new HorizontalLayoutData(-1, -1, new Margins(5)));
footer.add(labelContainer);
If I properly understand you need to place 2 label one over another.
For this you can try:
FlowLayoutContainer somePanel = new FlowLayoutContainer();
mixCont.add(somePanel);
Label versionLabel = new Label("12345678");
Label expirationMessage = new Label("9999999");
versionLabel.getElement().getStyle().setFloat(Style.Float.LEFT);
expirationMessage.getElement().getStyle().setPosition(Position.ABSOLUTE);
expirationMessage.getElement().getStyle().setLeft(20, Unit.PX);
somePanel.add(versionLabel);
somePanel.add(expirationMessage);
Actually next code should solve your problem. Second row helps you in positioning your overlapping message:
expirationMessage.getElement().getStyle().setPosition(Position.ABSOLUTE);
expirationMessage.getElement().getStyle().setLeft(20, Unit.PX);
Related
I'm trying to make an app with a panel where it asks a question (whether an image contains humans, cars, or other objects... and more). Each question is answered with yes/no. I didn't want to make JRadioButton for each of the 'yes's and 'no's. So I tried to add the same Radio Button multiple times but it doesn't work (See below).
contentsPanel = new JPanel();
contentsHumans = new JLabel("Humans? ");
contentsCars = new JLabel("Cars? ");
contentsOtherObjects = new JLabel("Other Objects? ");
yes = new JRadioButton("Yes");
no = new JRadioButton("No");
binaryAnswer = new ButtonGroup();
binaryAnswer.add(yes);
binaryAnswer.add(no);
contentsPanel.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Image contains... "));
contentsPanel.add(contentsHumans);
contentsPanel.add(yes); contentsPanel.add(no);
contentsPanel.add(contentsCars);
contentsPanel.add(yes); contentsPanel.add(no);
contentsPanel.add(contentsOtherObjects);
contentsPanel.add(yes); contentsPanel.add(no);
Do I have to separately create y1 = new JRadioButton("Yes");, y2 = new JRadioButton("Yes");, etc., for all my 'yes's and 'no's?? I can definitely copy and paste to do that but I was wondering if there is any other way.
Here's the image of current output:
I'm new to itext7
Recently, I'm generating custom report pdf by iText7.
There is one layout I want to approach.
Make the vertically text align in the middle of the cell.
To illustrate my purpose, the first screenshot demonstrate my progress.
The second screenshot is what I want.
Here is how I implement my approach.
//Init table
Table table = new Table(UnitValue.createPercentArray(new float[]{20, 20, 20, 20, 20})).setWidth(UnitValue.createPercentValue(100));
//Init cellHeader
Paragraph servicePara = new Paragraph("Date of Service");
servicePara.setBorder(new SolidBorder(new DeviceRgb(5, 10, 50), 1));
servicePara.setBackgroundColor(DeviceCmyk.YELLOW);
servicePara.setRotationAngle(Math.PI / 2);
Cell cell = new Cell();
cell.add(servicePara);
table.addHeaderCell(cell);
I have a transition screen from which I am getting values(s) via a checkbox control, I need to get these values and update them on another checkbox control in the issues view screen. The below code updates the values but doesn't change the checkbox to checked.
platvalue = issue.getCustomFieldValue(platRelOnField) //platRelOnField is the field from where I am getting my values to be set , it has 3 options [High,Low,Medium]
ModifiedValue mVal = new ModifiedValue(issue.getCustomFieldValue(platRelOnAPIField),platvalue);
platRelOnAPIField.updateValue(null, issue, mVal, new DefaultIssueChangeHolder());
I am new to groovy/jira and cant seem to know the right way to set the checkbox options properly.
Any help in the right direction is appreciated.
I am using JIRA 6.3.9
Managed to get it working by writing the below code
ArrayList<LazyLoadedOption> optionsList = new ArrayList<LazyLoadedOption>();
FieldConfig fieldConfig = platRelOnAPIField.getRelevantConfig(issue);
OptionsManager optionManager = ComponentAccessor.getOptionsManager();
platOptions = optionManager.getOptions(fieldConfig);
for(def i = 0;i<platOptions.size();i++){
def optVal = platOptions.get(i).getValue();
if(platOptions.get(i).getValue().equals("custom field value")){
optionsList.add(platOptions.get(i));
break;
}
}
platRelOnAPIField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(platRelOnAPIField), optionsList),changeHolder)
I need to change the value topMargin of my layouts programmatically. I tried the following:
android.widget.LinearLayout.LayoutParams lp_ll = new LinearLayout.LayoutParams(
spaceBtnWidth, buttonHeight);
lp_ll.height = LayoutParams.WRAP_CONTENT;
lp_ll.width = LayoutParams.WRAP_CONTENT;
lp_ll.gravity = Gravity.CENTER_HORIZONTAL;
lp_ll.topMargin = rowDistance;
ll3.setLayoutParams(lp_ll);
ll4.setLayoutParams(lp_ll);
ll5.setLayoutParams(lp_ll);
I want all my 3 layouts ll3, ll4 and ll5 to use the same properties from lp_ll. The problem is now that only my first layout ll3 takes it. The other two don't change. I even tried a different order and put the line where I set ll4 above the ll3 and ll5 lines. Anyways ll3 is being set and the other two don't change their properties.
Thanks
for every layout create a copy of lp_ll
ll4.setLayoutParams(new LinearLayout.LayoutParams(lp_ll));
ll5.setLayoutParams(new LinearLayout.LayoutParams(lp_ll));
You can simply edit your code like this:
android.widget.LinearLayout.LayoutParams lp_ll = new LinearLayout.LayoutParams(
spaceBtnWidth, buttonHeight);
lp_ll.height = LayoutParams.WRAP_CONTENT;
lp_ll.width = LayoutParams.WRAP_CONTENT;
lp_ll.gravity = Gravity.CENTER_HORIZONTAL;
lp_ll.topMargin = rowDistance;
ll3.setLayoutParams(lp_ll);
ll4.setLayoutParams(ll3.getLayoutParams());
ll5.setLayoutParams(ll3.getLayoutParams());
It will still do the same, i hope this helps.
I am trying to make a two column, 3 row layout. Something along the lines of:
----------------------
| Username |Textbox| |
| Email |Textbox| |
----------------------
Yet even when I'm quite sure the groups managed correctly, it still ends up on a single row like so:
I have the vertical groups separated just fine
gl_contentPanel.setHorizontalGroup(
gl_contentPanel.createSequentialGroup()
.addGroup(gl_contentPanel.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(usernameLabel)
.addComponent(emailLabel))
.addGroup(gl_contentPanel.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(usernames)
.addComponent(email))
);
gl_contentPanel.setVerticalGroup(
gl_contentPanel.createSequentialGroup()
.addGroup(gl_contentPanel.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(usernameLabel)
.addComponent(usernames))
.addGroup(gl_contentPanel.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(emailLabel)
.addComponent(email))
);
Any ideas?
You need to set the layout for the container - see mark [1] in the third line below.
To me it looks like you missed that and the container uses FlowLayout.
JFrame frame = new JFrame("GroupLayout Test");
GroupLayout gl_contentPanel = new GroupLayout(frame.getContentPane());
frame.setLayout(gl_contentPanel); // [1]
JLabel usernameLabel = new JLabel("User name");
JLabel emailLabel = new JLabel("Email");
JTextField usernames = new JTextField("usernames");
JTextField email = new JTextField("email");
// your snippet
gl_contentPanel.setHorizontalGroup(
gl_contentPanel.createSequentialGroup()
.addGroup(gl_contentPanel.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(usernameLabel)
.addComponent(emailLabel))
.addGroup(gl_contentPanel.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(usernames)
.addComponent(email))
);
gl_contentPanel.setVerticalGroup(
gl_contentPanel.createSequentialGroup()
.addGroup(gl_contentPanel.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(usernameLabel)
.addComponent(usernames))
.addGroup(gl_contentPanel.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(emailLabel)
.addComponent(email))
);
// end of your snippet
frame.pack();
frame.setVisible(true);
For reference, there's a working example of a two column, three row layout here, illustrated below, that may help guide you.