Example usage for javax.swing JMenuBar setAlignmentX

List of usage examples for javax.swing JMenuBar setAlignmentX

Introduction

In this page you can find the example usage for javax.swing JMenuBar setAlignmentX.

Prototype

@BeanProperty(description = "The preferred horizontal alignment of the component.")
public void setAlignmentX(float alignmentX) 

Source Link

Document

Sets the horizontal alignment.

Usage

From source file:savant.plugin.builtin.SAFEBrowser.java

void initSafe(final String username, final String password)
        throws MalformedURLException, JDOMException, IOException {

    safeCard.removeAll();/* w w w  . j  av  a  2  s. com*/
    safeCard.setLayout(new BorderLayout());

    File f = NetworkUtils.downloadFile(
            new URL(BrowserSettings.SAFE_URL + "?type=list&username=" + username + "&password=" + password),
            DirectorySettings.getTmpDirectory(), null);

    if (!wereCredentialsValid(f)) {
        DialogUtils.displayMessage("Login failed.");
        return;
    }

    final Component mainp = getCenterPanel(getDownloadTreeRows(f));
    safeCard.add(mainp, BorderLayout.CENTER);

    JMenuBar bottombar = new JMenuBar();
    bottombar.setAlignmentX(RIGHT_ALIGNMENT);
    bottombar.add(Box.createHorizontalGlue());

    /*
    JButton refbutt = new JButton("Refresh");
    refbutt.putClientProperty( "JButton.buttonType", "default" );
    refbutt.addActionListener(new ActionListener() {
            
    @Override
    public void actionPerformed(ActionEvent e) {
        try {
            System.out.println("Refreshing");
            safeCard.remove(mainp);
            File f = DownloadFile.downloadFile(new URL("http://savantbrowser.com/safe/savantsafe.php?username=" + username + "&password=" + password), System.getProperty("java.io.tmpdir"));
            Component newmainp = getCenterPanel(getDownloadTreeRows(f));
            safeCard.add(newmainp, BorderLayout.CENTER);
            container.invalidate();
            System.out.println("Done Refreshing");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    });
    bottombar.add(refbutt);
     *
     */

    JButton addgroupbutt = new JButton("Create group");
    addgroupbutt.putClientProperty("JButton.buttonType", "default");
    addgroupbutt.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                addGroup(username, password);
            } catch (Exception ex) {
                LOG.error("Unable to create group: " + ex.getLocalizedMessage());
            }
        }
    });
    bottombar.add(addgroupbutt);

    JButton logoutbutt = new JButton("Logout");
    logoutbutt.putClientProperty("JButton.buttonType", "default");
    logoutbutt.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            layout.show(container, "login");
        }
    });
    bottombar.add(logoutbutt);

    JButton openbutt = new JButton("Load Track");
    openbutt.putClientProperty("JButton.buttonType", "default");
    openbutt.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            actOnSelectedItem(false);
        }
    });
    bottombar.add(openbutt);

    safeCard.add(bottombar, BorderLayout.SOUTH);

    layout.show(container, "safe");
}

From source file:savant.plugin.builtin.SavantFileRepositoryBrowser.java

private SavantFileRepositoryBrowser(Window parent) {
    super(parent, "Public Savant File Repository Browser", Dialog.ModalityType.APPLICATION_MODAL);

    setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
    setResizable(true);//from  ww w .jav a 2 s  . c  o m
    setLayout(new BorderLayout());
    add(getCenterPanel(getDownloadTreeRows()), BorderLayout.CENTER);

    JMenuBar bottombar = new JMenuBar();
    bottombar.setAlignmentX(RIGHT_ALIGNMENT);
    bottombar.add(Box.createHorizontalGlue());
    JButton openbutt = new JButton("Load Track");
    openbutt.putClientProperty("JButton.buttonType", "default");
    openbutt.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            actOnSelectedItem(false);
        }
    });
    bottombar.add(openbutt);
    JButton cancelButton = new JButton("Cancel");
    cancelButton.putClientProperty("JButton.buttonType", "default");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            closeDialog();
        }
    });
    bottombar.add(cancelButton);

    add(bottombar, BorderLayout.SOUTH);

    setPreferredSize(new Dimension(800, 500));
    pack();

    setLocationRelativeTo(parent);
}