awt

BorderLayout - Control height but not width

烂漫一生 提交于 2020-01-14 12:42:54
问题 I am relatively new to Java UI and would appreciate your help with a simple problem that I have. I have a JPanel of type BorderLayout . The CENTER part contains a combo box. As the outer frame is resized, the panel resizes (this is desired) and the width of the combo box changes (this is desired too). However, the height of the combobox is also changing as the panel is resized. This is not desired. How can I ensure that my combo box expands in width but not in height? I also have a button in

BorderLayout - Control height but not width

99封情书 提交于 2020-01-14 12:38:07
问题 I am relatively new to Java UI and would appreciate your help with a simple problem that I have. I have a JPanel of type BorderLayout . The CENTER part contains a combo box. As the outer frame is resized, the panel resizes (this is desired) and the width of the combo box changes (this is desired too). However, the height of the combobox is also changing as the panel is resized. This is not desired. How can I ensure that my combo box expands in width but not in height? I also have a button in

Multiple JSliders activating and deactivating - Sharing values

可紊 提交于 2020-01-13 20:47:27
问题 Context Im writing a piece of code that has 1+ Sliders. These sliders form a group. The sum of the slider values of this group must always be 100. However, as a NEEDED feature, the user can disable and enable (add/remove) sliders from this group. Therefore, this requires that the sliders values get adjusted properly. After attempting to code my own group, I decided to look for a better/tested and implemented code. It improved from mine, however, some issues appeared. Primary Issue Adding or

Java applet repaint a moving circle

谁说胖子不能爱 提交于 2020-01-13 07:07:33
问题 I've just moved over from Pygame so Java 2D in an applet is a little new to me, especially when it comes to repainting the screen. In pygame you can simply do display.fill([1,1,1]) but how do I do this in an applet in Java? I understand the use of repaint() but that doesn't clear the screen - any moving object is not 'removed' from the screen so you just get a long line of painted circles. Here's my code that I've been testing with: package circles; import java.applet.Applet; import java.awt

Java GUI shows blank until resize

孤街醉人 提交于 2020-01-11 11:36:49
问题 I have written a java gui code for many options available on it. the gui is also set visible true but it doesn't show until I pick its border and drag them to resize the gui window. After manually resizing it, it shows everything. Also, the textlabels and the textfields and buttons are not in new lines, they are placed one after one. Please tell me whats wrong with that: here is a part of code: public static void initGUI(){ JFrame fr = new JFrame(); Container cont = fr.getContentPane(); cont

Java GUI shows blank until resize

眉间皱痕 提交于 2020-01-11 11:36:07
问题 I have written a java gui code for many options available on it. the gui is also set visible true but it doesn't show until I pick its border and drag them to resize the gui window. After manually resizing it, it shows everything. Also, the textlabels and the textfields and buttons are not in new lines, they are placed one after one. Please tell me whats wrong with that: here is a part of code: public static void initGUI(){ JFrame fr = new JFrame(); Container cont = fr.getContentPane(); cont

Custom Fonts in Java

ⅰ亾dé卋堺 提交于 2020-01-11 02:26:11
问题 How to fix problem with custom fonts in Java? For example, my app uses font, that isn't on all computers. Can I somehow include it in compiled executable and then call it from there, if it doesn't exists on clients computer? What are other alternatives? I could make all fonts chars as images (before, in some graphics app) and then display image for each char... is it ok? 回答1: Here's an utility method I'm using to load a font file from a .ttf file (can be bundled): private static final Font

Differences between components and lightweight/heavyweight

孤街醉人 提交于 2020-01-09 20:13:02
问题 What is the difference between JPanel and JFrame and relationship to lightweight, heavyweight? 回答1: JPanel is container that allows to put several UI components together. JFrame is a window written using Swing. All Swing components are so-called "lightwight" components because they are written in java. If for example you run Swing application and try to analyze it using UI analyzing tool (e.g. WinSpy in windows) you see only one element: the window (JFrame) itself. All other components are

Differences between components and lightweight/heavyweight

∥☆過路亽.° 提交于 2020-01-09 20:10:54
问题 What is the difference between JPanel and JFrame and relationship to lightweight, heavyweight? 回答1: JPanel is container that allows to put several UI components together. JFrame is a window written using Swing. All Swing components are so-called "lightwight" components because they are written in java. If for example you run Swing application and try to analyze it using UI analyzing tool (e.g. WinSpy in windows) you see only one element: the window (JFrame) itself. All other components are

Differences between components and lightweight/heavyweight

烈酒焚心 提交于 2020-01-09 20:10:39
问题 What is the difference between JPanel and JFrame and relationship to lightweight, heavyweight? 回答1: JPanel is container that allows to put several UI components together. JFrame is a window written using Swing. All Swing components are so-called "lightwight" components because they are written in java. If for example you run Swing application and try to analyze it using UI analyzing tool (e.g. WinSpy in windows) you see only one element: the window (JFrame) itself. All other components are