Skip to content
Advertisement

Tag: awt

Unexpected behavior of FlowLayout

I’m using JPanel with a default FlowLayout layout manager. I think in case the application window was resized and there is not enough width to show all components in JPanel in one row, some components will be moved to another row(s). This assumption is based on the documentation: If the horizontal space in the container is too small to put

Moving code from ActionListener to main()

PROBLEM: I have following code for the java.awt.Button : I need to move the code inside btn.addActionListener to the public static void main(String[] args), something like below (in pseudo code): RELEVANT INFORMATION : I am aware that there are better solutions for GUI development, but I am restricted to using AWT for UI. I have no power to change the

How to scale basic drawings?

I would like to have a list of shapes, that appears in my window. Whenever I’m changing the size of the window, I would like to scale all of my drawings. I already prepared classes, that store information about random shapes in a list (rectangles, ovals, etc.). I have no problem with painting them all, but I can’t deal with

JTextField size can’t be changed

} I tried to create a form and a JTextField on it. But the problem is, my location and size doesn’t work. The TextField is filling the whole form. How can I fix it? Answer The size is not “working” due to the default layout (FlowLayout) in your JFrame. This layout doesn’t let you change the size or location of

Java AWT Window doesn’t get repainted

I’ve derived a class from window, but whenever I call setValue() (which calls repaint) it doesn’t get redrawn (the method is called, but nothing changes on the screen). The first value is drawn, which is 0 by default. Here’s the class: Why does it not get repainted properly? Answer From the oracle docs If [the update] method is reimplemented, super.update(g)

Cannot load font in JRE 8

I cannot load a font from an S3 Inputstream in JRE 8. I do not have issue if a system is installed with JRE 7, JDK 7, or even JDK 8. The error that I got is I tried to load the inputstream to a temp file, but it does not help. I also tried to load a font directly

Advertisement