-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8357176: java.awt javadoc code examples still use Applet API #25278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,15 +240,15 @@ | |
* left-to-right container and Figure 3 shows the layout for a horizontal, | ||
* right-to-left container. | ||
* | ||
* <div style="margin:0 auto;width:680px;text-align:center;font-weight:bold"> | ||
* <div style="margin:0 auto;width:850px;text-align:center;font-weight:bold"> | ||
* <div style="float:left"> | ||
* <p><img src="doc-files/GridBagLayout-1.gif" | ||
* <p><img src="doc-files/GridBagLayout-1.png" | ||
* alt="The preceding text describes this graphic (Figure 2)." | ||
* style="margin: 7px 10px;"> | ||
* <p>Figure 2: Horizontal, Left-to-Right | ||
* </div> | ||
* <div style="float:right"> | ||
* <p><img src="doc-files/GridBagLayout-2.gif" | ||
* <p><img src="doc-files/GridBagLayout-2.png" | ||
* alt="The preceding text describes this graphic (Figure 3)." | ||
* style="margin: 7px 10px;"> | ||
* <p>Figure 3: Horizontal, Right-to-Left | ||
|
@@ -276,73 +276,66 @@ | |
* <p> | ||
* Here is the code that implements the example shown above: | ||
* | ||
* <hr><blockquote><pre> | ||
* import java.awt.*; | ||
* import java.util.*; | ||
* import java.applet.Applet; | ||
* {@snippet lang='java': | ||
* import java.awt.Button; | ||
* import java.awt.EventQueue; | ||
* import java.awt.Frame; | ||
* import java.awt.GridBagConstraints; | ||
* import java.awt.GridBagLayout; | ||
* | ||
* public class GridBagEx1 extends Applet { | ||
* public class GridBagLayoutExample { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sample indents each code block by 4 spaces, which is good. |
||
* | ||
* protected void makebutton(String name, | ||
* GridBagLayout gridbag, | ||
* GridBagConstraints c) { | ||
* private static void addButton(String name, | ||
* GridBagLayout gridbag, | ||
* GridBagConstraints c, | ||
* Frame frame) { | ||
* Button button = new Button(name); | ||
* gridbag.setConstraints(button, c); | ||
* add(button); | ||
* frame.add(button); | ||
* } | ||
* | ||
* public void init() { | ||
* GridBagLayout gridbag = new GridBagLayout(); | ||
* GridBagConstraints c = new GridBagConstraints(); | ||
* public static void main(String[] args) throws Exception { | ||
* EventQueue.invokeAndWait(() -> { | ||
* Frame frame = new Frame("GridBagLayout"); | ||
* GridBagLayout gridbag = new GridBagLayout(); | ||
* GridBagConstraints c = new GridBagConstraints(); | ||
* frame.setLayout(gridbag); | ||
* | ||
* setFont(new Font("SansSerif", Font.PLAIN, 14)); | ||
* setLayout(gridbag); | ||
* c.fill = GridBagConstraints.BOTH; | ||
* c.weightx = 1.0; | ||
* addButton("Button1", gridbag, c, frame); | ||
* addButton("Button2", gridbag, c, frame); | ||
* addButton("Button3", gridbag, c, frame); | ||
* | ||
* c.fill = GridBagConstraints.BOTH; | ||
* c.weightx = 1.0; | ||
* makebutton("Button1", gridbag, c); | ||
* makebutton("Button2", gridbag, c); | ||
* makebutton("Button3", gridbag, c); | ||
* c.gridwidth = GridBagConstraints.REMAINDER; //end row | ||
* addButton("Button4", gridbag, c, frame); | ||
* | ||
* c.gridwidth = GridBagConstraints.REMAINDER; //end row | ||
* makebutton("Button4", gridbag, c); | ||
* c.weightx = 0.0; //reset to the default | ||
* addButton("Button5", gridbag, c, frame); //another row | ||
* | ||
* c.weightx = 0.0; //reset to the default | ||
* makebutton("Button5", gridbag, c); //another row | ||
* c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row | ||
* addButton("Button6", gridbag, c, frame); | ||
* | ||
* c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last in row | ||
* makebutton("Button6", gridbag, c); | ||
* c.gridwidth = GridBagConstraints.REMAINDER; //end row | ||
* addButton("Button7", gridbag, c, frame); | ||
* | ||
* c.gridwidth = GridBagConstraints.REMAINDER; //end row | ||
* makebutton("Button7", gridbag, c); | ||
* c.gridwidth = 1; //reset to the default | ||
* c.gridheight = 2; | ||
* c.weighty = 1.0; | ||
* addButton("Button8", gridbag, c, frame); | ||
* | ||
* c.gridwidth = 1; //reset to the default | ||
* c.gridheight = 2; | ||
* c.weighty = 1.0; | ||
* makebutton("Button8", gridbag, c); | ||
* c.weighty = 0.0; //reset to the default | ||
* c.gridwidth = GridBagConstraints.REMAINDER; //end row | ||
* c.gridheight = 1; //reset to the default | ||
* addButton("Button9", gridbag, c, frame); | ||
* addButton("Button10", gridbag, c, frame); | ||
* | ||
* c.weighty = 0.0; //reset to the default | ||
* c.gridwidth = GridBagConstraints.REMAINDER; //end row | ||
* c.gridheight = 1; //reset to the default | ||
* makebutton("Button9", gridbag, c); | ||
* makebutton("Button10", gridbag, c); | ||
* | ||
* setSize(300, 100); | ||
* } | ||
* | ||
* public static void main(String args[]) { | ||
* Frame f = new Frame("GridBag Layout Example"); | ||
* GridBagEx1 ex1 = new GridBagEx1(); | ||
* | ||
* ex1.init(); | ||
* | ||
* f.add("Center", ex1); | ||
* f.pack(); | ||
* f.setSize(f.getPreferredSize()); | ||
* f.show(); | ||
* frame.pack(); | ||
* frame.setVisible(true); | ||
* }); | ||
* } | ||
* } | ||
* </pre></blockquote><hr> | ||
* } | ||
* | ||
* @author Doug Stein | ||
* @author Bill Spitzak (original NeWS & OLIT implementation) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to keep the width small as it was?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt it - unless you make the font really small, maybe?
If you look at how it is today you'll see the buttons are packed together using Motif L&F
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/GridBagLayout.html
BTW I tried a couple of times to upload javadoc to cr.openjdk.org so I could show the new rendered javadoc but uploads failed ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I experienced some issues with uploading files to cr.openjdk.org some time ago; recently it worked well, however, the login isn't instantaneous. I uploaded the updated javadoc for
PassFailJFrame
yesterday.Yeah, it would be helpful to look at the updated javadoc. If I have some time, I'll build updated javadoc and upload it…