layout-manager

Which Swing layout manager to get my desired layout?

情到浓时终转凉″ 提交于 2019-11-30 09:47:26
问题 I am trying to make a basic login menu following this mock up : I decided to put this whole menu into a JPanel so I can switch to another panel once the connexion is successful. So I decided to use a Borderlayout to have the title in north area and the connect button in the south area . I made the center of the borderlayout a panel itself . I decided to make it a gridlayout to both have the labels(login,password) but also the textfield in which the user will put his id. The result is very

How do I keep JTextFields in a Java Swing BoxLayout from expanding?

自作多情 提交于 2019-11-30 08:09:23
I have a JPanel that looks something like this: JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); ... panel.add(jTextField1); panel.add(Box.createVerticalStrut(10)); panel.add(jButton1); panel.add(Box.createVerticalStrut(30)); panel.add(jTextField2); panel.add(Box.createVerticalStrut(10)); panel.add(jButton2); ... //etc. My problem is that the JTextField s become huge vertically. I want them to only be high enough for a single line, since that is all that the user can type in them. The buttons are fine (they don't expand vertically). Is there any way to keep

Adding components into JPanel inside a JFrame

淺唱寂寞╮ 提交于 2019-11-30 07:49:35
问题 Since im a beginner and i don't want to get involved with the layout managers, i was simply adding a JPanel into my main JFrame and giving spesific location to each component in the panel. But somehow the output appears way too wrong.. frame = new JFrame(email + " (Offline)"); frame.setSize(400, 400); frame.setLocation(0, 0); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setLayout(new FlowLayout()); frame.addWindowListener(new WindowAdapter() { public void windowClosing

Using Java pack() method

老子叫甜甜 提交于 2019-11-30 07:42:31
问题 I can't make the pack() method work. I tried several things. My code looks like this at the moment: Class 1: public static void main( String[] args ) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JavaGui mygui = new JavaGui(); // mygui.setSize(1154, 753); mygui.setVisible(true); mygui.pack(); Class 2: public class JavaGui extends javax.swing.JFrame { public JavaGui() { getContentPane().setLayout(null); .. getContentPane().add(panelLeft); ... getContentPane().add

How to overlay, resize and centre a component on a JPanel?

对着背影说爱祢 提交于 2019-11-30 05:25:17
问题 I've spent a while reading and experimenting here, and come up with a few approaches, but not got any of them to work completely yet, so I would like to know what more experienced Swing programmers would do. The main window of my application contains a custom subtype of JPanel, which is used to display an image calculated from a mathematical function. This can take some time to calculate, so while this happens I display a text message and a progress bar superimposed on the middle of the panel

jQuery Layout Manager

孤街浪徒 提交于 2019-11-29 20:22:20
Has anyone had any experience with a jQuery-based layout manager? I know of only one ( JX ) but it's somewhat bloated for my needs. Any thoughts? Thought these links may help... jQuery UI.Layout Plug-in 6 Flexible jQuery Plugins To Control Webpage Layouts Easily 11 Best jQuery Layout Plugins I have used the Docking Layout Manager plugin with good success. Its pretty simple and fairly small, about 7 kb uncompressed. The Magic jQuery plugin at : http://www.jquery-css.com/magic-jquery is a 31kb compressed web Layout manager and much more : - fixed position - Layout manager : align and limit

more efficient layout than Box

和自甴很熟 提交于 2019-11-29 15:12:34
I've got some very old code which uses a Box to list some information. I create it like so: Box patterns = Box.createVerticalBox(); Very (very) often, new items are added and old items are removed eg: label = new JLabel("xyz"); patterns.add(label); and later patterns.remove(label); whenever something is added ore removed I have to have it repaint, so I call: patterns.revalidate(); patterns.repaint(); Problem is, since this happens very often it chokes up the UI. I think I need a better implementation in order to make it more efficient. I know I could maintain a list of the active items in the

How would I be able to achieve this expandable layout in Java? Flexible BoxLayout etc

橙三吉。 提交于 2019-11-29 11:34:06
I would like to be able to have three JPanels p1 p2 and p3, and have them lay out like so: I have been playing around with FlowLayout, BoxLayout etc but I'm not really sure if I am heading in the right direction. I am quite new with Java so I don't know what does what if I'm quite honest. I like how BoxLayout works, resizing the panels, but I would like to be able to give it some sort of width attribute. I am not using a visual designer for this, this is my window code at the moment: private void initialize() { Dimension dimensions = Toolkit.getDefaultToolkit().getScreenSize(); frame = new

Java setBounds not working with JPanel

穿精又带淫゛_ 提交于 2019-11-29 11:31:27
i am doing a small Gui in java. i am using setBounds methods to set the position of buttons etc on my JFrame , but problem is that when i use it with JPanel button is not visible on JFrame , and without JPanel its quite ok ,, see both the codes and please help me as i am beginner and facing these foolish problems . This one is working fine JFrame jframe = new JFrame("Working Fine"); jframe.setLayout(null); JButton jbutton = new JButton("Position Test"); jbutton.setBounds(0, 0, 100, 100); jframe.add(jbutton); jframe.setSize(300,300); jframe.setVisible(true); Same code when i add Button to