本文整理汇总了Java中org.jdesktop.application.ResourceMap.injectComponents方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceMap.injectComponents方法的具体用法?Java ResourceMap.injectComponents怎么用?Java ResourceMap.injectComponents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdesktop.application.ResourceMap
的用法示例。
在下文中一共展示了ResourceMap.injectComponents方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defineUI
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
private void defineUI ()
{
ApplicationContext applicationContext = OMR.gui.getApplication().getContext();
component.setLayout(new BorderLayout());
// Progress bar
progressBar.setPreferredSize(new Dimension(90, 20));
progressBar.setName("progressBar");
progressBar.setToolTipText("Used memory / Global memory");
progressBar.setStringPainted(true);
component.add(progressBar, BorderLayout.CENTER);
// Garbage collector button
JButton button = new JButton(applicationContext.getActionMap(this).get("collectGarbage"));
button.setBorder(UIUtil.getToolBorder());
component.add(button, BorderLayout.EAST);
// Remember the default foreground color
defaultForeground = progressBar.getForeground();
// Resource injection
ResourceMap resource = applicationContext.getResourceMap(getClass());
resource.injectComponents(component);
}
示例2: showFrame
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Display the UI frame.
*/
public static void showFrame ()
{
if (frame == null) {
frame = new JFrame();
frame.setName("shapeColorChooserFrame");
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.add(new ShapeColorChooser().component);
// Resources injection
ResourceMap resource = Application.getInstance().getContext().getResourceMap(
ShapeColorChooser.class);
resource.injectComponents(frame);
}
OmrGui.getApplication().show(frame);
}
示例3: defineUI
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
private void defineUI ()
{
ApplicationContext applicationContext = MainGui.getInstance()
.getContext();
component.setLayout(new BorderLayout());
// Progress bar
progressBar.setPreferredSize(new Dimension(90, 20));
progressBar.setName("progressBar");
progressBar.setToolTipText("Used memory / Global memory");
progressBar.setStringPainted(true);
component.add(progressBar, BorderLayout.CENTER);
// Garbage collector button
JButton button = new JButton(
applicationContext.getActionMap(this).get("collectGarbage"));
button.setBorder(UIUtil.getToolBorder());
component.add(button, BorderLayout.EAST);
// Remember the default foreground color
defaultForeground = progressBar.getForeground();
// Resource injection
ResourceMap resource = applicationContext.getResourceMap(getClass());
resource.injectComponents(component);
}
示例4: getMenu
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
public JMenu getMenu ()
{
if (menu == null) {
NameSet history = ScoresManager.getInstance()
.getHistory();
menu = history.menu("Sheet History", new HistoryListener());
menu.setEnabled(!history.isEmpty());
menu.setName("historyMenu");
ResourceMap resource = MainGui.getInstance()
.getContext()
.getResourceMap(
SheetActions.class);
resource.injectComponents(menu);
}
return menu;
}
示例5: showFrame
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Display the UI frame.
*/
public static void showFrame ()
{
if (frame == null) {
frame = new JFrame();
frame.setName("shapeColorChooserFrame");
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.add(new ShapeColorChooser().component);
// Resources injection
ResourceMap resource = Application.getInstance()
.getContext()
.getResourceMap(
ShapeColorChooser.class);
resource.injectComponents(frame);
}
MainGui.getInstance()
.show(frame);
}
示例6: SampleVerifier
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Create an instance of SampleVerifier.
*/
private SampleVerifier ()
{
// Pane split vertically: selectors then browser
JSplitPane vertSplitPane = new JSplitPane(
JSplitPane.VERTICAL_SPLIT,
getSelectorsPanel(),
glyphBrowser.getComponent());
vertSplitPane.setName("SampleVerifierSplitPane");
vertSplitPane.setDividerSize(1);
// Hosting frame
frame = new JFrame();
frame.setName("SampleVerifierFrame");
frame.add(vertSplitPane);
// Resource injection
ResourceMap resource = MainGui.getInstance().getContext().
getResourceMap(
getClass());
resource.injectComponents(frame);
}
示例7: populate
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Fill the provided menu with one item per each history path.
*
* @param menu the menu to populate
* @param resourceClass the class to get menu resources from
*/
public void populate (JMenu menu,
Class<?> resourceClass)
{
history.feedMenu(
menu,
new ActionListener()
{
@Override
public void actionPerformed (ActionEvent e)
{
try {
final String name = e.getActionCommand().trim();
if (!name.isEmpty()) {
PathTask pathTask = pathTaskClass.newInstance();
pathTask.setPath(Paths.get(name));
pathTask.execute();
}
} catch (Exception ex) {
logger.warn("Error in HistoryMenu " + ex, ex);
}
}
});
// Resource injection
ResourceMap resource = OMR.gui.getApplication().getContext().getResourceMap(resourceClass);
resource.injectComponents(menu);
this.menu = menu;
// Initial menu status
menu.setEnabled(!history.isEmpty());
}
示例8: getFrame
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Report the enclosing frame of this entity
*
* @return the frame of the score browser
*/
public JFrame getFrame ()
{
if (frame == null) {
// Set up a GUI framework
frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setName("scoreTreeFrame");
// Add a REFRESH button
JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL);
frame.getContentPane().add(toolBar, BorderLayout.NORTH);
// Set up the views, and display it all
JButton refreshButton = new JButton(
new AbstractAction()
{
@Override
public void actionPerformed (ActionEvent e)
{
refresh();
}
});
refreshButton.setName("refreshButton");
toolBar.add(refreshButton);
frame.add(component);
// Resources injection
ResourceMap resource = OMR.gui.getApplication().getContext().getResourceMap(getClass());
resource.injectComponents(frame);
frame.setTitle(resource.getString("frameTitleMask", book.getRadix()));
}
return frame;
}
示例9: getFrame
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Report the enclosing frame of this entity
*
* @return the frame of the score browser
*/
public JFrame getFrame ()
{
if (frame == null) {
// Set up a GUI framework
frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setName("scoreTreeFrame");
// Add a REFRESH button
JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL);
frame.getContentPane().add(toolBar, BorderLayout.NORTH);
// Set up the views, and display it all
JButton refreshButton = new JButton(
new AbstractAction()
{
@Override
public void actionPerformed (ActionEvent e)
{
refresh();
}
});
refreshButton.setName("refreshButton");
toolBar.add(refreshButton);
frame.add(component);
// Resources injection
ResourceMap resource = MainGui.getInstance().getContext().
getResourceMap(getClass());
resource.injectComponents(frame);
frame.setTitle(
resource.getString("frameTitleMask", score.getRadix()));
}
return frame;
}
示例10: defineLayout
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Define the layout of components within the provided frame.
*
* @param frame the bare frame
* @return the populated frame
*
*/
private JFrame defineLayout (final JFrame frame)
{
frame.setName("TrainerFrame"); // For SAF life cycle
/*
* +=============================================================+
* | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
* | . . . . . . . . . . . . Selection . . . . . . . . . . . . . |
* | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
* |-------------------------------------------------------------|
* | . . . . . . . . . . . . . . || . . . . . . . . . . . . . . .|
* | . Training. . . . . . . . . || . Training. . . . . . . . . .|
* | . . . . . . . . . . . . . . || . . . . . . . . . . . . . . .|
* |-----------------------------||------------------------------|
* | . . . . . . . . . . . . . . || . . . . . . . . . . . . . . .|
* | . Validation [train set]. . || . Validation [train set]. . .|
* | . . . . . . . . . . . . . . || . . . . . . . . . . . . . . .|
* |-----------------------------||------------------------------|
* | . . . . . . . . . . . . . . || . . . . . . . . . . . . . . .|
* | . Validation [test set] . . || . Validation [test set] . . .|
* | . . . . . . . . . . . . . . || . . . . . . . . . . . . . . .|
* +=============================================================+
*/
FormLayout layout = new FormLayout("pref, 10dlu, pref", "pref, 10dlu, pref");
CellConstraints cst = new CellConstraints();
PanelBuilder builder = new PanelBuilder(layout, new Panel());
int r = 1; // --------------------------------
builder.add(selectionPanel.getComponent(), cst.xyw(1, r, 3, "center, fill"));
r += 2; // --------------------------------
builder.add(definePanel(ShapeClassifier.getInstance()), cst.xy(1, r));
builder.add(definePanel(ShapeClassifier.getSecondInstance()), cst.xy(3, r));
frame.add(builder.getPanel());
// Resource injection
ResourceMap resource = OmrGui.getApplication().getContext().getResourceMap(getClass());
resource.injectComponents(frame);
return frame;
}
示例11: registerAllActions
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Register all actions as listed in the descriptor files, and organize them
* according to the various domains defined.
* There is one pull-down menu generated for each domain found.
*/
public void registerAllActions ()
{
// Insert an initial separator, to let user easily grab the toolBar
toolBar.addSeparator();
DomainLoop:
for (String domain : Actions.getDomainNames()) {
// Create dedicated menu for this range, if not already existing
JMenu menu = menuMap.get(domain);
if (menu == null) {
logger.debug("Creating menu:{}", domain);
menu = new SeparableMenu(domain);
menuMap.put(domain, menu);
} else {
logger.debug("Augmenting menu:{}", domain);
}
// Proper menu decoration
ResourceMap resource = OMR.gui.getApplication().getContext()
.getResourceMap(Actions.class);
menu.setText(domain); // As default
menu.setName(domain);
// Register all actions in the given domain
registerDomainActions(domain, menu);
resource.injectComponents(menu); // Localized
SeparableMenu.trimSeparator(menu); // No separator at end of menu
// Smart insertion of the menu into the menu bar, and separators into the toolBar
if (menu.getItemCount() > 0) {
final int toolCount = toolBar.getComponentCount();
if (toolCount > 0) {
Component comp = toolBar.getComponent(toolCount - 1);
if (!(comp instanceof JToolBar.Separator)) {
toolBar.addSeparator();
}
}
menuBar.add(menu);
}
}
}
示例12: GlyphTrainer
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Create an instance of Glyph Trainer (there should be just one)
*/
private GlyphTrainer ()
{
if (standAlone) {
// UI Look and Feel
UILookAndFeel.setUI(null);
}
frame = new JFrame();
frame.setName("trainerFrame");
// Listener on remaining error
ChangeListener errorListener = new ChangeListener()
{
@Override
public void stateChanged (ChangeEvent e)
{
frame.setTitle(
String.format(
"%.5f - %s",
networkPanel.getBestError(),
frameTitle));
}
};
// Create the three companions
selectionPanel = new SelectionPanel(task, standardWidth);
networkPanel = new NetworkPanel(
task,
standardWidth,
errorListener,
selectionPanel);
selectionPanel.setTrainingPanel(networkPanel);
validationPanel = new ValidationPanel(
task,
standardWidth,
GlyphNetwork.getInstance(),
selectionPanel,
networkPanel);
regressionPanel = new RegressionPanel(
task,
standardWidth,
selectionPanel);
frame.add(createGlobalPanel());
// Initial state
task.setActivity(Task.Activity.INACTIVE);
// Specific ending if stand alone
if (standAlone) {
frame.addWindowListener(windowCloser);
}
// Resource injection
ResourceMap resource = MainGui.getInstance()
.getContext()
.getResourceMap(getClass());
resource.injectComponents(frame);
frameTitle = frame.getTitle();
}
示例13: registerAllActions
import org.jdesktop.application.ResourceMap; //导入方法依赖的package包/类
/**
* Register all actions as listed in the descriptor files, and
* organize them according to the various domains defined.
* There is one pull-down menu generated for each domain found.
*/
public void registerAllActions ()
{
// Insert an initial separator, to let user easily grab the toolBar
toolBar.addSeparator();
for (String domain : Actions.getDomainNames()) {
// Create dedicated menu for this range, if not already existing
JMenu menu = menuMap.get(domain);
if (menu == null) {
logger.debug("Creating menu:{}", domain);
menu = new SeparableMenu(domain);
menuMap.put(domain, menu);
} else {
logger.debug("Augmenting menu:{}", domain);
}
// Proper menu decoration
ResourceMap resource = MainGui.getInstance().getContext().
getResourceMap(Actions.class);
menu.setText(domain); // As default
menu.setName(domain);
// Register all actions in the given domain
registerDomainActions(domain, menu);
resource.injectComponents(menu);
toolBar.addSeparator();
// Smart insertion of the menu into the menu bar
if (menu.getItemCount() > 0) {
if (domain.equalsIgnoreCase("help")) {
menuBar.add(Box.createHorizontalStrut(50));
}
SeparableMenu.trimSeparator(menu); // No separator at end
menuBar.add(menu);
}
}
}