absolutelayout

How to absolutely position a JPanel over another JPanel with setLayout(null) and a background image?

ぃ、小莉子 提交于 2019-12-22 17:42:16
问题 I'm working with JFrames in Java, specifically with absolutely positioned elements that need to overlap. I understand that to overlay components, one should make a JPanel (with setOpacity(false); ), and position it with either setBounds(x,y,x2,y2); or setPosition(x,y) & setSize(x,y) . Unfortunately the panels act like CSS's inline-divs ; they take up only the needed amount of room on their line, and do not stack. This is the code I have so far, but it doesn't seem to act like I'd imagine it

Dynamically growing JPanel with BoxLayout (on a null layout)

独自空忆成欢 提交于 2019-12-19 12:07:21
问题 I have a JPanel with a vertical BoxLayout on top of a JPanel with a null layout. I would like the JPanel with the BoxLayout to grow as the components are being added. See this code: public static void main (String[] args) { JFrame f = new JFrame(); f.setSize(500,500); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel total = new JPanel(); total.setLayout(null); total.setSize(f.getWidth(),f.getHeight()); total.setBackground(Color.green); JPanel box = new JPanel(); box.setLocation(100

Component on JPanel not showing when setLayout(null)

人盡茶涼 提交于 2019-12-19 10:59:08
问题 Someone can tell why the combobox is not showing ? I have a Controller: public class TestController extends JPanel { TestView cgView; public TestController() { setLayout(null); cgView=new TestView(); add(cgView); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame fr = new JFrame("testt"); fr.setSize(1200,1000); fr.setResizable(false); TestController cgc=new TestController(); fr.setBackground(Color.white); fr.setVisible(true); fr

Stick Layout in Xamarin Forms to bottom

不问归期 提交于 2019-12-18 10:13:40
问题 I'm making an application in Xamarin forms but I have some trouble sticking a layout to the bottom of the device. I thought an AbsoluteLayout would work, but I cannot grasp how it works. So I made a RelativeLayout which I filled with the elements I wanted to fill but now I cannot seem to get it working on sticking to the bottom of the device at all time. Below is a screenshot to make things hopefully a little bit more clear. I have a stacklayout which I fill with the headerlayout and the

Space between buttons and window

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 14:26:02
问题 I have this code right here, and the idea is to have two buttons in a main window alongside a text area, which I have not added yet. After trying to use GridBagLayout and ripping off my hair in the process I decided not to use a layout and manually position buttons inside a non resizable window. import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Tema extends JFrame implements ActionListener { JMenuBar menubar = new JMenuBar(); JMenu actiuni = new JMenu("Actiuni");

swing component not visible

此生再无相见时 提交于 2019-12-12 00:47:43
问题 I am working on an application and I am stuck in the incipient phase. I have a JTextField in a JPanel in a JFrame . JTextField isn't there. If I use JPanel p0 = (JPanel) f.getContentPane(); it works. But Not with JPanel p0 = new JPanel(); f.add(p0); So the problems are: Why is not the field visible? (most important q) What's the difference between the 2 aforementioned approaches? Code: import java.awt.*; import java.io.*; import java.net.*; import java.util.*; import javax.swing.*; public

Getting data from JTextField that is one of several local variables

你。 提交于 2019-12-11 03:08:50
问题 So I am reading a file and I get the amount of lines in that file. Based on that I generate my interface. Now I need to have the ability to edit valus trougth UI . Rows is the variable that has how lines the input document has . Of course the code below doesnt work . I want to write new values to the array from which i read . for(int i=0;i<Rows;i++) { //System.out.println("!"+Symbol[1]+"!"); //if(Symbol[i]!=""&&Symbol[i]!=null) // { JTextField symbol = new JTextField(6); symbol.setText(Symbol

Using the deprecated AbsoluteLayout class in Android?

对着背影说爱祢 提交于 2019-12-10 19:48:16
问题 The AbsoluteLayout class is deprecated but still can write it in code and it works. Will there be any problems if I use this class? Will the application work correctly after I deploy it on a phone? Thanks 回答1: When a piece of code is listed as deprecated, it means that it'll still work for the time being, but that in some future update of the code, support for it will be dropped. This means you'll eventually have to come up with a different solution to the problem. Might as well do it now. I

Scaling layout with invariant aspect ratio in Android

戏子无情 提交于 2019-12-05 02:07:17
问题 I want to create a GUI for my app which is essentially a background image with some controls on top of it. The important (and tricky) part is that the background image should keep its aspect ratio and scale (with black borders if it's not a perfect fit), and that the controls are aligned with certain parts of the background image. I was thinking of solving this by inheriting AbsoluteLayout (or my copy of it since it's deprecated), scaling/positioning it properly and have it draw my background

Scaling layout with invariant aspect ratio in Android

大兔子大兔子 提交于 2019-12-03 20:32:45
I want to create a GUI for my app which is essentially a background image with some controls on top of it. The important (and tricky) part is that the background image should keep its aspect ratio and scale (with black borders if it's not a perfect fit), and that the controls are aligned with certain parts of the background image. I was thinking of solving this by inheriting AbsoluteLayout (or my copy of it since it's deprecated), scaling/positioning it properly and have it draw my background image. Then, I would have it place its children according to "scaled absolute positions", using the