border-layout

How do I put two Jpanels/Jbuttons in the borderlayout north section?

二次信任 提交于 2021-01-29 07:36:29
问题 How do I display two JPanels in the 'North' in borderlayout? Here's and example code that outputs a GUI with three distinct rows, Top, Middle, Bottom. There's one button covering the first row, 3 buttons covering the second row, and one covering the bottom row. package borderLayoutDemo; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.BorderLayout; public class BorderLayoutDemo { public static void main(String[] args) { JFrame

How do I put two Jpanels/Jbuttons in the borderlayout north section?

♀尐吖头ヾ 提交于 2021-01-29 07:30:38
问题 How do I display two JPanels in the 'North' in borderlayout? Here's and example code that outputs a GUI with three distinct rows, Top, Middle, Bottom. There's one button covering the first row, 3 buttons covering the second row, and one covering the bottom row. package borderLayoutDemo; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.BorderLayout; public class BorderLayoutDemo { public static void main(String[] args) { JFrame

BorderLayout - child component remains visible after adding another component

 ̄綄美尐妖づ 提交于 2020-01-15 15:31:58
问题 I try to do the following thing: Add a component to a JFrame with a BorderLayout Add another component to the JFrame I would expect the new component to 'overwrite' the old component, since I'm using a BorderLayout . This works if I overwrite the old component before I call pack() . Now if I add the 2nd component after I call pack() , both components remain visible. Example: public class Test extends JFrame{ public Test(){ setLayout(new BorderLayout()); add(new JLabel("Quite a long text"));

Center JLabel in BorderLayout with a button at line end

妖精的绣舞 提交于 2020-01-15 12:32:53
问题 I have a header on a section of my swing layout, and I want to have text centered horizontally across the whole width of the section, but also have a button on only the right side. It should look like this: /------Same width------\ /------Same width------\ [------------------------]Text here[----------------[Button]] I am currently using a BorderLayout, with the text in the center and the button at the line end, but the text is centered not counting the button, as such: /----Same width----\ /

how to add jscrollpane to jframe?

人盡茶涼 提交于 2020-01-09 03:52:32
问题 I have following source code...Can someone please give me an advice how to add jscrollpane onto jframe? I tried several time to add it to jframe but without any progress. It is not even showing. public class Form3 { JFrame jframe = new JFrame("Etiket print."); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JPanel panel3 = new JPanel(); JPanel panel4 = new JPanel(); JScrollPane scrollFrame = new JScrollPane(panel2); Color myBlue1Color = new Color(168, 175, 247); Color myBlue2Color

How to apply double line bottom border to a cell in iText

眉间皱痕 提交于 2020-01-05 08:48:46
问题 I need your help in applying the double line bottom border only to a cell and to remove the other top, right and left borders. I am able to implement the dotted line cell borders by using the below code: class DoubleCell implements PdfPCellEvent { public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfContentByte canvas = canvases[PdfPTable.LINECANVAS]; canvas.setLineDash(5f, 5f); canvas.rectangle(position.getLeft(), position.getBottom(), position.getWidth()

JProgressbar width using Grid/FlowLayout

社会主义新天地 提交于 2020-01-03 13:00:29
问题 I'm working on a downloader which looks like this at the moment: The JFrame uses a BorderLayout. In the NORTH, I have a JPanel(FlowLayout). In the SOUTH there is also a JPanel(FlowLayout), in the WEST I just have a JTextArea (in a JScrollPane). This is all shown correctly. However, in the EAST I currently have a JPanel(GridLayout(10, 1)). I want to show up to 10 JProgressBars in the EAST section which are added and removed from the panel dynamically. The problem is, I can not get them to look

How to centre the Buttons in my JFrame?

被刻印的时光 ゝ 提交于 2020-01-03 02:26:08
问题 I am trying to make a board game, I have Player 1 label and player 2 label set to the east and west. I am having trouble centre my 3 x 10 buttons. And is there any simpler way of making all 30 buttons at once? Below is my Code: JPanel panel = new JPanel(); JButton button1 = new JButton();JButton button2 = new JButton(); JButton button3 = new JButton();JButton button4 = new JButton(); JButton button5 = new JButton();JButton button6 = new JButton(); JButton button7 = new JButton();JButton

How do I stop center of BorderLayout from taking up east and west?

醉酒当歌 提交于 2019-12-24 15:13:53
问题 I have a program in which I use BorderLayout and the EAST and WEST positions are not filled, though the CENTER one is. As a result, the center component extends to the space where the east and west components would be. How can I prevent this? I know I could just use a blank JPanel in the east and west positions, but that seems hacky. 回答1: If what you want is empty space around your center panel, you can add a border to it: panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10); 回答2:

BorderLayout.CENTER doesn't center

 ̄綄美尐妖づ 提交于 2019-12-24 12:19:10
问题 I can't get my JLabel to center in my JPanel after adding a ChartPanel to it: JPanel panel = new JPanel(new BorderLayout()); panel.add(visualiser(ternaire), BorderLayout.NORTH);//visualiser(ternaire) is the ChartPanel panel.add(new JLabel("L'alliage a bien été enregistré."), BorderLayout.CENTER); JOptionPane jop = new JOptionPane(); jop.showMessageDialog(null, panel, "Information", JOptionPane.PLAIN_MESSAGE); Any idea why BorderLayout.CENTER doesn't work ? 回答1: JLabel by default is