use of javax.swing.JComponent in project binnavi by google.
the class CModuleNodeMenuBuilder method addPluginMenus.
/**
* Adds the plugin-generated menus to the context menu.
*
* @param menu The context menu where the menu items are added.
*/
private void addPluginMenus(final JComponent menu) {
final List<IModuleMenuPlugin> plugins = new ArrayList<>();
for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
if (plugin instanceof IModuleMenuPlugin) {
plugins.add((IModuleMenuPlugin) plugin);
}
}
boolean addedSeparator = false;
for (final IModuleMenuPlugin plugin : plugins) {
try {
final List<JComponent> menuItems = plugin.extendModuleMenu(getPluginModules());
if (menuItems != null) {
for (final JComponent menuItem : menuItems) {
if (!addedSeparator) {
menu.add(new JSeparator());
addedSeparator = true;
}
menu.add(menuItem);
}
}
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00093: " + "Plugin caused an unexpected exception";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
}
}
}
use of javax.swing.JComponent in project binnavi by google.
the class CProjectContainerNodeMenuBuilder method createMenu.
@Override
protected void createMenu(final JComponent menu) {
menu.add(new JMenuItem(CActionProxy.proxy(new CCreateProjectAction(getParent(), database, new CNodeSelectionUpdater(getProjectTree(), findNode())))));
final List<IProjectFolderMenuPlugin> plugins = new ArrayList<IProjectFolderMenuPlugin>();
for (final IPlugin<IPluginInterface> plugin : PluginInterface.instance().getPluginRegistry()) {
if (plugin instanceof IProjectFolderMenuPlugin) {
plugins.add((IProjectFolderMenuPlugin) plugin);
}
}
if (!plugins.isEmpty()) {
menu.add(new JSeparator());
for (final IProjectFolderMenuPlugin plugin : plugins) {
try {
final List<JComponent> menuItems = plugin.extendProjectFolderMenu(getPluginDatabase());
if (menuItems != null) {
for (final JComponent menuItem : menuItems) {
menu.add(menuItem);
}
}
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
final String innerMessage = "E00089: " + "Plugin caused an unexpected exception";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The plugin %s caused an unexpected exception.", plugin.getName()), new String[] { "The plugin contains a bug." }, new String[] { "The plugin probably behaves erroneously from this point on but it remains active" });
NaviErrorDialog.show(getParent(), innerMessage, innerDescription, exception);
}
}
}
}
use of javax.swing.JComponent in project jdk8u_jdk by JetBrains.
the class bug7170310 method check.
private static void check() {
try {
JViewport vp = null;
for (Component c : tabbedPane.getComponents()) {
if (c instanceof JViewport) {
vp = (JViewport) c;
break;
}
}
JComponent v = (JComponent) vp.getView();
Rectangle vr = vp.getViewRect();
Dimension vs = v.getSize();
// The tab view must be scrolled to the end so that the last tab is visible
if (vs.width != (vr.x + vr.width)) {
throw new RuntimeException("tabScroller.tabPanel view is positioned incorrectly: " + vs.width + " vs " + (vr.x + vr.width));
}
} catch (Exception e) {
exception = e;
}
}
use of javax.swing.JComponent in project jdk8u_jdk by JetBrains.
the class TSFrame method createGui.
public static Frame createGui(final boolean useSwing, final boolean useShape, final boolean useTransl, final boolean useNonOpaque, final float factor) {
Frame frame;
done = false;
if (useNonOpaque) {
if (useSwing) {
frame = new NonOpaqueJFrame();
// frame = new NonOpaqueJAppletFrame(gc);
} else {
frame = new NonOpaqueFrame();
}
animateComponent(frame);
} else if (useSwing) {
frame = new JFrame("Swing Frame");
JComponent p = new JButton("Swing!");
p.setPreferredSize(new Dimension(200, 100));
frame.add("North", p);
p = new MyJPanel();
animateComponent(p);
frame.add("Center", p);
} else {
frame = new Frame("AWT Frame") {
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillRect(0, 0, 100, 100);
}
};
frame.setLayout(new BorderLayout());
Canvas c = new MyCanvas();
frame.add("North", c);
animateComponent(c);
c = new MyCanvas();
frame.add("Center", c);
animateComponent(c);
c = new MyCanvas();
frame.add("South", c);
animateComponent(c);
}
final Frame finalFrame = frame;
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
finalFrame.dispose();
done = true;
}
});
frame.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
finalFrame.dispose();
done = true;
}
});
frame.setPreferredSize(new Dimension(800, 600));
if (useShape) {
frame.setUndecorated(true);
}
frame.setLocation(450, 10);
frame.pack();
GraphicsDevice gd = frame.getGraphicsConfiguration().getDevice();
if (useShape) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSPARENT)) {
System.out.println("applying PERPIXEL_TRANSPARENT");
frame.setShape(new Ellipse2D.Double(0, 0, frame.getWidth(), frame.getHeight() / 3));
frame.setTitle("PERPIXEL_TRANSPARENT");
} else {
System.out.println("Passed: PERPIXEL_TRANSPARENT unsupported");
}
}
if (useTransl) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.TRANSLUCENT)) {
System.out.println("applying TRANSLUCENT");
frame.setOpacity(factor);
frame.setTitle("TRANSLUCENT");
} else {
System.out.println("Passed: TRANSLUCENT unsupported");
}
}
if (useNonOpaque) {
if (gd.isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
System.out.println("applying PERPIXEL_TRANSLUCENT");
frame.setBackground(new Color(0, 0, 0, 0));
frame.setTitle("PERPIXEL_TRANSLUCENT");
} else {
System.out.println("Passed: PERPIXEL_TRANSLUCENT unsupported");
}
}
frame.setVisible(true);
return frame;
}
use of javax.swing.JComponent in project jdk8u_jdk by JetBrains.
the class BMPCompressionTest method showDiff.
private static void showDiff(final BufferedImage in, final BufferedImage out) {
final int width = in.getWidth();
final int height = in.getHeight();
JFrame f = new JFrame("");
f.getContentPane().add(new JComponent() {
public Dimension getPreferredSize() {
return new Dimension(2 * width + 2, height);
}
public void paintComponent(Graphics g) {
g.setColor(Color.black);
g.drawImage(in, 0, 0, null);
g.drawImage(out, width + 2, 0, null);
}
});
f.pack();
f.setVisible(true);
}
Aggregations