| |

VerySource

 Forgot password?
 Register
Search
View: 717|Reply: 4

How to control the display of VIEW through the menu

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-8 11:00:01
| Show all posts |Read mode
How to control the display of VIEW through the menu
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-4-1 19:00:01
| Show all posts
The question is puzzling! !! !!
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-2 06:30:02
| Show all posts
Click on a menu to display the corresponding VIEW
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-4-5 13:00:02
| Show all posts
import javax.swing. *; // Insert javax.swing package
import java.awt. *; // Insert java.awt package
import java.awt.event. *; // Insert java.awt.event package
// The following code creates a JFrame frame form
class FrameTest extends JFrame
{
    public FrameTest () // Create constructor function
    {
super ("Form title"); // Create JFrame class object
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setVisible (true); // Set the form to be visible
setSize (240,100); // Set the window size
}
}
// The following code creates a JPanel panel and adds the panel to the frame form
class PanelTest extends FrameTest
{
JPanel panelObj; // Declare JFrame class object
    public PanelTest () // Create constructor function
    {
panelObj = new JPanel (); // Create JPanel class object
// panelObj.setBackground (Color.white); // Set the panel color
getContentPane (). add (panelObj); // Add the panel to the form
}
}
// The following code creates a JTable radio button and adds the radio button to the panel
class MenuTest extends PanelTest
{
JMenuBar menuBar;
JMenu menuFile, menuEdit, menuHelp;
JMenuItem menuItemNew, menuItemOpen, menuItemSave;
JMenuItem menuItemCut, menuItemCopy, menuItemPaste;
    public MenuTest () // Create constructor function
    {
menuBar = new JMenuBar (); // Menu bar JMenuBar
setJMenuBar (menuBar);
menuFile = new JMenu ("FILE (F)"); // Menu JMenu
menuEdit = new JMenu ("Edit (E)");
menuHelp = new JMenu ("Help (H)");
menuBar.add (menuFile);
menuBar.add (menuEdit);
menuBar.add (menuHelp);
menuItemNew = new JMenuItem ("New (N)"); // Menu item JMenuItem
menuItemOpen = new JMenuItem ("Open (O)");
menuItemSave = new JMenuItem ("Save (S)");
menuFile.add (menuItemNew);
menuFile.add (menuItemOpen);
menuFile.add (menuItemSave);
menuItemCut = new JMenuItem ("cut (T)");
menuItemCopy = new JMenuItem ("Copy (C)");
menuItemPaste = new JMenuItem ("Paste (P)");
menuEdit.add (menuItemCut);
menuEdit.add (menuItemCopy);
menuEdit.add (menuItemPaste);
menuEdit.add (menuItemPaste);
}
}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Australia

Post time: 2020-4-27 19:45:01
| Show all posts
1) create a class implements interface IWorkbenchWindowActionDelegate
  in method run (IAction action)
PlatformUI.getWorkbench (). GetActiveWorkbenchWindow (). GetActivePage (). ShowView ("your View Id")

2) add an actionset in your extensions and add a menu and an action under that ActionSet
assign action's option "class" as your class created in step 1
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list