Example usage for java.awt GridBagConstraints CENTER

List of usage examples for java.awt GridBagConstraints CENTER

Introduction

In this page you can find the example usage for java.awt GridBagConstraints CENTER.

Prototype

int CENTER

To view the source code for java.awt GridBagConstraints CENTER.

Click Source Link

Document

Put the component in the center of its display area.

Usage

From source file:de.huxhorn.lilith.swing.MainFrame.java

public MainFrame(ApplicationPreferences applicationPreferences, SplashScreen splashScreen, String appName,
        boolean enableBonjour) {
    super(appName);
    this.applicationPreferences = applicationPreferences;
    this.coloringWholeRow = this.applicationPreferences.isColoringWholeRow();
    this.splashScreen = splashScreen;
    setSplashStatusText("Creating main frame.");

    groovyFormatter = new GroovyEventWrapperHtmlFormatter(applicationPreferences);
    thymeleafFormatter = new ThymeleafEventWrapperHtmlFormatter(applicationPreferences);

    smallProgressIcon = new ImageIcon(MainFrame.class.getResource("/otherGraphics/Progress16.gif"));
    ImageIcon frameIcon = new ImageIcon(MainFrame.class.getResource("/otherGraphics/Lilith16.jpg"));
    setIconImage(frameIcon.getImage());/*  w w w  . j  ava2s .c  o m*/
    //colorsReferenceQueue=new ReferenceQueue<Colors>();
    //colorsCache=new ConcurrentHashMap<EventIdentifier, SoftColorsReference>();
    application = new DefaultApplication();
    autostartProcesses = new ArrayList<AutostartRunnable>();

    addWindowListener(new MainWindowListener());
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // fixes ticket #79 
    Runtime runtime = Runtime.getRuntime();
    Thread shutdownHook = new Thread(new ShutdownRunnable());
    runtime.addShutdownHook(shutdownHook);

    senderService = new SenderService(this);
    this.enableBonjour = enableBonjour;
    /*
    if(application.isMac())
    {
       setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    }
    else
    {
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
      */

    longTaskManager = new TaskManager<Long>();
    longTaskManager.setUsingEventQueue(true);
    longTaskManager.startUp();
    longTaskManager.addTaskListener(new MainTaskListener());

    startupApplicationPath = this.applicationPreferences.getStartupApplicationPath();

    loggingFileFactory = new LogFileFactoryImpl(new File(startupApplicationPath, LOGGING_FILE_SUBDIRECTORY));
    accessFileFactory = new LogFileFactoryImpl(new File(startupApplicationPath, ACCESS_FILE_SUBDIRECTORY));

    Map<String, String> loggingMetaData = new HashMap<String, String>();
    loggingMetaData.put(FileConstants.CONTENT_TYPE_KEY, FileConstants.CONTENT_TYPE_VALUE_LOGGING);
    loggingMetaData.put(FileConstants.CONTENT_FORMAT_KEY, FileConstants.CONTENT_FORMAT_VALUE_PROTOBUF);
    loggingMetaData.put(FileConstants.COMPRESSION_KEY, FileConstants.COMPRESSION_VALUE_GZIP);
    // TODO: configurable format and compressed

    loggingFileBufferFactory = new LoggingFileBufferFactory(loggingFileFactory, loggingMetaData);

    Map<String, String> accessMetaData = new HashMap<String, String>();
    accessMetaData.put(FileConstants.CONTENT_TYPE_KEY, FileConstants.CONTENT_TYPE_VALUE_ACCESS);
    accessMetaData.put(FileConstants.CONTENT_FORMAT_KEY, FileConstants.CONTENT_FORMAT_VALUE_PROTOBUF);
    accessMetaData.put(FileConstants.COMPRESSION_KEY, FileConstants.COMPRESSION_VALUE_GZIP);
    // TODO: configurable format and compressed

    accessFileBufferFactory = new AccessFileBufferFactory(accessFileFactory, accessMetaData);

    rrdFileFilter = new RrdFileFilter();

    loggingEventViewManager = new LoggingEventViewManager(this);
    accessEventViewManager = new AccessEventViewManager(this);
    this.applicationPreferences.addPropertyChangeListener(new PreferencesChangeListener());
    loggingSourceListener = new LoggingEventSourceListener();
    accessSourceListener = new AccessEventSourceListener();
    // this.cleanupWindowChangeListener = new CleanupWindowChangeListener();
    desktop = new JDesktopPane();
    statusBar = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    statusLabel = new JLabel();
    statusLabel.setText("Starting...");

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(0, 5, 0, 0);

    statusBar.add(statusLabel, gbc);

    taskStatusLabel = new JLabel();
    taskStatusLabel.setText("");
    taskStatusLabel.setForeground(Color.BLUE);
    taskStatusLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent mouseEvent) {
            showTaskManager();
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            taskStatusLabel.setForeground(Color.RED);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            taskStatusLabel.setForeground(Color.BLUE);
        }
    });
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(0, 5, 0, 0);
    statusBar.add(taskStatusLabel, gbc);

    MemoryStatus memoryStatus = new MemoryStatus();
    memoryStatus.setBackground(Color.WHITE);
    memoryStatus.setOpaque(true);
    memoryStatus.setUsingBinaryUnits(true);
    memoryStatus.setUsingTotal(false);
    memoryStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));

    gbc.fill = GridBagConstraints.NONE;
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0.0;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(0, 0, 0, 0);

    statusBar.add(memoryStatus, gbc);
    add(desktop, BorderLayout.CENTER);
    add(statusBar, BorderLayout.SOUTH);

    if (SystemUtils.IS_JAVA_1_6) {
        setSplashStatusText("Creating statistics dialog.");
        if (logger.isDebugEnabled())
            logger.debug("Before creation of statistics-dialog...");
        statisticsDialog = new StatisticsDialog(this);
        if (logger.isDebugEnabled())
            logger.debug("After creation of statistics-dialog...");
    }

    setSplashStatusText("Creating about dialog.");
    aboutDialog = new AboutDialog(this, "About " + appName + "...", appName);

    setSplashStatusText("Creating update dialog.");
    checkForUpdateDialog = new CheckForUpdateDialog(this);

    setSplashStatusText("Creating debug dialog.");
    debugDialog = new DebugDialog(this, this);

    setSplashStatusText("Creating preferences dialog.");
    if (logger.isDebugEnabled())
        logger.debug("Before creation of preferences-dialog...");
    preferencesDialog = new PreferencesDialog(this);
    if (logger.isDebugEnabled())
        logger.debug("After creation of preferences-dialog...");

    setSplashStatusText("Creating \"Open inactive\" dialog.");
    openInactiveLogsDialog = new OpenPreviousDialog(MainFrame.this);

    setSplashStatusText("Creating help frame.");
    helpFrame = new HelpFrame(this);
    helpFrame.setTitle("Help Topics");

    openFileChooser = new JFileChooser();
    openFileChooser.setFileFilter(new LilithFileFilter());
    openFileChooser.setFileHidingEnabled(false);
    openFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousOpenPath());

    importFileChooser = new JFileChooser();
    importFileChooser.setFileFilter(new XmlImportFileFilter());
    importFileChooser.setFileHidingEnabled(false);
    importFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousImportPath());

    exportFileChooser = new JFileChooser();
    exportFileChooser.setFileFilter(new LilithFileFilter());
    exportFileChooser.setFileHidingEnabled(false);
    exportFileChooser.setCurrentDirectory(this.applicationPreferences.getPreviousExportPath());

    setSplashStatusText("Creating task manager frame.");
    taskManagerFrame = new TaskManagerInternalFrame(this);
    taskManagerFrame.setTitle("Task Manager");
    taskManagerFrame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
    taskManagerFrame.setBounds(0, 0, 320, 240);

    desktop.add(taskManagerFrame);
    desktop.validate();

    // the following code must be executed after desktop has been initialized...
    try {
        // try to use the 1.6 transfer handler...
        new MainFrameTransferHandler16(this).attach();
    } catch (Throwable t) {
        // ... and use the basic 1.5 transfer handler if this fails.
        new MainFrameTransferHandler(this).attach();
    }

    setSplashStatusText("Creating Tip of the Day dialog.");
    tipOfTheDayDialog = new TipOfTheDayDialog(this);

    setSplashStatusText("Creating actions and menus.");
    viewActions = new ViewActions(this, null);
    viewActions.getPopupMenu(); // initialize popup once in main frame only.

    JMenuBar menuBar = viewActions.getMenuBar();
    toolbar = viewActions.getToolbar();
    add(toolbar, BorderLayout.NORTH);
    setJMenuBar(menuBar);

    setShowingToolbar(applicationPreferences.isShowingToolbar());
    setShowingStatusbar(applicationPreferences.isShowingStatusbar());
}

From source file:junk.gui.HazardDataSetCalcCondorApp.java

/**
 * Initialize the ERF Gui Bean/*  w w w .  j a  va  2s  .co m*/
 */
private void initERFSelector_GuiBean() {
    // create the ERF Gui Bean object
    ArrayList erf_Classes = new ArrayList();

    erf_Classes.add(RMI_FRANKEL02_ADJ_FORECAST_CLASS_NAME);
    erf_Classes.add(RMI_FLOATING_POISSON_FAULT_ERF_CLASS_NAME);
    erf_Classes.add(RMI_FRANKEL_ADJ_FORECAST_CLASS_NAME);
    erf_Classes.add(RMI_STEP_FORECAST_CLASS_NAME);
    erf_Classes.add(RMI_STEP_ALASKAN_FORECAST_CLASS_NAME);
    erf_Classes.add(RMI_WG02_ADJ_FORECAST_CLASS_NAME);
    erf_Classes.add(RMI_WGCEP_UCERF1_ERF_CLASS_NAME);
    try {
        erfGuiBean = new ERF_GuiBean(erf_Classes);
    } catch (InvocationTargetException e) {
        throw new RuntimeException("Connection to ERF servlets failed");
    }
    eqkRupPanel.add(erfGuiBean, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, defaultInsets, 0, 0));
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java

private JPanel getJPanelForCreatorInfo() {
    if (jPanelForCreatorInfo == null) {
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints5.gridx = -1;//from w w w  .  j a v a2 s.c  o m
        gridBagConstraints5.gridy = -1;
        gridBagConstraints5.gridwidth = 1;
        gridBagConstraints5.anchor = GridBagConstraints.CENTER;
        gridBagConstraints5.weightx = 1.0;
        gridBagConstraints5.weighty = 0.0;
        gridBagConstraints5.insets = new Insets(0, 10, 10, 43); // margin // top, left, bottom, right
        jPanelForCreatorInfo = new JPanel();
        jPanelForCreatorInfo.setLayout(new GridBagLayout());
        jPanelForCreatorInfo.setBorder(BorderFactory.createTitledBorder(null, "Creator Info",
                TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jPanelForCreatorInfo.add(getJPanelCreatorInfo(), gridBagConstraints5);
    }
    return jPanelForCreatorInfo;
}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void setupPortableMode(JPanel panel) {
    panel.setLayout(new GridBagLayout());

    JLabel portableSpiel = new JLabel("<html><body align=\"left\" style='margin-right:10px;'>"
            + resources.getString("launcher.installer.portablespiel") + "</body></html>");
    portableSpiel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    portableSpiel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    portableSpiel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.add(portableSpiel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(9, 8, 9, 3), 0, 0));

    panel.add(Box.createGlue(), new GridBagConstraints(0, 1, 3, 1, 1.0, 0.7, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    JLabel installFolderLabel = new JLabel(resources.getString("launcher.installer.folder"));
    installFolderLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    installFolderLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    panel.add(installFolderLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 24, 0, 8), 0, 0));

    String installDir = "";
    if (settings.isPortable())
        installDir = settings.getTechnicRoot().getAbsolutePath();

    portableInstallDir = new JTextField(installDir);
    portableInstallDir.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    portableInstallDir.setForeground(LauncherFrame.COLOR_BLUE);
    portableInstallDir.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    portableInstallDir.setHighlighter(null);
    portableInstallDir.setEditable(false);
    portableInstallDir.setCursor(null);//from   w ww. j av a 2 s.c  om
    portableInstallDir.setBorder(new RoundBorder(LauncherFrame.COLOR_BUTTON_BLUE, 1, 8));
    panel.add(portableInstallDir, new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));

    RoundedButton selectInstall = new RoundedButton(resources.getString("launcher.installer.select"));
    selectInstall.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    selectInstall.setContentAreaFilled(false);
    selectInstall.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
    selectInstall.setHoverForeground(LauncherFrame.COLOR_BLUE);
    selectInstall.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectPortable();
        }
    });
    panel.add(selectInstall, new GridBagConstraints(2, 2, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 16), 0, 0));

    panel.add(Box.createGlue(), new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    String defaultLocaleText = resources.getString("launcheroptions.language.default");
    if (!resources.isDefaultLocaleSupported()) {
        defaultLocaleText = defaultLocaleText
                .concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")");
    }

    portableLanguages = new JComboBox();
    portableLanguages.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources));
    for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
        portableLanguages
                .addItem(new LanguageItem(resources.getCodeFromLocale(ResourceLoader.SUPPORTED_LOCALES[i]),
                        ResourceLoader.SUPPORTED_LOCALES[i].getDisplayName(ResourceLoader.SUPPORTED_LOCALES[i]),
                        resources.getVariant(ResourceLoader.SUPPORTED_LOCALES[i])));
    }
    if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) {
        Locale loc = resources.getLocaleFromCode(settings.getLanguageCode());

        for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
            if (loc.equals(ResourceLoader.SUPPORTED_LOCALES[i])) {
                portableLanguages.setSelectedIndex(i + 1);
                break;
            }
        }
    }
    portableLanguages.setBorder(new RoundBorder(LauncherFrame.COLOR_SCROLL_THUMB, 1, 10));
    portableLanguages.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    portableLanguages.setUI(new LanguageCellUI(resources));
    portableLanguages.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    portableLanguages.setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    portableLanguages.setRenderer(new LanguageCellRenderer(resources, "globe.png",
            LauncherFrame.COLOR_SELECTOR_BACK, LauncherFrame.COLOR_WHITE_TEXT));
    portableLanguages.setEditable(false);
    portableLanguages.setFocusable(false);
    portableLanguages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            portableLanguageChanged();
        }
    });
    panel.add(portableLanguages, new GridBagConstraints(0, 4, 1, 0, 0, 0, GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0));

    portableInstallButton = new RoundedButton(resources.getString("launcher.installer.install"));
    portableInstallButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    portableInstallButton.setContentAreaFilled(false);
    portableInstallButton.setForeground(LauncherFrame.COLOR_GREY_TEXT);
    portableInstallButton.setHoverForeground(LauncherFrame.COLOR_BLUE);
    portableInstallButton.setBorder(BorderFactory.createEmptyBorder(8, 56, 8, 56));
    portableInstallButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            portableInstall();
        }
    });
    portableInstallButton.setEnabled(false);

    if (!installDir.equals("")) {
        portableInstallButton.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
        portableInstallButton.setEnabled(true);
    }

    panel.add(portableInstallButton, new GridBagConstraints(1, 4, 2, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 8, 8), 0, 0));
}

From source file:junk.gui.HazardSpectrumApplication.java

private void jbInit() throws Exception {
    border1 = BorderFactory.createLineBorder(SystemColor.controlText, 1);
    border2 = BorderFactory.createLineBorder(SystemColor.controlText, 1);
    border3 = BorderFactory.createEmptyBorder();
    border4 = BorderFactory.createLineBorder(SystemColor.controlText, 1);
    border5 = BorderFactory.createLineBorder(SystemColor.controlText, 1);
    border6 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white, Color.white,
            new Color(98, 98, 112), new Color(140, 140, 161));
    border7 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white, Color.white,
            new Color(98, 98, 112), new Color(140, 140, 161));
    border8 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white, Color.white,
            new Color(98, 98, 112), new Color(140, 140, 161));
    //this.getContentPane().setBackground(Color.white);
    this.setSize(new Dimension(1100, 670));
    this.getContentPane().setLayout(borderLayout1);

    jPanel1.setLayout(gridBagLayout10);//from w  ww  .ja  va 2s .  co  m
    //creating the Object the GraphPaenl class
    graphPanel = new GraphPanel(this);

    jPanel1.setBackground(Color.white);
    jPanel1.setBorder(border4);
    jPanel1.setMinimumSize(new Dimension(959, 600));
    jPanel1.setPreferredSize(new Dimension(959, 600));

    //loading the OpenSHA Logo

    topSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    clearButton.setText("Clear Plot");
    clearButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearButton_actionPerformed(e);
        }
    });
    imgLabel.setText("");
    imgLabel.setIcon(new ImageIcon(FileUtils.loadImage(this.POWERED_BY_IMAGE)));
    imgLabel.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            imgLabel_mouseClicked(e);
        }
    });
    //jCheckylog.setBackground(Color.white);
    //jCheckylog.setForeground(new Color(80, 80, 133));
    //buttonPanel.setBackground(Color.white);
    buttonPanel.setMinimumSize(new Dimension(568, 20));
    buttonPanel.setLayout(flowLayout1);
    //progressCheckBox.setBackground(Color.white);
    progressCheckBox.setFont(new java.awt.Font("Dialog", 1, 12));
    //progressCheckBox.setForeground(new Color(80, 80, 133));
    progressCheckBox.setSelected(true);
    progressCheckBox.setText("Show Progress Bar");
    addButton.setText("Compute");
    addButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addButton_actionPerformed(e);
        }
    });
    // jCheckxlog.setBackground(Color.white);
    //jCheckxlog.setForeground(new Color(80, 80, 133));
    //controlComboBox.setBackground(new Color(200, 200, 230));
    //controlComboBox.setForeground(new Color(80, 80, 133));
    controlComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            controlComboBox_actionPerformed(e);
        }
    });
    panel.setLayout(gridBagLayout9);
    panel.setBackground(Color.white);
    panel.setBorder(border5);
    panel.setMinimumSize(new Dimension(0, 0));
    imrSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    imrSplitPane.setBottomComponent(imtPanel);
    imrSplitPane.setTopComponent(imrPanel);
    erfSplitPane.setTopComponent(erfPanel);
    sitePanel.setLayout(gridBagLayout13);
    sitePanel.setBackground(Color.white);
    imtPanel.setLayout(gridBagLayout8);
    imtPanel.setBackground(Color.white);
    controlsSplit.setDividerSize(5);
    erfPanel.setLayout(gridBagLayout5);
    erfPanel.setBackground(Color.white);
    erfPanel.setBorder(border2);
    erfPanel.setMaximumSize(new Dimension(2147483647, 10000));
    erfPanel.setMinimumSize(new Dimension(2, 300));
    erfPanel.setPreferredSize(new Dimension(2, 300));
    imrPanel.setLayout(gridBagLayout15);
    imrPanel.setBackground(Color.white);
    chartSplit.setLeftComponent(panel);
    chartSplit.setRightComponent(paramsTabbedPane);
    probDeterSelection.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            probDeterSelection_actionPerformed(e);
        }
    });
    peelOffButton.setText("Peel Off");
    peelOffButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            peelOffButton_actionPerformed(e);
        }
    });
    this.getContentPane().add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(topSplitPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(11, 4, 5, 6), 243, 231));
    buttonPanel.add(probDeterSelection, null);
    buttonPanel.add(controlComboBox, null);
    buttonPanel.add(addButton, null);
    buttonPanel.add(clearButton, null);
    buttonPanel.add(peelOffButton, null);
    buttonPanel.add(progressCheckBox, null);
    buttonPanel.add(imgLabel, null);
    topSplitPane.add(chartSplit, JSplitPane.TOP);
    chartSplit.add(panel, JSplitPane.LEFT);
    chartSplit.add(paramsTabbedPane, JSplitPane.RIGHT);
    imrSplitPane.add(imrPanel, JSplitPane.TOP);
    imrSplitPane.add(imtPanel, JSplitPane.BOTTOM);
    controlsSplit.add(imrSplitPane, JSplitPane.LEFT);
    paramsTabbedPane.add(controlsSplit, "IMR, IML/Prob, & Site");
    controlsSplit.add(sitePanel, JSplitPane.RIGHT);
    paramsTabbedPane.add(erfSplitPane, "ERF & Time Span");
    erfSplitPane.add(erfPanel, JSplitPane.LEFT);
    topSplitPane.add(buttonPanel, JSplitPane.BOTTOM);
    topSplitPane.setDividerLocation(600);
    imrSplitPane.setDividerLocation(300);
    erfSplitPane.setDividerLocation(260);
    controlsSplit.setDividerLocation(260);
    erfPanel.validate();
    erfPanel.repaint();
    chartSplit.setDividerLocation(600);

}

From source file:mt.listeners.InteractiveRANSAC.java

public void CardTable() {
    this.lambdaSB = new Scrollbar(Scrollbar.HORIZONTAL, this.lambdaInt, 1, MIN_SLIDER, MAX_SLIDER + 1);

    maxSlopeSB.setValue(utility.Slicer.computeScrollbarPositionFromValue((float) maxSlope,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize));

    maxDistSB.setValue(/*from   w w  w.  j a  v  a 2  s. c  o  m*/
            utility.Slicer.computeScrollbarPositionFromValue(maxDist, MIN_Gap, MAX_Gap, scrollbarSize));

    minInliersSB.setValue(utility.Slicer.computeScrollbarPositionFromValue(minInliers, MIN_Inlier, MAX_Inlier,
            scrollbarSize));
    maxErrorSB.setValue(
            utility.Slicer.computeScrollbarPositionFromValue(maxError, MIN_ERROR, MAX_ERROR, scrollbarSize));

    minSlopeSB.setValue(utility.Slicer.computeScrollbarPositionFromValue((float) minSlope,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize));

    lambdaLabel = new Label("Linearity (fraction) = " + new DecimalFormat("#.##").format(lambda), Label.CENTER);
    maxErrorLabel = new Label("Maximum Error (px) = " + new DecimalFormat("#.##").format(maxError) + "      ",
            Label.CENTER);
    minInliersLabel = new Label(
            "Minimum No. of timepoints (tp) = " + new DecimalFormat("#.##").format(minInliers), Label.CENTER);
    maxDistLabel = new Label("Maximum Gap (tp) = " + new DecimalFormat("#.##").format(maxDist), Label.CENTER);

    minSlopeLabel = new Label("Min. Segment Slope (px/tp) = " + new DecimalFormat("#.##").format(minSlope),
            Label.CENTER);
    maxSlopeLabel = new Label("Max. Segment Slope (px/tp) = " + new DecimalFormat("#.##").format(maxSlope),
            Label.CENTER);
    maxResLabel = new Label(
            "MT is rescued if the start of event# i + 1 > start of event# i by px =  " + this.restolerance,
            Label.CENTER);

    CardLayout cl = new CardLayout();
    Object[] colnames = new Object[] { "Track File", "Growth velocity", "Shrink velocity", "Growth events",
            "Shrink events", "fcat", "fres", "Error" };

    Object[][] rowvalues = new Object[0][colnames.length];

    if (inputfiles != null) {
        rowvalues = new Object[inputfiles.length][colnames.length];
        for (int i = 0; i < inputfiles.length; ++i) {

            rowvalues[i][0] = inputfiles[i].getName();
        }
    }

    table = new JTable(rowvalues, colnames);

    table.setFillsViewportHeight(true);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.isOpaque();
    int size = 100;
    table.getColumnModel().getColumn(0).setPreferredWidth(size);
    table.getColumnModel().getColumn(1).setPreferredWidth(size);
    table.getColumnModel().getColumn(2).setPreferredWidth(size);
    table.getColumnModel().getColumn(3).setPreferredWidth(size);
    table.getColumnModel().getColumn(4).setPreferredWidth(size);
    table.getColumnModel().getColumn(5).setPreferredWidth(size);
    table.getColumnModel().getColumn(6).setPreferredWidth(size);
    table.getColumnModel().getColumn(7).setPreferredWidth(size);
    maxErrorField = new TextField(5);
    maxErrorField.setText(Float.toString(maxError));

    minInlierField = new TextField(5);
    minInlierField.setText(Float.toString(minInliers));

    maxGapField = new TextField(5);
    maxGapField.setText(Float.toString(maxDist));

    maxSlopeField = new TextField(5);
    maxSlopeField.setText(Float.toString(maxSlope));

    minSlopeField = new TextField(5);
    minSlopeField.setText(Float.toString(minSlope));

    maxErrorSB.setSize(new Dimension(SizeX, 20));
    minSlopeSB.setSize(new Dimension(SizeX, 20));
    minInliersSB.setSize(new Dimension(SizeX, 20));
    maxDistSB.setSize(new Dimension(SizeX, 20));
    maxSlopeSB.setSize(new Dimension(SizeX, 20));
    maxErrorField.setSize(new Dimension(SizeX, 20));
    minInlierField.setSize(new Dimension(SizeX, 20));
    maxGapField.setSize(new Dimension(SizeX, 20));
    minSlopeField.setSize(new Dimension(SizeX, 20));
    maxSlopeField.setSize(new Dimension(SizeX, 20));

    scrollPane = new JScrollPane(table);
    scrollPane.setMinimumSize(new Dimension(300, 200));
    scrollPane.setPreferredSize(new Dimension(300, 200));

    scrollPane.getViewport().add(table);
    scrollPane.setAutoscrolls(true);

    // Location
    panelFirst.setLayout(layout);
    panelSecond.setLayout(layout);
    PanelSavetoFile.setLayout(layout);
    PanelParameteroptions.setLayout(layout);
    Panelfunction.setLayout(layout);
    Panelslope.setLayout(layout);
    PanelCompileRes.setLayout(layout);
    PanelDirectory.setLayout(layout);

    panelCont.setLayout(cl);

    panelCont.add(panelFirst, "1");
    panelCont.add(panelSecond, "2");

    panelFirst.setName("Ransac fits for rates and frequency analysis");
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.BOTH;
    c.ipadx = 35;

    inputLabelT = new Label("Compute length distribution at time: ");
    inputLabelTcont = new Label("(Press Enter to start computation) ");
    inputFieldT = new TextField(5);
    inputFieldT.setText("1");

    c.gridwidth = 10;
    c.gridheight = 10;
    c.gridy = 1;
    c.gridx = 0;

    String[] Method = { "Linear Function only", "Linearized Quadratic function", "Linearized Cubic function" };
    JComboBox<String> ChooseMethod = new JComboBox<String>(Method);

    final Checkbox findCatastrophe = new Checkbox("Detect Catastrophies", this.detectCatastrophe);
    final Checkbox findmanualCatastrophe = new Checkbox("Detect Catastrophies without fit",
            this.detectmanualCatastrophe);
    final Scrollbar minCatDist = new Scrollbar(Scrollbar.HORIZONTAL, this.minDistCatInt, 1, MIN_SLIDER,
            MAX_SLIDER + 1);
    final Scrollbar maxRes = new Scrollbar(Scrollbar.HORIZONTAL, this.restoleranceInt, 1, MIN_SLIDER,
            MAX_SLIDER + 1);
    final Label minCatDistLabel = new Label("Min. Catastrophy height (tp) = " + this.minDistanceCatastrophe,
            Label.CENTER);
    final Button done = new Button("Done");
    final Button batch = new Button("Save Parameters for Batch run");
    final Button cancel = new Button("Cancel");
    final Button Compile = new Button("Compute rates and freq. till current file");
    final Button AutoCompile = new Button("Auto Compute Velocity and Frequencies");
    final Button Measureserial = new Button("Select directory of MTrack generated files");
    final Button WriteLength = new Button("Compute length distribution at framenumber : ");
    final Button WriteStats = new Button("Compute lifetime and mean length distribution");
    final Button WriteAgain = new Button("Save Velocity and Frequencies to File");

    PanelDirectory.add(Measureserial, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelDirectory.add(scrollPane, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    PanelDirectory.setBorder(selectdirectory);
    PanelDirectory.setPreferredSize(new Dimension(SizeX, SizeY));
    panelFirst.add(PanelDirectory, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxerror = new SliderBoxGUI(errorstring, maxErrorSB, maxErrorField, maxErrorLabel,
            scrollbarSize, maxError, MAX_ERROR);

    PanelParameteroptions.add(combomaxerror.BuildDisplay(), new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomininlier = new SliderBoxGUI(inlierstring, minInliersSB, minInlierField, minInliersLabel,
            scrollbarSize, minInliers, MAX_Inlier);

    PanelParameteroptions.add(combomininlier.BuildDisplay(), new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxdist = new SliderBoxGUI(maxgapstring, maxDistSB, maxGapField, maxDistLabel,
            scrollbarSize, maxDist, MAX_Gap);

    PanelParameteroptions.add(combomaxdist.BuildDisplay(), new GridBagConstraints(0, 3, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.add(ChooseMethod, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
            GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.add(lambdaSB, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    PanelParameteroptions.add(lambdaLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelParameteroptions.setPreferredSize(new Dimension(SizeX, SizeY));
    PanelParameteroptions.setBorder(selectparam);
    panelFirst.add(PanelParameteroptions, new GridBagConstraints(3, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combominslope = new SliderBoxGUI(minslopestring, minSlopeSB, minSlopeField, minSlopeLabel,
            scrollbarSize, (float) minSlope, (float) MAX_ABS_SLOPE);

    Panelslope.add(combominslope.BuildDisplay(), new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    SliderBoxGUI combomaxslope = new SliderBoxGUI(maxslopestring, maxSlopeSB, maxSlopeField, maxSlopeLabel,
            scrollbarSize, (float) maxSlope, (float) MAX_ABS_SLOPE);

    Panelslope.add(combomaxslope.BuildDisplay(), new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insets, 0, 0));

    Panelslope.add(findCatastrophe, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(findmanualCatastrophe, new GridBagConstraints(4, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(minCatDist, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.add(minCatDistLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));
    Panelslope.setBorder(selectslope);
    Panelslope.setPreferredSize(new Dimension(SizeX, SizeY));

    panelFirst.add(Panelslope, new GridBagConstraints(3, 1, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(AutoCompile, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(WriteLength, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(inputFieldT, new GridBagConstraints(3, 1, 3, 1, 0.1, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.add(WriteStats, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    PanelCompileRes.setPreferredSize(new Dimension(SizeX, SizeY));

    PanelCompileRes.setBorder(compileres);

    panelFirst.add(PanelCompileRes, new GridBagConstraints(0, 1, 3, 1, 0.0, 0.0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insets, 0, 0));

    if (inputfiles != null) {

        table.addMouseListener(new MouseAdapter() {

            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() >= 1) {

                    if (!jFreeChartFrame.isVisible())
                        jFreeChartFrame = Tracking.display(chart, new Dimension(500, 500));
                    JTable target = (JTable) e.getSource();
                    row = target.getSelectedRow();
                    // do some action if appropriate column
                    if (row > 0)
                        displayclicked(row);
                    else
                        displayclicked(0);
                }
            }
        });
    }

    maxErrorSB.addAdjustmentListener(new ErrorListener(this, maxErrorLabel, errorstring, MIN_ERROR, MAX_ERROR,
            scrollbarSize, maxErrorSB));

    minInliersSB.addAdjustmentListener(new MinInlierListener(this, minInliersLabel, inlierstring, MIN_Inlier,
            MAX_Inlier, scrollbarSize, minInliersSB));

    maxDistSB.addAdjustmentListener(
            new MaxDistListener(this, maxDistLabel, maxgapstring, MIN_Gap, MAX_Gap, scrollbarSize, maxDistSB));

    ChooseMethod.addActionListener(new FunctionItemListener(this, ChooseMethod));
    lambdaSB.addAdjustmentListener(new LambdaListener(this, lambdaLabel, lambdaSB));
    minSlopeSB.addAdjustmentListener(new MinSlopeListener(this, minSlopeLabel, minslopestring,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize, minSlopeSB));

    maxSlopeSB.addAdjustmentListener(new MaxSlopeListener(this, maxSlopeLabel, maxslopestring,
            (float) MIN_ABS_SLOPE, (float) MAX_ABS_SLOPE, scrollbarSize, maxSlopeSB));
    findCatastrophe.addItemListener(
            new CatastrophyCheckBoxListener(this, findCatastrophe, minCatDistLabel, minCatDist));
    findmanualCatastrophe.addItemListener(
            new ManualCatastrophyCheckBoxListener(this, findmanualCatastrophe, minCatDistLabel, minCatDist));
    minCatDist.addAdjustmentListener(new MinCatastrophyDistanceListener(this, minCatDistLabel, minCatDist));
    Measureserial.addActionListener(new MeasureserialListener(this));
    Compile.addActionListener(new CompileResultsListener(this));
    AutoCompile.addActionListener(new AutoCompileResultsListener(this));
    WriteLength.addActionListener(new WriteLengthListener(this));
    WriteStats.addActionListener(new WriteStatsListener(this));
    WriteAgain.addActionListener(new WriteRatesListener(this));
    done.addActionListener(new FinishButtonListener(this, false));
    batch.addActionListener(new RansacBatchmodeListener(this));
    cancel.addActionListener(new FinishButtonListener(this, true));
    inputFieldT.addTextListener(new LengthdistroListener(this));

    maxSlopeField.addTextListener(new MaxSlopeLocListener(this, false));
    minSlopeField.addTextListener(new MinSlopeLocListener(this, false));
    maxErrorField.addTextListener(new ErrorLocListener(this, false));
    minInlierField.addTextListener(new MinInlierLocListener(this, false));
    maxGapField.addTextListener(new MaxDistLocListener(this, false));

    panelFirst.setVisible(true);
    functionChoice = 0;

    cl.show(panelCont, "1");

    Cardframe.add(panelCont, BorderLayout.CENTER);

    setFunction();
    Cardframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Cardframe.pack();
    Cardframe.setVisible(true);
    Cardframe.pack();

}

From source file:org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer.java

/**
 * Initialize the GUI.//from  w w  w.ja v  a  2s  . c o  m
 */
private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    setLayout(new GridBagLayout());

    GridBagConstraints cl = new GridBagConstraints(); // for labels
    cl.gridx = 0;
    cl.anchor = GridBagConstraints.EAST;
    cl.insets = new Insets(0, 1, 0, 1);

    GridBagConstraints ce = new GridBagConstraints(); // for editors
    ce.fill = GridBagConstraints.BOTH;
    ce.gridx = 1;
    ce.weightx = 1.0;
    ce.insets = new Insets(0, 1, 0, 1);

    GridBagConstraints cp = new GridBagConstraints(); // for panels
    cp.fill = GridBagConstraints.BOTH;
    cp.gridx = 1;
    cp.gridy = GridBagConstraints.RELATIVE;
    cp.gridwidth = 2;
    cp.weightx = 1.0;

    JPanel currentPanel = this;
    String currentGroup = DEFAULT_GROUP;
    int y = 0;

    for (int i = 0; i < editors.length; i++) {
        if (editors[i] == null) {
            continue;
        }

        if (log.isDebugEnabled()) {
            log.debug("Laying property " + descriptors[i].getName());
        }

        String g = group(descriptors[i]);
        if (!currentGroup.equals(g)) {
            if (currentPanel != this) {
                add(currentPanel, cp);
            }
            currentGroup = g;
            currentPanel = new JPanel(new GridBagLayout());
            currentPanel.setBorder(
                    BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), groupDisplayName(g)));
            cp.weighty = 0.0;
            y = 0;
        }

        Component customEditor = editors[i].getCustomEditor();

        boolean multiLineEditor = false;
        if (customEditor.getPreferredSize().height > 50 || customEditor instanceof JScrollPane
                || descriptors[i].getValue(MULTILINE) != null) {
            // TODO: the above works in the current situation, but it's
            // just a hack. How to get each editor to report whether it
            // wants to grow bigger? Whether the property label should
            // be at the left or at the top of the editor? ...?
            multiLineEditor = true;
        }

        JLabel label = createLabel(descriptors[i]);
        label.setLabelFor(customEditor);

        cl.gridy = y;
        cl.gridwidth = multiLineEditor ? 2 : 1;
        cl.anchor = multiLineEditor ? GridBagConstraints.CENTER : GridBagConstraints.EAST;
        currentPanel.add(label, cl);

        ce.gridx = multiLineEditor ? 0 : 1;
        ce.gridy = multiLineEditor ? ++y : y;
        ce.gridwidth = multiLineEditor ? 2 : 1;
        ce.weighty = multiLineEditor ? 1.0 : 0.0;

        cp.weighty += ce.weighty;

        currentPanel.add(customEditor, ce);

        y++;
    }
    if (currentPanel != this) {
        add(currentPanel, cp);
    }

    // Add a 0-sized invisible component that will take all the vertical
    // space that nobody wants:
    cp.weighty = 0.0001;
    add(Box.createHorizontalStrut(0), cp);
}

From source file:shuffle.fwk.service.teams.EditTeamService.java

private Component makeBottomPanel() {
    JPanel ret = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.weightx = 1.0;//from  w w  w  . j a va2s. c o m
    c.weighty = 0.0;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;

    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.0;
    c.gridx += 1;
    c.insets = new Insets(0, 10, 0, 10);
    selectedDisplayLabel = new JLabel(getString(KEY_NONE_SELECTED));
    selectedDisplayLabel.setToolTipText(getString(KEY_SELECTED_TOOLTIP));
    ret.add(selectedDisplayLabel, c);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 1.0;
    c.gridx++;
    survivalMode = new JCheckBox(getString(KEY_SURVIVAL));
    JPanel survivalModePanel = new JPanel(new BorderLayout());
    survivalModePanel.add(survivalMode, BorderLayout.WEST);
    survivalMode.setToolTipText(getString(KEY_SURVIVAL_TOOLTIP));
    ret.add(survivalModePanel, c);

    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.0;
    c.gridx += 1;
    JButton okButton = new JButton(getString(KEY_OK));
    okButton.setToolTipText(getString(KEY_OK_TOOLTIP));
    ret.add(okButton, c);
    setDefaultButton(okButton);

    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.0;
    c.gridx += 1;
    JButton applyButton = new JButton(getString(KEY_APPLY));
    applyButton.setToolTipText(getString(KEY_APPLY_TOOLTIP));
    ret.add(applyButton, c);

    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.0;
    c.gridx += 1;
    JButton cancelButton = new JButton(new DisposeAction(getString(KEY_CANCEL), this));
    cancelButton.setToolTipText(getString(KEY_CANCEL_TOOLTIP));
    ret.add(cancelButton, c);

    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            onOK();
        }
    });
    applyButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            onApply();
        }
    });
    return ret;
}

From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java

/**
 * Create the messaging server panel which consists of MultiBit style header
 * and our Netbean visual editor designed panel
 * @param stentWidth//from www.  j  a  va  2s .  c  o  m
 * @return 
 */
private JPanel createMessagingServerPanel(int stentWidth) {

    MultiBitTitledPanel panel = new MultiBitTitledPanel("Messaging Servers",
            ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));

    // Create layout like other panels
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.weightx = 0.1;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    JPanel indent = MultiBitTitledPanel.getIndentPanel(1);
    panel.add(indent, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 1;
    constraints.gridy = 4;
    constraints.weightx = 0.3;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    JPanel stent = MultiBitTitledPanel.createStent(stentWidth);
    panel.add(stent, constraints);

    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 2;
    constraints.gridy = 3;
    constraints.weightx = 0.05;
    constraints.weighty = 0.3;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.CENTER;
    panel.add(MultiBitTitledPanel.createStent(MultiBitTitledPanel.SEPARATION_BETWEEN_NAME_VALUE_PAIRS),
            constraints);

    // Now insert our custom panel

    messagingServerPanel = new CSMessagingServerPanel();
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 1;
    constraints.gridy = 5;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_START;
    panel.add(messagingServerPanel, constraints);

    // fill up right side
    JPanel fill1 = new JPanel();
    fill1.setOpaque(false);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 4;
    constraints.gridy = 10;
    constraints.weightx = 20;
    constraints.weighty = 1;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.LINE_END;
    panel.add(fill1, constraints);

    return panel;
}