congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Component.getHeight
Code IndexAdd Tabnine to your IDE (free)

How to use
getHeight
method
in
java.awt.Component

Best Java code snippets using java.awt.Component.getHeight (Showing top 20 results out of 1,773)

Refine searchRefine arrow

  • Component.getWidth
  • Window.setVisible
  • Container.add
  • JFrame.setDefaultCloseOperation
  • JFrame.<init>
origin: deathmarine/Luyten

private void readPositionFromComponent(Component component) {
  isFullScreen = false;
  windowWidth = component.getWidth();
  windowHeight = component.getHeight();
  windowX = component.getX();
  windowY = component.getY();
}
origin: stackoverflow.com

 component.getWidth(),
 component.getHeight(),
 BufferedImage.TYPE_INT_RGB
 );
Runnable r = new Runnable() {
 public void run() {
  final JFrame f = new JFrame("Test Screenshot");
  p.add( new JScrollPane(new JTree()),
   BorderLayout.WEST );
  p.add( new JScrollPane( new JTextArea(HELP,10,30) ),
   BorderLayout.CENTER );
  f.pack();
  f.setLocationRelativeTo(null);
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.setVisible(true);
origin: stackoverflow.com

constraints.fill = GridBagConstraints.BOTH;
JLabel l = new JLabel("You have got 2 new Messages.");
panel.add(l, constraints);
constraints.gridx++;
constraints.weightx = 0f;
b.setMargin(new Insets(1, 4, 1, 4));
b.setFocusable(false);
panel.add(b, constraints);
dialog.setUndecorated(true);
dialog.setSize(300, 100);
dialog.setLocation(screenSize.width - dialog.getWidth(),
    screenSize.height - taskBarSize - dialog.getHeight());
lpg = new LinearGradientPaint(0, 0, 0, dialog.getHeight() / 2,
    new float[]{0f, 0.3f, 1f}, new Color[]{new Color(0.8f, 0.8f, 1f),
      new Color(0.7f, 0.7f, 1f), new Color(0.6f, 0.6f, 1f)});
origin: stackoverflow.com

 Component c; // the component you would like to print to a BufferedImage
JFrame frame = new JFrame();
frame.setBackground(Color.WHITE);
frame.setUndecorated(true);
frame.getContentPane().add(c);
frame.pack();
BufferedImage bi = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = bi.createGraphics();
c.print(graphics);
graphics.dispose();
frame.dispose();
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p.add(f);
frame.add(p);
frame.setVisible(true);
            lastFocusableIndex = 0;
            sl.setFocused(false);
            autoSuggestionPopUpWindow.setVisible(false);
            setFocusToTextField();
      autoSuggestionPopUpWindow.setVisible(false);
      setFocusToTextField();
suggestionsPanel.add(suggestionLabel);
  windowY = container.getY() + textField.getY() + textField.getHeight() + autoSuggestionPopUpWindow.getMinimumSize().height;
} else {
  windowY = container.getY() + textField.getY() + textField.getHeight() + autoSuggestionPopUpWindow.getHeight();
origin: stackoverflow.com

final int taskBarSize = scnMax.bottom;
setLocation(screenSize.width - getWidth(), screenSize.height - taskBarSize
  - getHeight());
lpg = new LinearGradientPaint(0, 0, 0, getHeight() / 2, new float[] { 0f,
  0.3f, 1f }, new Color[] { new Color(0.8f, 0.8f, 1f),
  new Color(0.7f, 0.7f, 1f), new Color(0.6f, 0.6f, 1f) });
  l.setOpaque(false);
  c.add(l, constraints);
  b.setFocusable(false);
  c.add(b, constraints);
origin: graphhopper/graphhopper

  @Override
  public void componentResized(ComponentEvent e) {
    int w = e.getComponent().getWidth();
    int h = e.getComponent().getHeight();
    System.out.println("mainResized:" + w + " " + h);
    for (MapLayer ml : layers) {
      ml.setBounds(new Rectangle(0, 0, w, h));
    }
    repaint();
  }
});
origin: stackoverflow.com

JFrame f = new JFrame("LowerRightFrame");
f.add(new JPanel() {
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
int x = (int) rect.getMaxX() - f.getWidth();
int y = (int) rect.getMaxY() - f.getHeight();
f.setLocation(x, y);
f.setVisible(true);
origin: stackoverflow.com

if (useSlideButton) {
  final JPanel statusPanel = new JPanel();
  basePanel.add(statusPanel, BorderLayout.SOUTH);
  statusPanel.add(new JButton("Slide Left") {
    private static final long serialVersionUID = 9204819004142223529L;
  statusPanel.add(new JButton("Slide Right") {
    componentNew = jPanels.get(0);
  final int w = componentOld.getWidth();
  final int h = componentOld.getHeight();
  final Point p1 = componentOld.getLocation();
  final Point p2 = new Point(0, 0);
  int step = 0;
  if ((slideType == LEFT) || (slideType == RIGHT)) {
    step = (int) (((float) parent.getWidth() / (float) Toolkit.getDefaultToolkit().getScreenSize().width) * 40.f);
    step = (int) (((float) parent.getHeight() / (float) Toolkit.getDefaultToolkit().getScreenSize().height) * 20.f);
origin: jMonkeyEngine/jmonkeyengine

private void recenterMouse(final Component component) {
  if (robot != null) {
    eventsSinceRecenter = 0;
    isRecentering = true;
    centerLocation.setLocation(component.getWidth() / 2, component.getHeight() / 2);
    centerLocationOnScreen.setLocation(centerLocation);
    SwingUtilities.convertPointToScreen(centerLocationOnScreen, component);
    robot.mouseMove(centerLocationOnScreen.x, centerLocationOnScreen.y);
  }
}
origin: stackoverflow.com

frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.add(jsp);
frame.setVisible(true);
BufferedImage bi = componentToImage(imagePanel, true);
try {
  BufferedImage img = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TRANSLUCENT);
  Graphics2D g2d = (Graphics2D) img.getGraphics();
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  component.setSize(component.getPreferredSize());
  layoutComponent(component);
  BufferedImage img = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TRANSLUCENT);
  CellRendererPane crp = new CellRendererPane();
  crp.add(component);
  crp.paintComponent(img.createGraphics(), component, crp, component.getBounds());
  return img;
origin: net.sf.tinylaf/tinylaf

public void setupUI(Frame frame) {
  JScrollPane sp = new JScrollPane(editor);
  getContentPane().add(sp);
  
  pack();
  
  setSize(800, 600);
  setLocation(frame.getLocationOnScreen().x + 
    (frame.getWidth() - getSize().width) / 2,
    frame.getLocationOnScreen().y + 
    (frame.getHeight() - getSize().height) / 2);
}
origin: apache/geode

 @Override
 public void componentResized(ComponentEvent e) {
  Component source = (Component) e.getSource();
  resizeMe(source.getWidth(), source.getHeight());
 }
});
origin: stackoverflow.com

 import javax.swing.*;
import java.awt.*;

public class TestFrameSize {

  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//        frame.setSize(new Dimension(450, 400));
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
//        frame.setLayout(new BorderLayout());

    JLabel question = new JLabel("But that's whole code... Those 3 lines are whole code ");
    question.setHorizontalAlignment(JLabel.CENTER);
    frame.add(question);
    frame.setVisible(true);

    System.out.println(frame.getWidth() + " : " + frame.getHeight());
  }
}
origin: net.sf.tinylaf/tinylaf

  "dialog decoration.");
p.add(l);
getContentPane().add(p, BorderLayout.CENTER);
p.add(b);
getContentPane().add(p, BorderLayout.SOUTH);
int w = Math.max(240, getWidth() + 32), h = getHeight();		
Point loc = new Point(
  owner.getLocationOnScreen().x + (owner.getWidth() - w) / 2,
  owner.getLocationOnScreen().y + (owner.getHeight() - w) * 2 / 3);
origin: stackoverflow.com

Insets insets = parent.getInsets();
int width = parent.getWidth() - insets.left - insets.right;
int height = parent.getHeight() - insets.top - insets.bottom;
origin: stackoverflow.com

 import Utilities.*;
import javax.swing.*;
import javax.imageio.*;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
public class GradientMask {
  public static void main(String[] args) throws Exception{
    JFrame Main = new JFrame("Gradient Mask");
    JLabel imageLayer = new JLabel();
    JLabel maskLayer = new JLabel();
    BufferedImage image = ImageIO.read(new File("C:\\Users\\"+System.getenv("username")+"\\Desktop\\Cat Image.jpg"));
    BufferedImage gradientMask = new GradientImage(image.getWidth(), image.getHeight(), new Color[]{new Color(255, 255, 255, 125), Color.BLACK}, GradientImage.RADIAL_FROM_CENTER).getImage();
    Main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Main.setBounds(100, 50, image.getWidth(), image.getHeight());
    imageLayer.setBounds(0, 0, Main.getWidth(), Main.getHeight());
    maskLayer.setBounds(0, 0, Main.getWidth(), Main.getHeight());
    imageLayer.setIcon(new ImageIcon((Image) image));
    maskLayer.setIcon(new ImageIcon((Image) gradientMask));
    Main.getContentPane().add(imageLayer);
    imageLayer.add(maskLayer);
    Main.setVisible(true);
  }
}
origin: org.freehep/freehep-graphicsio

public ProgressDialog(Component parent, int steps, String string) {
  setTitle("Exporting file...");
  setModal(true);
  this.exception = null;
  this.progress = 0;
  getContentPane().setLayout(new BorderLayout());
  JPanel center = new JPanel(new GridLayout(2, 1));
  progressBar = new JProgressBar(0, steps);
  center.add(progressBar);
  label = new JLabel(string);
  center.add(label);
  getContentPane().add(center, BorderLayout.CENTER);
  JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER));
  JButton cancel = new JButton("Cancel");
  cancel.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      cancel();
    }
  });
  buttons.add(cancel);
  getContentPane().add(buttons, BorderLayout.SOUTH);
  setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
  pack();
  if (parent != null) {
    Point pLoc = parent.getLocation();
    setLocation(pLoc.x + parent.getWidth() / 2 - getWidth() / 2, pLoc.y
        + parent.getHeight() / 2 - getHeight() / 2);
  }
}
origin: magefree/mage

public static Point keepComponentInsideParent(Point l, Point parentPoint, Component c, Component parent) {
  int dx = parentPoint.x + parent.getWidth() - DEFAULT_INSETS.right - COMPONENT_INSETS.right;
  if (l.x + c.getWidth() > dx) {
    l.x = dx - c.getWidth();
  }
  int dy = parentPoint.y + parent.getHeight() - DEFAULT_INSETS.bottom - COMPONENT_INSETS.bottom;
  if (l.y + c.getHeight() > dy) {
    l.y = Math.max(10, dy - c.getHeight());
  }
  return l;
}
origin: stackoverflow.com

 import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.EmptyBorder;

public class ALineBorder {

  public static void main(String args[]) {
    JFrame frame = new JFrame("Line Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button1 = new JButton("Button1");
    button1.setBorder( new EmptyBorder( 8, 8, 8, 8 ) );
    JButton button2 = new JButton("Button2");
    JButton button3 = new JButton("Button3");
    button3.setBorder( new EmptyBorder( 16, 16, 16, 16 ) );
    Container contentPane = frame.getContentPane();
    contentPane.add(button1, BorderLayout.WEST);
    contentPane.add(button2, BorderLayout.CENTER);
    contentPane.add(button3, BorderLayout.EAST);
    frame.pack();
    frame.setSize(300, frame.getHeight());
    frame.setVisible(true);
  }

}
java.awtComponentgetHeight

Javadoc

Returns the current height of this component. This method is preferable to writing component.getBounds().height or component.getSize().height because it doesn't cause any heap allocations.

Popular methods of Component

  • getParent
    Gets the parent of this component.
  • getPreferredSize
    Gets the preferred size of this component.
  • getWidth
    Returns the current width of this component. This method is preferable to writingcomponent.getBounds
  • isVisible
    Determines whether this component should be visible when its parent is visible. Components are initi
  • setBounds
    Moves and resizes this component to conform to the new bounding rectangle r. This component's new po
  • getName
    Gets the name of the component.
  • getSize
    Stores the width/height of this component into "return value" rv and return rv. If rv is null a newD
  • setEnabled
    Enables or disables this component, depending on the value of the parameter b. An enabled component
  • setBackground
    Sets the background color of this component. The background color affects each component differently
  • setVisible
    Shows or hides this component depending on the value of parameterb.
  • getMinimumSize
    Gets the mininimum size of this component.
  • getBackground
    Gets the background color of this component.
  • getMinimumSize,
  • getBackground,
  • addMouseListener,
  • getBounds,
  • setForeground,
  • repaint,
  • setCursor,
  • setSize,
  • requestFocus

Popular in Java

  • Running tasks concurrently on multiple threads
  • getResourceAsStream (ClassLoader)
  • addToBackStack (FragmentTransaction)
  • getExternalFilesDir (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now