Java Code Examples for java.awt.Panel#add()
The following examples show how to use
java.awt.Panel#add() .
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 jdk8u-dev-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 2
Source File: WPrinterJob.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example 3
Source File: WPrinterJob.java From hottub with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example 4
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 5
Source File: SelectionAutoscrollTest.java From jdk8u-jdk 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: WPrinterJob.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example 7
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 8
Source File: WPrinterJob.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example 9
Source File: SelectionVisible.java From openjdk-8-source 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 10
Source File: WPrinterJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example 11
Source File: SelectionAutoscrollTest.java From openjdk-8 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 12
Source File: SelectionVisible.java From openjdk-8-source 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 13
Source File: SelectionVisible.java From openjdk-jdk8u 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 14
Source File: SelectionVisible.java From hottub 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 15
Source File: GIPApplet.java From swift-k with Apache License 2.0 | 5 votes |
public EmailConfirmationDialog(Frame parent, String[] messages, String textArea) { super(parent, true); setTitle("Confirmation Dialog"); Font font = new Font("Courier", Font.PLAIN, 12); setFont(font); int rows = messages.length; Panel textPanel = new Panel(); textPanel.setLayout(new GridLayout(rows,1)); for(int i = 0; i < rows; i++){ textPanel.add(new Label(messages[i])); } add("North", textPanel); Panel textAreaPanel = new Panel(); TextArea ta = new TextArea(12,60); ta.setText(textArea); textAreaPanel.add(ta); add("Center", textAreaPanel); Panel p = new Panel(); p.setLayout(new FlowLayout()); Button yes = new Button("Yes"); yes.addActionListener(this); p.add(yes); Button no = new Button("No"); no.addActionListener(this); p.add(no); add("South", p); setLocation(100, 200); pack(); }
Example 16
Source File: SelectionInvisibleTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(TEXT + LAST_WORD, 30); Panel panel = new Panel(new FlowLayout()); panel.add(textField); frame.add(panel); frame.setVisible(true); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); toolkit.realSync(); Robot robot = new Robot(); robot.setAutoDelay(50); Point point = textField.getLocationOnScreen(); int x = point.x + textField.getWidth() / 2; int y = point.y + textField.getHeight() / 2; robot.mouseMove(x, y); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); toolkit.realSync(); robot.mousePress(InputEvent.BUTTON1_MASK); int N = 10; int dx = textField.getWidth() / N; for (int i = 0; i < N; i++) { x += dx; robot.mouseMove(x, y); } robot.mouseRelease(InputEvent.BUTTON1_MASK); toolkit.realSync(); if (!textField.getSelectedText().endsWith(LAST_WORD)) { throw new RuntimeException("Last word is not selected!"); } }
Example 17
Source File: CertDestroyApplet.java From swift-k with Apache License 2.0 | 5 votes |
public ConfirmationDialog(Frame parent, String[] messages) { super(parent, true); setTitle("Confirmation Dialog"); Font font = new Font("Courier", Font.PLAIN, 12); setFont(font); int rows = messages.length; Panel textPanel = new Panel(); textPanel.setLayout(new GridLayout(rows,1)); for(int i = 0; i < rows; i++){ textPanel.add(new Label(messages[i])); } add("Center", textPanel); Panel p = new Panel(); p.setLayout(new FlowLayout()); Button yes = new Button("Yes"); yes.addActionListener(this); p.add(yes); Button no = new Button("No"); no.addActionListener(this); p.add(no); add("South", p); setSize(300, 100); setLocation(100, 200); pack(); }
Example 18
Source File: SelectionInvisibleTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Frame frame = new Frame(); frame.setSize(300, 200); TextField textField = new TextField(TEXT + LAST_WORD, 30); Panel panel = new Panel(new FlowLayout()); panel.add(textField); frame.add(panel); frame.setVisible(true); SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); toolkit.realSync(); Robot robot = new Robot(); robot.setAutoDelay(50); Point point = textField.getLocationOnScreen(); int x = point.x + textField.getWidth() / 2; int y = point.y + textField.getHeight() / 2; robot.mouseMove(x, y); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); toolkit.realSync(); robot.mousePress(InputEvent.BUTTON1_MASK); int N = 10; int dx = textField.getWidth() / N; for (int i = 0; i < N; i++) { x += dx; robot.mouseMove(x, y); } robot.mouseRelease(InputEvent.BUTTON1_MASK); toolkit.realSync(); if (!textField.getSelectedText().endsWith(LAST_WORD)) { throw new RuntimeException("Last word is not selected!"); } }
Example 19
Source File: InteractivePlotter.java From Scripts with GNU General Public License v3.0 | 4 votes |
private void setPlotOptions() { if (plot == null) return; final int DEF_LINE_WIDTH = 1; final int DEF_MAX_INTERVALS = 12; final int DEF_TICK_LENGTH = 7; final int DEF_MINOR_TICK_LENGTH = 3; final int[] NUM_DEFAULTS = { DEF_LINE_WIDTH, DEF_MAX_INTERVALS, DEF_TICK_LENGTH, DEF_MINOR_TICK_LENGTH }; final String DEF_BACKGROUND_COLOR = "white"; final String title = plot.getTitle(); final GenericDialog ogd = new GenericDialog("Options for " + title); ogd.setInsets(0, 10, 10); ogd.addMessage("This prompt allows you access customizations that\n" + "are not accessible through the plot's \"More \u00bb\" menu"); if (!pwClosed) ogd.addStringField("Plot title:", title, 27); ogd.addSlider("Line width:", 1, 20, 1); ogd.addSlider("Max. n. of intervals:", 1, 40, 12); ogd.addSlider("Major ticks length:", 1, 14, 7); ogd.addSlider("Minor ticks length:", 1, 14, 3); ogd.addChoice("Backgrond color:", Colors.colors, DEF_BACKGROUND_COLOR); final Panel buttonPanel = new Panel(); final Button fontButton = new Button(" Text & Font... "); fontButton.addActionListener(ogd); buttonPanel.add(fontButton); final Button templateButton = new Button("Apply Template..."); templateButton.addActionListener(ogd); buttonPanel.add(templateButton); ogd.addPanel(buttonPanel, GridBagConstraints.EAST, new Insets(0, 0, 0, 0)); ogd.hideCancelButton(); ogd.addHelp(""); ogd.setHelpLabel("Apply Defaults"); ogd.addDialogListener(new DialogListener() { @Override public boolean dialogItemChanged(final GenericDialog gd, final AWTEvent e) { if (e != null && e.toString().contains("Apply Defaults")) { @SuppressWarnings("unchecked") final Vector<TextField> nFields = gd.getNumericFields(); for (final TextField field : nFields) field.setText(Integer.toString(NUM_DEFAULTS[nFields.indexOf(field)])); @SuppressWarnings("unchecked") final Vector<Choice> nChoices = gd.getChoices(); nChoices.firstElement().select(DEF_BACKGROUND_COLOR); } else if (e != null && e.toString().contains("Font")) { setPlotFont(); return true; } else if (e != null && e.toString().contains("Template")) { setTemplate(); return true; } plot.setLineWidth((int) ogd.getNextNumber()); plot.setMaxIntervals((int) ogd.getNextNumber()); plot.setTickLength((int) ogd.getNextNumber()); plot.setBackgroundColor(Colors.colors[ogd.getNextChoiceIndex()]); plot.updateImage(); return true; } }); showAsSubDialog(ogd); if (!ogd.wasOKed()) return; if (!pwClosed) plot.getImagePlus().setTitle(WindowManager.makeUniqueName(ogd.getNextString())); }
Example 20
Source File: ReqView.java From rest-client with Apache License 2.0 | 4 votes |
/** * * @Title: init * @Description: Component Initialization * @param * @return void * @throws */ private void init() { this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH)); this.setBorder(BorderFactory.createEmptyBorder(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH)); pnlUrl = new Panel(); pnlUrl.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, 0)); iconStart = UIUtil.getIcon(RESTConst.ICON_START); iconStop = UIUtil.getIcon(RESTConst.ICON_STOP); btnStart = new JButton(iconStart); btnStart.setName(RESTConst.START); btnStart.setToolTipText(RESTConst.START); btnStart.addActionListener(this); cbMtd = new JComboBox<HttpMethod>(HttpMethod.values()); cbMtd.setToolTipText(RESTConst.METHOD); cbMtd.addActionListener(this); cbUrl = new JComboBox<String>(); cbUrl.setEditable(true); cbUrl.setToolTipText(RESTConst.URL); cbUrl.requestFocus(); pnlUrl.add(cbMtd, BorderLayout.WEST); pnlUrl.add(cbUrl, BorderLayout.CENTER); pnlUrl.add(btnStart, BorderLayout.EAST); this.add(pnlUrl, BorderLayout.NORTH); // pane contains body, header, cookie, parameter JTabbedPane tp = new JTabbedPane(); pnlBody = new ReqBodyPanel(); tp.add(RESTConst.BODY, pnlBody); pnlHdr = new ReqTabPanel(RESTConst.HEADER); tp.add(RESTConst.HEADER, pnlHdr); pnlCookie = new ReqTabPanel(RESTConst.COOKIE); tp.add(RESTConst.COOKIE, pnlCookie); this.add(tp, BorderLayout.CENTER); pb = new JProgressBar(); pb.setVisible(false); this.add(pb, BorderLayout.SOUTH); this.setBorder(BorderFactory.createTitledBorder(null, RESTConst.HTTP_REQUEST, TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION)); }