Example usage for javax.swing JButton setBounds

List of usage examples for javax.swing JButton setBounds

Introduction

In this page you can find the example usage for javax.swing JButton setBounds.

Prototype

public void setBounds(Rectangle r) 

Source Link

Document

Moves and resizes this component to conform to the new bounding rectangle r .

Usage

From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.JPanCodeMatchMain.java

private void getJButtonSnippets() {
    int y = 0;/* www. ja v a2  s  .co  m*/
    int height = 0;
    if (getSimilarSnippets() == null) {
        log.debug("getSimilarSnippets()_null_return");
        return;
    }
    for (int i = 0; i < getSimilarSnippets().size(); i++) {
        if (totalLine != 0) {
            y = getSimilarSnippets().get(i).getLeftSnippet().getFirstLine()
                    * getJSplitPaneSourceCode().getHeight() / totalLine;
            height = (getSimilarSnippets().get(i).getLeftSnippet().getLastLine()
                    - getSimilarSnippets().get(i).getLeftSnippet().getFirstLine())
                    * getJSplitPaneSourceCode().getHeight() / totalLine;
        }
        JButton jButton = new JButton();
        jButton.addActionListener(new ButtonListener());
        jButton.setBackground(new Color(255, 255, 180));
        jButton.setBounds(new Rectangle(1, y, 35, height)); // new Rectangle(int x, int y, int width, int height)
        jButtonSnippets.add(jButton);
    }
}