Java Code Examples for java.awt.Panel#setLayout()
The following examples show how to use
java.awt.Panel#setLayout() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectionVisible.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 2
Source File: SelectionVisible.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 3
Source File: SelectionAutoscrollTest.java From hottub with GNU General Public License v2.0 | 6 votes |
void createObjects() { textArea = new TextArea( bigString() ); robot = Util.createRobot(); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( textArea ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
Example 4
Source File: SelectionVisible.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 5
Source File: SelectionAutoscrollTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
void createObjects() { textArea = new TextArea( bigString() ); robot = Util.createRobot(); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( textArea ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
Example 6
Source File: SelectionVisible.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { ta = new TextArea(4, 20); ta.setText("01234\n56789"); ta.select(3, 9); final TextArea instruction = new TextArea("INSTRUCTIONS:\n" + "The text 34567 should be selected in the TextArea.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); instruction.setEditable(false); instruction.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(ta); setLayout(new BorderLayout()); add(instruction, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 7
Source File: SelectionVisible.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextField.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 8
Source File: SelectionVisible.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { ta = new TextArea(4, 20); ta.setText("01234\n56789"); ta.select(3, 9); final TextArea instruction = new TextArea("INSTRUCTIONS:\n" + "The text 34567 should be selected in the TextArea.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); instruction.setEditable(false); instruction.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(ta); setLayout(new BorderLayout()); add(instruction, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 9
Source File: SelectionVisible.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public void init() { ta = new TextArea(4, 20); ta.setText("01234\n56789"); ta.select(3, 9); final TextArea instruction = new TextArea("INSTRUCTIONS:\n" + "The text 34567 should be selected in the TextArea.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); instruction.setEditable(false); instruction.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(ta); setLayout(new BorderLayout()); add(instruction, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 10
Source File: SelectionVisible.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public void init() { tf = new TextArea(3, 20); tf.setText("0123456789"); tf.select(0, 6); final TextArea ta = new TextArea("INSTRUCTIONS:\n" + "The text 012345 should be selected in the TextArea.\n" + "If this is what you observe, then the test passes.\n" + "Otherwise, the test fails.", 40, 5, TextArea.SCROLLBARS_NONE); ta.setEditable(false); ta.setPreferredSize(new Dimension(300, 70)); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); panel.add(tf); setLayout(new BorderLayout()); add(ta, BorderLayout.CENTER); add(panel, BorderLayout.PAGE_END); }
Example 11
Source File: GenericDialogPlus.java From ij-ridgedetection with GNU General Public License v2.0 | 5 votes |
/** * Adds an image to the generic dialog. * * @param image * - the {@link ImageIcon} to display * @return label - the {@link JLabel} that contains the image for updating: * * image.setImage(otherImageIcon.getImage()); * label.update(label.getGraphics()); */ public JLabel addImage(final ImageIcon image) { if (isHeadless()) return null; final Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); final JLabel label = new JLabel(image); label.setOpaque(true); panel.add(label); addPanel(panel); return label; }
Example 12
Source File: HoveringAndDraggingTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void start() { String[] instructions = new String[] { "1. Notice components in test window: main-panel, box-for-text," +" 2 scroll-sliders, and 4 scroll-buttons.", "2. Hover mouse over box-for-text." +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").", "3. Hover mouse over each of components (see item 1), except for box-for-text." +" Make sure, that cursor is DefaultCursor (arrow).", "4. Drag mouse (using any mouse button) from box-for-text to every" +" component in item 1, and also outside application window." +" Make sure, that cursor remains TextCursor while mouse button is pressed.", "5. Repeat item 4 for each other component in item 1, except for box-for-text," +" _but_ now make sure that cursor is DefaultCursor.", "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed." }; Sysout.createDialogWithInstructions( instructions ); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( new TextArea( bigString() ) ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
Example 13
Source File: HoveringAndDraggingTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void start() { String[] instructions = new String[] { "1. Notice components in test window: main-panel, box-for-text," +" 2 scroll-sliders, and 4 scroll-buttons.", "2. Hover mouse over box-for-text." +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").", "3. Hover mouse over each of components (see item 1), except for box-for-text." +" Make sure, that cursor is DefaultCursor (arrow).", "4. Drag mouse (using any mouse button) from box-for-text to every" +" component in item 1, and also outside application window." +" Make sure, that cursor remains TextCursor while mouse button is pressed.", "5. Repeat item 4 for each other component in item 1, except for box-for-text," +" _but_ now make sure that cursor is DefaultCursor.", "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed." }; Sysout.createDialogWithInstructions( instructions ); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( new TextArea( bigString() ) ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
Example 14
Source File: CompositeFactory.java From erflute with Apache License 2.0 | 5 votes |
private static RowHeaderTable createTable(Composite composite, int width, int height, int rowHeaderWidth, int rowHeight, boolean iconEnable, boolean editable) { final Frame frame = SWT_AWT.new_Frame(composite); frame.setLayout(new FlowLayout()); final Panel panel = new Panel(); panel.setLayout(new FlowLayout()); frame.add(panel); final RowHeaderTable table = new RowHeaderTable(width, height, rowHeaderWidth, rowHeight, iconEnable, editable); panel.add(table); return table; }
Example 15
Source File: HoveringAndDraggingTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void start() { String[] instructions = new String[] { "1. Notice components in test window: main-panel, box-for-text," +" 2 scroll-sliders, and 4 scroll-buttons.", "2. Hover mouse over box-for-text." +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").", "3. Hover mouse over each of components (see item 1), except for box-for-text." +" Make sure, that cursor is DefaultCursor (arrow).", "4. Drag mouse (using any mouse button) from box-for-text to every" +" component in item 1, and also outside application window." +" Make sure, that cursor remains TextCursor while mouse button is pressed.", "5. Repeat item 4 for each other component in item 1, except for box-for-text," +" _but_ now make sure that cursor is DefaultCursor.", "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed." }; Sysout.createDialogWithInstructions( instructions ); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( new TextArea( bigString() ) ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
Example 16
Source File: HoveringAndDraggingTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void start() { String[] instructions = new String[] { "1. Notice components in test window: main-panel, box-for-text," +" 2 scroll-sliders, and 4 scroll-buttons.", "2. Hover mouse over box-for-text." +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").", "3. Hover mouse over each of components (see item 1), except for box-for-text." +" Make sure, that cursor is DefaultCursor (arrow).", "4. Drag mouse (using any mouse button) from box-for-text to every" +" component in item 1, and also outside application window." +" Make sure, that cursor remains TextCursor while mouse button is pressed.", "5. Repeat item 4 for each other component in item 1, except for box-for-text," +" _but_ now make sure that cursor is DefaultCursor.", "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed." }; Sysout.createDialogWithInstructions( instructions ); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( new TextArea( bigString() ) ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
Example 17
Source File: HoveringAndDraggingTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void start() { String[] instructions = new String[] { "1. Notice components in test window: main-panel, box-for-text," +" 2 scroll-sliders, and 4 scroll-buttons.", "2. Hover mouse over box-for-text." +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").", "3. Hover mouse over each of components (see item 1), except for box-for-text." +" Make sure, that cursor is DefaultCursor (arrow).", "4. Drag mouse (using any mouse button) from box-for-text to every" +" component in item 1, and also outside application window." +" Make sure, that cursor remains TextCursor while mouse button is pressed.", "5. Repeat item 4 for each other component in item 1, except for box-for-text," +" _but_ now make sure that cursor is DefaultCursor.", "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed." }; Sysout.createDialogWithInstructions( instructions ); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( new TextArea( bigString() ) ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
Example 18
Source File: HoveringAndDraggingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void start() { String[] instructions = new String[] { "1. Notice components in test window: main-panel, box-for-text," +" 2 scroll-sliders, and 4 scroll-buttons.", "2. Hover mouse over box-for-text." +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").", "3. Hover mouse over each of components (see item 1), except for box-for-text." +" Make sure, that cursor is DefaultCursor (arrow).", "4. Drag mouse (using any mouse button) from box-for-text to every" +" component in item 1, and also outside application window." +" Make sure, that cursor remains TextCursor while mouse button is pressed.", "5. Repeat item 4 for each other component in item 1, except for box-for-text," +" _but_ now make sure that cursor is DefaultCursor.", "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed." }; Sysout.createDialogWithInstructions( instructions ); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( new TextArea( bigString() ) ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
Example 19
Source File: ComponentIsNotDrawnAfterRemoveAddTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public ComponentIsNotDrawnAfterRemoveAddTest() { frame = new Frame("ComponentIsNotDrawnAfterRemoveAddTest"); frame.setSize(500, 500); frame.setLocation(200, 200); frame.setLayout(null); frame.setBackground(Color.RED); panel = new Panel(); panel.setLayout(null); panel.setBounds(25, 100, 455, 295); panel.setBackground(Color.GREEN); for (int i = 0; i < 10; i++) { TestCanvas canv1 = new TestCanvas(); canv1.setBounds(i * 45 + 5, 15, 30 + i, 30 + i); panel.add(canv1); compList.add(canv1); TestButton btn1 = new TestButton(); btn1.setBounds(i * 45 + 5, 60, 30 + i, 30 + i); panel.add(btn1); compList.add(btn1); TestCanvas canv2 = new TestCanvas(); canv2.setBounds(i * 45 + 5, 105, 30 + i, 30 + i); panel.add(canv2); compList.add(canv2); TestButton btn2 = new TestButton(); btn2.setBounds(i * 45 + 5, 150, 30 + i, 30 + i); panel.add(btn2); compList.add(btn2); TestCanvas canv3 = new TestCanvas(); canv3.setBounds(i * 45 + 5, 195, 30 + i, 30 + i); panel.add(canv3); compList.add(canv3); TestButton btn3 = new TestButton(); btn3.setBounds(i * 45 + 5, 240, 30 + i, 30 + i); panel.add(btn3); compList.add(btn3); } frame.add(panel); frame.setVisible(true); }
Example 20
Source File: PrintfApplet.java From KEEL with GNU General Public License v3.0 | 4 votes |
private void initOutputPanel(Panel p) { String blanks= " "; GridBagConstraints gbc= new GridBagConstraints(); p.setLayout(new GridBagLayout()); gbc.weightx=10; gbc.weighty=100; gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=1; gbc.gridheight=1; gbc.fill=GridBagConstraints.HORIZONTAL; gbc.anchor=GridBagConstraints.WEST; Button position=new Button("Format"); position.addActionListener(new PrintfCommand()); p.add(position,gbc); gbc.weightx=100; gbc.gridx=1; gbc.gridwidth=GridBagConstraints.REMAINDER; objectCount=new Label("0 objects"); objectCount.setBackground(Color.white); p.add(objectCount,gbc); gbc.weightx=10; gbc.gridx=0; gbc.gridy=1; gbc.gridwidth=1; Label jLabel = new Label("Output"); p.add(jLabel,gbc); gbc.weightx=100; gbc.gridx=1; gbc.gridwidth=GridBagConstraints.REMAINDER; jOutput = new Label(blanks); jOutput.setBackground(Color.white); p.add(jOutput,gbc); gbc.weightx=10; gbc.gridx=0; gbc.gridy=2; gbc.gridheight=GridBagConstraints.REMAINDER; gbc.gridwidth=1; Label eLabel = new Label("Errors"); p.add(eLabel,gbc); gbc.weightx=100; gbc.gridx=1; gbc.gridwidth=GridBagConstraints.REMAINDER; eOutput = new Label(blanks); eOutput.setBackground(Color.white); p.add(eOutput,gbc); }