Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:19:38+00:00 2026-05-27T06:19:38+00:00

I’d like to create a custom FieldEditor for a preference page. the aim is

  • 0

I’d like to create a custom FieldEditor for a preference page. the aim is to override ScaleFieldEditor to provide a Scale with two labels over it (one to display the min value, the other to display the max).

It made one. It is working but the layout is not good when I add a FileFieldeditor to preference page.

It’s even worst if I add the FileFieldEditor immediately after the custom ScaleFieldEditor:
http://imageshack.us/g/844/customscalelayoutok.png/
(Sorry, I cannot add images to this post).

I made a Composite which contains the 2 Labels and the Scale. I used a GridLayout:

public class ScaleWithLabelFieldEditor extends ScaleFieldEditor {

/**
 * The maximum value label
 */
private Label maxLabel;
/**
 * The minimum value label
 */
private Label minLabel;
/**
 * A composite that contains the scale and the min & max values label
 */
private Composite controls;

public ScaleWithLabelFieldEditor(String name, String labelText,
        Composite parent) {
    super(name, labelText, parent);
}

public ScaleWithLabelFieldEditor(String name, String labelText,
        Composite parent, int min, int max, int increment, int pageIncrement) {
    super(name, labelText, parent, min, max, increment, pageIncrement);
}

@Override
protected void doFillIntoGrid(Composite parent, int numColumns) {
    Control labelControl = getLabelControl(parent);
    GridData gd = new GridData();
    labelControl.setLayoutData(gd);

    controls = getControls(parent, 2);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = numColumns -1;
    gd.grabExcessHorizontalSpace = true;
    controls.setLayoutData(gd);
    updateControls();
    parent.layout();
}

/**
 * Initialize (if not done yet) the controls composite
 * 
 * @param parent
 *            the parent composite
 * @return the controls composite that contains the scaler and the min/max
 *         labels
 */
protected Composite getControls(Composite parent, int numColumns) {
    if (controls == null) {
        controls = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout(numColumns, false);
        layout.numColumns = numColumns;
        controls.setLayout(layout);

        // Initialize the min value label
        minLabel = getMinLabel(controls);
        minLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
        // Initialize the max value label
        maxLabel = getMaxLabel(controls);
        maxLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
        // Initialize the scale
        scale = getScale(controls);
        scale.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, numColumns, 1));

    }
    return controls;
}

/**
 * Nothing to do, already handle with controls composite
 */
@Override
protected void adjustForNumColumns(int numColumns) {
    // Nothing to do, already handle with controls composite
}

/**
 * Update the scale and the labels above
 */
protected void updateControls() {
    if (controls != null && !controls.isDisposed()) {
        // Update scale
        scale.setMinimum(getMinimum());
        scale.setMaximum(getMaximum());
        scale.setIncrement(getIncrement());
        scale.setPageIncrement(getPageIncrement());
        // Update labels
        maxLabel.setText(Integer.toString(getMaximum()));
        minLabel.setText(Integer.toString(getMinimum()));
    }
}

What I should do to make this field layout work? Did I miss something in GridLayout/GridData use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:19:38+00:00Added an answer on May 27, 2026 at 6:19 am

    The problem seems to be, that you did not implement the adjustForNumColumns(int numColumns) method. When you add the FileFieldEditor the number of columns changes from 2 to 3. And your field editor must adapt to that which it currently does not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.