Java Code Examples for javax.swing.JPanel.getWidth()

The following are Jave code examples for showing how to use getWidth() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: sstore-soft   File: ProcGui.java   View Source Code Vote up 6 votes
private JPanel createProcParasPane(JPanel parent)
{
    JPanel paneProcParas = new JPanel();
    paneProcParas.setLayout(null);
    paneProcParas.setBorder(BorderFactory.createEtchedBorder());
    int nYStartPaneProcParas = m_paneProbability.getHeight() + GuiConstants.GAP_COMPONENT;
    paneProcParas.setBounds(0, nYStartPaneProcParas, parent.getWidth(), parent.getHeight() - nYStartPaneProcParas);

    LHSListPane scrollParaNames = new LHSListPane(paneProcParas, m_lstProcParaNames);
    paneProcParas.add(scrollParaNames);

    paneProcParas.add(m_paneParaDistribution);
    int nXStartParaDistribution = scrollParaNames.getWidth() + GuiConstants.GAP_COMPONENT;
    int nWidthParaDistribution = paneProcParas.getWidth() - nXStartParaDistribution - GuiConstants.GAP_COMPONENT;
    int nHeightParaDistribution = scrollParaNames.getHeight() - 2 * GuiConstants.GAP_COMPONENT;
    m_paneParaDistribution.setBounds(nXStartParaDistribution, GuiConstants.GAP_COMPONENT, nWidthParaDistribution,
                                     nHeightParaDistribution);

    m_paneParaDistribution.add(s_paneDummy);

    return paneProcParas;
}
 
Example 2
Project: s-store   File: ProcGui.java   View Source Code Vote up 6 votes
private JPanel createProcParasPane(JPanel parent)
{
    JPanel paneProcParas = new JPanel();
    paneProcParas.setLayout(null);
    paneProcParas.setBorder(BorderFactory.createEtchedBorder());
    int nYStartPaneProcParas = m_paneProbability.getHeight() + GuiConstants.GAP_COMPONENT;
    paneProcParas.setBounds(0, nYStartPaneProcParas, parent.getWidth(), parent.getHeight() - nYStartPaneProcParas);

    LHSListPane scrollParaNames = new LHSListPane(paneProcParas, m_lstProcParaNames);
    paneProcParas.add(scrollParaNames);

    paneProcParas.add(m_paneParaDistribution);
    int nXStartParaDistribution = scrollParaNames.getWidth() + GuiConstants.GAP_COMPONENT;
    int nWidthParaDistribution = paneProcParas.getWidth() - nXStartParaDistribution - GuiConstants.GAP_COMPONENT;
    int nHeightParaDistribution = scrollParaNames.getHeight() - 2 * GuiConstants.GAP_COMPONENT;
    m_paneParaDistribution.setBounds(nXStartParaDistribution, GuiConstants.GAP_COMPONENT, nWidthParaDistribution,
                                     nHeightParaDistribution);

    m_paneParaDistribution.add(s_paneDummy);

    return paneProcParas;
}
 
Example 3
Project: SE2017-Team1   File: TestUtil.java   View Source Code Vote up 5 votes
public static void exportToImage(String format, JPanel dPanel, String fileName) {
  BufferedImage bImg = new BufferedImage(dPanel.getWidth(), dPanel.getHeight(), BufferedImage.TYPE_INT_RGB);
  Graphics2D cg = bImg.createGraphics();
  dPanel.paintAll(cg);
  try {
          if (ImageIO.write(bImg, "jpg", new File("./" + fileName + "." + format)))
          {
              System.out.println("image saved succesfully");
          }
  } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
  }
}
 
Example 4
Project: SE2017-Team1   File: TestUtil.java   View Source Code Vote up 5 votes
public static void exportToImage(String format, JPanel dPanel, String fileName) {
  BufferedImage bImg = new BufferedImage(dPanel.getWidth(), dPanel.getHeight(), BufferedImage.TYPE_INT_RGB);
  Graphics2D cg = bImg.createGraphics();
  dPanel.paintAll(cg);
  try {
          if (ImageIO.write(bImg, "jpg", new File("./" + fileName + "." + format)))
          {
              System.out.println("image saved succesfully");
          }
  } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
  }
}
 
Example 5
Project: jaer   File: Head6DOF_GUI.java   View Source Code Vote up 4 votes
private Point gaze2pix(JPanel pan, Point2D.Float gaze) {
    int h=pan.getHeight(), w=pan.getWidth();
    // (g+1)/2 ranges 0:1
    p2.setLocation((gaze.x + 1) / 2 * w, h-((gaze.y + 1) / 2 * h)); // y starts from top in AWT, so flip y here
    return p2;
}